Class: Zenlish::Lang::Lemmatizer
- Inherits:
-
Object
- Object
- Zenlish::Lang::Lemmatizer
- Defined in:
- lib/zenlish/lang/lemmatizer.rb
Instance Attribute Summary collapse
-
#trie ⇒ Trie:Trie
readonly
Trie (aka prefix tree) with all word forms from dictionary.
Instance Method Summary collapse
-
#initialize(aLexicon) ⇒ Lemmatizer
constructor
A new instance of Lemmatizer.
- #lemmatize(aWordForm, _hints = nil) ⇒ Object
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
#trie ⇒ Trie:Trie (readonly)
Returns 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 |