lib/indonesian_stemmer.rb in indonesian_stemmer-0.1.0 vs lib/indonesian_stemmer.rb in indonesian_stemmer-0.1.1
- old
+ new
@@ -8,18 +8,23 @@
attr_accessor :number_of_syllables
def stem(word, derivational_stemming = true)
@flags = 0
- @number_of_syllables = total_syllables word
- remove_particle(word) if still_has_many_syllables?
- remove_possessive_pronoun(word) if still_has_many_syllables?
+ if word =~ /\s/
+ word.split(' ').map { |w| stem(w) }
+ else
+ @number_of_syllables = total_syllables word
- stem_derivational(word) if derivational_stemming
+ remove_particle(word) if still_has_many_syllables?
+ remove_possessive_pronoun(word) if still_has_many_syllables?
- word
+ stem_derivational(word) if derivational_stemming
+
+ word
+ end
end
private
def stem_derivational(word)
@@ -44,8 +49,12 @@
end
end
class String
def stem
+ IndonesianStemmer.stem(self.dup)
+ end
+
+ def stem!
IndonesianStemmer.stem(self)
end
end