Class: Daidai::Deinflection
- Inherits:
-
Struct
- Object
- Struct
- Daidai::Deinflection
- Defined in:
- lib/daidai/deinflector.rb
Overview
A single deinflection candidate: a base-form ‘term` reached from the input by applying `inflections` (transform names, ordered from the surface form inward to the dictionary form). `dictionary_form?` is true when the rule chain lands on a recognised dictionary form (a likely real lemma), useful for callers without their own dictionary to look the term up in.
Daidai.deinflect("食べてる") # candidate base forms, each with named inflections;
# one is #<Daidai::Deinflection 食べる [-いる, -て]>
Instance Attribute Summary collapse
-
#dictionary_form ⇒ Object
Returns the value of attribute dictionary_form.
-
#inflections ⇒ Object
Returns the value of attribute inflections.
-
#term ⇒ Object
Returns the value of attribute term.
Instance Method Summary collapse
- #dictionary_form? ⇒ Boolean
- #inspect ⇒ Object
-
#labels ⇒ Object
The inflections as friendly English labels for display (e.g. “-いる” => “progressive”, “-て” => “te-form”), via Deinflector.label.
- #to_s ⇒ Object
Instance Attribute Details
#dictionary_form ⇒ Object
Returns the value of attribute dictionary_form
14 15 16 |
# File 'lib/daidai/deinflector.rb', line 14 def dictionary_form @dictionary_form end |
#inflections ⇒ Object
Returns the value of attribute inflections
14 15 16 |
# File 'lib/daidai/deinflector.rb', line 14 def inflections @inflections end |
#term ⇒ Object
Returns the value of attribute term
14 15 16 |
# File 'lib/daidai/deinflector.rb', line 14 def term @term end |
Instance Method Details
#dictionary_form? ⇒ Boolean
15 |
# File 'lib/daidai/deinflector.rb', line 15 def dictionary_form? = dictionary_form |
#inspect ⇒ Object
24 |
# File 'lib/daidai/deinflector.rb', line 24 def inspect = "#<Daidai::Deinflection #{self}>" |
#labels ⇒ Object
The inflections as friendly English labels for display (e.g. “-いる” => “progressive”, “-て” => “te-form”), via Deinflector.label. Localise these downstream (i18n) if your app is multilingual.
20 |
# File 'lib/daidai/deinflector.rb', line 20 def labels = inflections.map { |name| Deinflector.label(name) } |
#to_s ⇒ Object
22 |
# File 'lib/daidai/deinflector.rb', line 22 def to_s = inflections.empty? ? term : "#{term} [#{inflections.join(", ")}]" |