Sha256: 401206ec8f1ab2f2a68b6651bd3f14852a072b6fc1f26b1f201df604962c5585

Contents?: true

Size: 483 Bytes

Versions: 4

Compression:

Stored size: 483 Bytes

Contents

module Sastrawi
  module StopWordRemover
    class StopWordRemover
      attr_reader :dictionary

      def initialize(dictionary)
        @dictionary = dictionary
      end

      ##
      # Remove stop words

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sastrawi-0.1.4 lib/sastrawi/stop_word_remover/stop_word_remover.rb
sastrawi-0.1.3 lib/sastrawi/stop_word_remover/stop_word_remover.rb
sastrawi-0.1.2 lib/sastrawi/stop_word_remover/stop_word_remover.rb
sastrawi-0.1.1 lib/sastrawi/stop_word_remover/stop_word_remover.rb