Class: Sastrawi::Stemmer::Context::Visitor::RemoveDerivationalSuffix
- Inherits:
-
Object
- Object
- Sastrawi::Stemmer::Context::Visitor::RemoveDerivationalSuffix
- Defined in:
- lib/sastrawi/stemmer/context/visitor/remove_derivational_suffix.rb
Instance Method Summary collapse
-
#remove_suffix(word) ⇒ Object
Original rule: i|kan|an Added the adopted foreign suffix rule: is|isme|isasi.
- #visit(context) ⇒ Object
Instance Method Details
#remove_suffix(word) ⇒ Object
Original rule: i|kan|an Added the adopted foreign suffix rule: is|isme|isasi
30 31 32 |
# File 'lib/sastrawi/stemmer/context/visitor/remove_derivational_suffix.rb', line 30 def remove_suffix(word) word.sub(/(is|isme|isasi|i|kan|an)$/, '') end |
#visit(context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sastrawi/stemmer/context/visitor/remove_derivational_suffix.rb', line 13 def visit(context) result = remove_suffix(context.current_word) if result != context.current_word removed_part = context.current_word.sub(/#{Regexp.quote(result)}/, '') removal = Sastrawi::Stemmer::Context::Removal.new(self, context.current_word, result, removed_part, 'DS') context.add_removal(removal) context.current_word = result end end |