Class: Pingilish::DbFilter
- Inherits:
-
Object
- Object
- Pingilish::DbFilter
- Defined in:
- lib/pingilish.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ DbFilter
constructor
A new instance of DbFilter.
- #process ⇒ Object
Constructor Details
#initialize(text) ⇒ DbFilter
Returns a new instance of DbFilter.
57 58 59 |
# File 'lib/pingilish.rb', line 57 def initialize(text) @text = text.gsub(/ي/,"ی").gsub(/ك/,"ک") # dealing with non-standard characters end |
Instance Method Details
#process ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 |