Class: Daidai::Deinflection

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#dictionary_formObject

Returns the value of attribute dictionary_form

Returns:

  • (Object)

    the current value of dictionary_form



14
15
16
# File 'lib/daidai/deinflector.rb', line 14

def dictionary_form
  @dictionary_form
end

#inflectionsObject

Returns the value of attribute inflections

Returns:

  • (Object)

    the current value of inflections



14
15
16
# File 'lib/daidai/deinflector.rb', line 14

def inflections
  @inflections
end

#termObject

Returns the value of attribute term

Returns:

  • (Object)

    the current value of term



14
15
16
# File 'lib/daidai/deinflector.rb', line 14

def term
  @term
end

Instance Method Details

#dictionary_form?Boolean

Returns:

  • (Boolean)


15
# File 'lib/daidai/deinflector.rb', line 15

def dictionary_form? = dictionary_form

#inspectObject



24
# File 'lib/daidai/deinflector.rb', line 24

def inspect = "#<Daidai::Deinflection #{self}>"

#labelsObject

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_sObject



22
# File 'lib/daidai/deinflector.rb', line 22

def to_s = inflections.empty? ? term : "#{term} [#{inflections.join(", ")}]"