class Sastrawi::StopWordRemover::StopWordRemover

Attributes

dictionary[R]

Public Class Methods

new(dictionary) click to toggle source
# File lib/sastrawi/stop_word_remover/stop_word_remover.rb, line 6
def initialize(dictionary)
  @dictionary = dictionary
end

Public Instance Methods

remove(text) click to toggle source

Remove stop words

# File lib/sastrawi/stop_word_remover/stop_word_remover.rb, line 13
def remove(text)
  words = text.split(' ')
  stop_words = []

  words.each do |word|
    unless @dictionary.contains?(word)
      stop_words.push(word)
    end
  end

  stop_words.join(' ')
end