Class: Katsuyoujin::Analyzer
- Inherits:
-
Object
- Object
- Katsuyoujin::Analyzer
- Defined in:
- lib/katsuyoujin/analyzer.rb
Instance Attribute Summary collapse
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Instance Method Summary collapse
- #base_form ⇒ Object
- #base_form_hiragana ⇒ Object
-
#initialize(word) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #verb ⇒ Object
- #verb_category ⇒ Object
Constructor Details
#initialize(word) ⇒ Analyzer
Returns a new instance of Analyzer.
8 9 10 |
# File 'lib/katsuyoujin/analyzer.rb', line 8 def initialize(word) @word = word end |
Instance Attribute Details
#word ⇒ Object (readonly)
Returns the value of attribute word.
6 7 8 |
# File 'lib/katsuyoujin/analyzer.rb', line 6 def word @word end |
Instance Method Details
#base_form ⇒ Object
18 19 20 |
# File 'lib/katsuyoujin/analyzer.rb', line 18 def base_form verb['base_form'].to_s end |
#base_form_hiragana ⇒ Object
22 23 24 |
# File 'lib/katsuyoujin/analyzer.rb', line 22 def base_form_hiragana verb['reading'].to_s.hiragana end |
#verb ⇒ Object
12 13 14 15 16 |
# File 'lib/katsuyoujin/analyzer.rb', line 12 def verb analysis.detect do |part| part['parts_of_speech'].split(/\s*,\s*/).include? '動詞' end || {} end |
#verb_category ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/katsuyoujin/analyzer.rb', line 26 def verb_category fail ArgumentError('not a verb') unless base_form case when irregular_godan? then 'godan' when suru? then 'suru' when kuru? then 'kuru' when ichidan? then 'ichidan' else 'godan' end end |