Class: LLT::Morphologizer::StemLookupStatementBuilder
- Inherits:
-
Object
- Object
- LLT::Morphologizer::StemLookupStatementBuilder
show all
- Includes:
- Conjugable, Declinable
- Defined in:
- lib/llt/morphologizer/stem_lookup_statement_builder.rb
Defined Under Namespace
Modules: Conjugable, ContractedForms, Declinable
Constant Summary
collapse
- GETTER_METHODS =
{ components: %w{ thematic extension comparison_sign ending contraction },
lookup: %w{ table column itype } }
Constants included
from Conjugable
Conjugable::DEP_IMP_ENDING, Conjugable::FUTURE_B, Conjugable::FUTURE_OR_SUBJUNCTIVE_A_OR_E, Conjugable::IMPERATIVE_ENDING, Conjugable::IMPERFECT_BA, Conjugable::INFINITIVE_PF, Conjugable::INFINITIVE_PR, Conjugable::PERFECT_EXTENSIONS, Conjugable::PRIMARY_ENDING, Conjugable::PRIMARY_ENDING_SG_2_PASSIVE, Conjugable::SECONDARY_ENDING, Conjugable::SUBJUNCTIVE_IMPERFECT, Conjugable::THEMATIC_E_OF_SUBJUNCTIVE_IMPERFECT, Conjugable::THEMATIC_I_OF_M, Conjugable::THEMATIC_VOWEL
ContractedForms::CONTRACTED_FORMS
Constants included
from Declinable
Declinable::A_ENDING, Declinable::COMPARISON, Declinable::DECL_COMPONENTS, Declinable::FUTURE_PARTICIPLE, Declinable::IUS_ENDING, Declinable::NOMINATIVE_ENDING, Declinable::OTHER_CASE_ENDING, Declinable::PPA_OR_GERUND, Declinable::PRONOMINAL_ENDING, Declinable::THEMATIC_I_OF_M, Declinable::THEMATIC_VOWEL, Declinable::UM_ENDING
Instance Method Summary
collapse
Methods included from Conjugable
#conjugable_search, #create_conjugables, pl_1_active, pl_1_passive, pl_2_active, pl_2_passive, pl_3_active, pl_3_passive, sg_1_active, sg_1_passive, sg_2_active, sg_2_passive, sg_3_active, sg_3_passive
#search_for_contracted_form
Methods included from Declinable
#create_declinables
Constructor Details
Returns a new instance of StemLookupStatementBuilder.
13
14
15
16
17
18
19
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 13
def initialize(word, log)
@word = word.clone
@log = log
@components = Hash.new { |h, k| h[k] = "" }
@lookup = {}
end
|
Instance Method Details
#add_additional_persona_place_or_ethnic_statement! ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 117
def add_additional_persona_place_or_ethnic_statement!
if stem.match(/^[A-Z].*/)
case table
when :noun
@lookup[:table] = :persona and add_statement!
@lookup[:table] = :place and add_statement!
when :adjective
@lookup[:table] = :ethnic and add_statement! if column == :stem
end
end
end
|
#add_statement! ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 91
def add_statement!
if itype.empty?
@log.warning("#{stem} with #{@components[:ending]} has no searchable infl classes.")
else
st = LookupStatement.new(cloned_stem, table, column, itype.clone, unemptied_components)
@statements << st
end
end
|
#all ⇒ Object
59
60
61
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 59
def all
@all_memo ||= i{ thematic extension comparison_sign ending }
end
|
#cloned_stem ⇒ Object
107
108
109
110
111
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 107
def cloned_stem
s = stem.clone
s.downcase! unless persona_place_or_ethnic?
s
end
|
#has(arr) ⇒ Object
63
64
65
66
67
68
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 63
def has(arr)
type, components = arr
if result = scan(components, type)
slice_and_stash(type, result)
end
end
|
#look_for(the_table = :same, the_column = :same) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 79
def look_for the_table = :same, the_column = :same
unless the_table == :same
@lookup[:table] = the_table
@lookup[:column] = the_column
end
send("valid_itypes_for_#{@operator}")
add_statement!
add_additional_persona_place_or_ethnic_statement!
itype.clear
end
|
#persona_place_or_ethnic? ⇒ Boolean
113
114
115
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 113
def persona_place_or_ethnic?
table == :persona || table == :place || table == :ethnic
end
|
#reset(*args) ⇒ Object
53
54
55
56
57
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 53
def reset(*args)
args.flatten.each do |comp|
@word << @components.delete(comp).to_s
end
end
|
#scan(components, type) ⇒ Object
70
71
72
73
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 70
def scan(components, type)
components.flat_map {|x| @word.scan(x) }.first
end
|
#setup(operator) ⇒ Object
47
48
49
50
51
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 47
def setup(operator)
@components.clear
@lookup = { table: "", column: "", itype: [] }
@operator = operator
end
|
#slice_and_stash(type, result) ⇒ Object
75
76
77
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 75
def slice_and_stash(type, result)
@components[type].prepend(@word.slice!(/#{result}$/))
end
|
#statements ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 39
def statements
@statements = []
create_declinables
create_conjugables
@statements
end
|
#stem ⇒ Object
21
22
23
24
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 21
def stem
@word
end
|
#unemptied_components ⇒ Object
101
102
103
104
|
# File 'lib/llt/morphologizer/stem_lookup_statement_builder.rb', line 101
def unemptied_components
@components.reject { |k, v| v.empty? unless k == :ending }
end
|