class Pingilish::MappingFilter
Constants
- CHAR_MAP
- CHAR_MAP_FILE_PATH
- ENGLISH_CHARS
- PERSIAN_CHARS
Public Class Methods
new(text)
click to toggle source
# File lib/pingilish.rb, line 31 def initialize(text) @text = text end
Public Instance Methods
process()
click to toggle source
# File lib/pingilish.rb, line 35 def process # general character replacement text = @text.to_s.tr(PERSIAN_CHARS,ENGLISH_CHARS) CHAR_MAP.each { |k, v| text.gsub!("#{k}","#{v}") } return text # TODO: make a mapping hash instead of this dirty gsub ing # TODO: replace non latin alphabet at the end # TODO: return an object with alternatives (like chert/chort) # TODO: seperate the login into classes: Tokenizer, StemmingFilter, DbFilter, GeneralMappingFilter # TODO: seperate the logic of dealing with a backend in a class, subclass it and write something for YML # BUG: major bug, do not replace latin chars that came from DB by latin chars in mapping array! # TODO: write the mapping filter interations end