Class: Kotoshu::Algorithms::Lookup::CompoundForm
- Inherits:
-
Object
- Object
- Kotoshu::Algorithms::Lookup::CompoundForm
- Defined in:
- lib/kotoshu/algorithms/lookup/compound_form.rb
Overview
CompoundForm is a hypothesis of how some word could be split into several AffixForms (word parts with their own stems and possible affixes).
Typically, only first part is allowed to have prefix, and only last part is allowed to have suffix, but there are languages where middle parts can have affixes too, specified by special flags.
Instance Attribute Summary collapse
-
#junction_patterns ⇒ Array<Readers::CompoundPattern, nil>
readonly
Junctions sit between parts, so a compound of N parts has N-1 of them.
-
#parts ⇒ Array<AffixForm>
readonly
Parts of the compound word.
Instance Method Summary collapse
-
#initialize(parts, junction_patterns = []) ⇒ CompoundForm
constructor
A new instance of CompoundForm.
-
#junction_pattern(index) ⇒ Readers::CompoundPattern?
The pattern whose replacement rebuilt the junction after part
index, if any. -
#to_s ⇒ String
(also: #inspect)
String representation.
Constructor Details
#initialize(parts, junction_patterns = []) ⇒ CompoundForm
Returns a new instance of CompoundForm.
25 26 27 28 |
# File 'lib/kotoshu/algorithms/lookup/compound_form.rb', line 25 def initialize(parts, junction_patterns = []) @parts = parts @junction_patterns = junction_patterns end |
Instance Attribute Details
#junction_patterns ⇒ Array<Readers::CompoundPattern, nil> (readonly)
Junctions sit between parts, so a compound of N parts has N-1 of them. The list is built front-to-back exactly like parts and holds the CHECKCOMPOUNDPATTERN whose replacement rebuilt each junction, or nil where the parts simply met. A shorter list means the trailing junctions are ordinary.
23 24 25 |
# File 'lib/kotoshu/algorithms/lookup/compound_form.rb', line 23 def junction_patterns @junction_patterns end |
#parts ⇒ Array<AffixForm> (readonly)
Returns Parts of the compound word.
14 15 16 |
# File 'lib/kotoshu/algorithms/lookup/compound_form.rb', line 14 def parts @parts end |
Instance Method Details
#junction_pattern(index) ⇒ Readers::CompoundPattern?
The pattern whose replacement rebuilt the junction after part
index, if any.
35 36 37 |
# File 'lib/kotoshu/algorithms/lookup/compound_form.rb', line 35 def junction_pattern(index) @junction_patterns[index] end |
#to_s ⇒ String Also known as: inspect
String representation.
42 43 44 |
# File 'lib/kotoshu/algorithms/lookup/compound_form.rb', line 42 def to_s "CompoundForm(#{@parts.map(&:to_s).join(' + ')})" end |