Class: NHKore::DictFormVariator
- Defined in:
- lib/nhkore/variator.rb
Overview
Guesses a word’s dictionary/plain form (辞書形).
It doesn’t work very well,but better than nothing…
Direct Known Subclasses
Instance Attribute Summary collapse
-
#deinflector ⇒ Object
Returns the value of attribute deinflector.
Instance Method Summary collapse
- #end_variate(str) ⇒ Object
-
#initialize ⇒ DictFormVariator
constructor
A new instance of DictFormVariator.
Methods inherited from Variator
Constructor Details
#initialize ⇒ DictFormVariator
Returns a new instance of DictFormVariator.
40 41 42 43 44 45 46 47 |
# File 'lib/nhkore/variator.rb', line 40 def initialize(*) require 'set' # Must require manually because JapaneseDeinflector is old require 'japanese_deinflector' super @deinflector = JapaneseDeinflector.new end |
Instance Attribute Details
#deinflector ⇒ Object
Returns the value of attribute deinflector.
38 39 40 |
# File 'lib/nhkore/variator.rb', line 38 def deinflector @deinflector end |
Instance Method Details
#end_variate(str) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/nhkore/variator.rb', line 49 def end_variate(str) guess = @deinflector.deinflect(str) return [] if guess.length < 1 return [] if (guess = guess[0])[:weight] < 0.5 return [guess[:word]] end |