Class: Sastrawi::Stemmer::Context::Visitor::RemovePlainPrefix
- Inherits:
-
Object
- Object
- Sastrawi::Stemmer::Context::Visitor::RemovePlainPrefix
- Defined in:
- lib/sastrawi/stemmer/context/visitor/remove_plain_prefix.rb
Instance Method Summary collapse
-
#remove(word) ⇒ Object
Remove plain prefix: di|ke|se.
- #visit(context) ⇒ Object
Instance Method Details
#remove(word) ⇒ Object
Remove plain prefix: di|ke|se
27 28 29 |
# File 'lib/sastrawi/stemmer/context/visitor/remove_plain_prefix.rb', line 27 def remove(word) word.sub(/^(di|ke|se)/, '') end |
#visit(context) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sastrawi/stemmer/context/visitor/remove_plain_prefix.rb', line 11 def visit(context) result = remove(context.current_word) if result != context.current_word removed_part = context.current_word.sub(/#{Regexp.quote(result)}/, '') removal = Removal.new(self, context.current_word, result, removed_part, 'DP') context.add_removal(removal) context.current_word = result end end |