class ClassifierReborn::WordList
This class keeps a word => index mapping. It is used to map stemmed words to dimensions of a vector.
Public Class Methods
new()
click to toggle source
# File lib/classifier-reborn/lsi/word_list.rb, line 10 def initialize @location_table = {} end
Public Instance Methods
[](lookup)
click to toggle source
Returns the dimension of the word or nil if the word is not in the space.
# File lib/classifier-reborn/lsi/word_list.rb, line 20 def [](lookup) @location_table[lookup] end
add_word(word)
click to toggle source
Adds a word (if it is new) and assigns it a unique dimension.
# File lib/classifier-reborn/lsi/word_list.rb, line 15 def add_word(word) @location_table[word] = @location_table.size unless @location_table[word] end
size()
click to toggle source
Returns the number of words mapped.
# File lib/classifier-reborn/lsi/word_list.rb, line 29 def size @location_table.size end
word_for_index(ind)
click to toggle source
# File lib/classifier-reborn/lsi/word_list.rb, line 24 def word_for_index(ind) @location_table.invert[ind] end