Class: Zenlish::Lang::Lemmatizer

Inherits:
Object
  • Object
show all
Defined in:
lib/zenlish/lang/lemmatizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aLexicon) ⇒ Lemmatizer

Returns a new instance of Lemmatizer.



11
12
13
14
# File 'lib/zenlish/lang/lemmatizer.rb', line 11

def initialize(aLexicon)
  @trie = Trie::Trie.new
  initialize_trie(aLexicon)
end

Instance Attribute Details

#trieTrie:Trie (readonly)

Returns Trie (aka prefix tree) with all word forms from dictionary.

Returns:

  • (Trie:Trie)

    Trie (aka prefix tree) with all word forms from dictionary.



9
10
11
# File 'lib/zenlish/lang/lemmatizer.rb', line 9

def trie
  @trie
end

Instance Method Details

#lemmatize(aWordForm, _hints = nil) ⇒ Object



16
17
18
19
# File 'lib/zenlish/lang/lemmatizer.rb', line 16

def lemmatize(aWordForm, _hints = nil)
  node = trie.search(aWordForm)
  node&.value
end