Skip to content

Commit

Permalink
renamed SkipWords to StopWords
Browse files Browse the repository at this point in the history
  • Loading branch information
luisparravicini committed Dec 26, 2009
1 parent e0235ea commit ee0dd7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/classifier/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def stemmer

def word_hash_for_words(words)
d = Hash.new
skip_words = SkipWords.for(@options[:language])
skip_words = StopWords.for(@options[:language])
words.each do |word|
word = word.mb_chars.downcase.to_s if word =~ /[\w]+/
key = stemmer.stem(word).intern
Expand Down
10 changes: 5 additions & 5 deletions lib/classifier/stopwords.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module Classifier

module SkipWords
module StopWords

def self.for(language)
unless SKIP_WORDS.has_key?(language)
SKIP_WORDS[language] = load_stopwords(language) || []
unless STOP_WORDS.has_key?(language)
STOP_WORDS[language] = load_stopwords(language) || []
end
SKIP_WORDS[language]
STOP_WORDS[language]
end

protected
Expand All @@ -25,6 +25,6 @@ def self.load_stopwords(language)
end
end

SKIP_WORDS = {}
STOP_WORDS = {}
end
end
10 changes: 5 additions & 5 deletions test/stopwords_test.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# coding:utf-8
require File.dirname(__FILE__) + '/test_helper'

class SkipWordsTest < Test::Unit::TestCase
class StopWordsTest < Test::Unit::TestCase
def test_en
assert_equal 80, Classifier::SkipWords.for('en').size
assert_equal 80, Classifier::StopWords.for('en').size
end

def test_ru
assert_equal 159, Classifier::SkipWords.for('ru').size
assert_equal 159, Classifier::StopWords.for('ru').size
end

def test_stopword_es
list = Classifier::SkipWords.for('es')
list = Classifier::StopWords.for('es')
assert list.include?('más')
end

def test_unknown
assert_equal [], Classifier::SkipWords.for('xxyyzz')
assert_equal [], Classifier::StopWords.for('xxyyzz')
end
end

0 comments on commit ee0dd7a

Please sign in to comment.