Class: Sastrawi::Stemmer::Context::Visitor::RemoveInflectionalParticle

Inherits:
Object
  • Object
show all
Defined in:
lib/sastrawi/stemmer/context/visitor/remove_inflectional_particle.rb

Instance Method Summary collapse

Instance Method Details

#remove(word) ⇒ Object

Remove inflectional particle: lah|kah|tah|pun



27
28
29
# File 'lib/sastrawi/stemmer/context/visitor/remove_inflectional_particle.rb', line 27

def remove(word)
  word.sub(/-*(lah|kah|tah|pun)$/, '')
end

#visit(context) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sastrawi/stemmer/context/visitor/remove_inflectional_particle.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, 'P')

    context.add_removal(removal)
    context.current_word = result
  end
end