Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/sent/main.rb

Overview

Produce Stem lists, used by the Web Service

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reset_stem_listObject



20
21
22
# File 'lib/sent/main.rb', line 20

def self.reset_stem_list
  @@stem_dictionary = Hash.new
end

.stem_list(dictionary = nil) ⇒ Object

Returns the dictionary of recorded stems.



34
35
36
37
38
39
40
41
# File 'lib/sent/main.rb', line 34

def self.stem_list(dictionary = nil)
  stem_list = Hash.new
  @@stem_dictionary.each{|k,l|
    next if dictionary && !dictionary.include?(k)
    stem_list[k] = l.keys
  }
  stem_list
end

Instance Method Details

#old_stemObject



18
# File 'lib/sent/main.rb', line 18

alias old_stem stem

#stemObject

Extends the stem functionality so that is generates a dictionary of stems. For each stem a list of words that reduce to it.



26
27
28
29
30
31
# File 'lib/sent/main.rb', line 26

def stem
  res = old_stem
  @@stem_dictionary[res] ||= Hash.new
  @@stem_dictionary[res][self] ||= 1
  res
end