class Pingilish::DbFilter

Public Class Methods

new(text) click to toggle source
# File lib/pingilish.rb, line 57
def initialize(text) 
  @text = text.gsub(/ي/,"ی").gsub(/ك/,"ک") # dealing with non-standard characters
end

Public Instance Methods

process() click to toggle source
# File lib/pingilish.rb, line 61
def process
  text = @text
  y_db = YamlBackend.new
  words = Tokenizer.new(@text)
  
  db = y_db.load
  words.tokens.each do |w|
    text = text.gsub(/#{w}/, db[w].to_s) if db[w]
  end
 
  return text
# BUG: do not gsub just replace the text
# BUG: case for hash and string
end