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
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.
50 51 52 53 54 55 56 57 |
# File 'lib/nhkore/variator.rb', line 50 def initialize(*) require 'set' # Must require manually because JapaneseDeinflector is old require 'japanese_deinflector' super @deinflector = JapaneseDeinflector.new end |
Instance Attribute Details
#deinflector ⇒ Object
48 49 50 |
# File 'lib/nhkore/variator.rb', line 48 def deinflector @deinflector end |
Instance Method Details
#end_variate(str) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/nhkore/variator.rb', line 59 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 |