Class: ClassifierReborn::WordList

### Home Classes Methods

### In Files

- lib/classifier-reborn/lsi/word_list.rb

### Parent

Object

### Methods

- ::new
- #[]
- #add_word
- #size
- #word_for_index

### Files

- LICENSE

### Class/Module Index

Quicksearch

- ClassifierReborn
- ClassifierReborn::Bayes
- ClassifierReborn::CategoryNamer
- ClassifierReborn::ContentNode
- ClassifierReborn::Hasher
- ClassifierReborn::LSI
- ClassifierReborn::Summarizer
- ClassifierReborn::WordList
- GSL
- GSL::Matrix
- GSL::Vector
- Matrix

No matching classes.

# 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 = Hash.new
    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 21
    def [](lookup)
      term = lookup
      @location_table[term]
    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)
      term = word
      @location_table[term] = @location_table.size unless @location_table[term]
    end

size() click to toggle source

Returns the number of words mapped.

    # File lib/classifier-reborn/lsi/word_list.rb, line 31
    def size
      @location_table.size
    end

word_for_index(ind) click to toggle source

    # File lib/classifier-reborn/lsi/word_list.rb, line 26
    def word_for_index(ind)
      @location_table.invert[ind]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.