llt-form_builder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +8 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +29 -0
  8. data/Rakefile +8 -0
  9. data/lib/llt/form/adjective.rb +19 -0
  10. data/lib/llt/form/adverb.rb +13 -0
  11. data/lib/llt/form/cardinal.rb +31 -0
  12. data/lib/llt/form/conjunction.rb +7 -0
  13. data/lib/llt/form/declinable.rb +23 -0
  14. data/lib/llt/form/demonstrative_pronoun.rb +7 -0
  15. data/lib/llt/form/ethnic.rb +6 -0
  16. data/lib/llt/form/fp.rb +6 -0
  17. data/lib/llt/form/gerund.rb +9 -0
  18. data/lib/llt/form/gerundive.rb +12 -0
  19. data/lib/llt/form/indefinite_pronoun.rb +7 -0
  20. data/lib/llt/form/infinitive.rb +13 -0
  21. data/lib/llt/form/interrogative_pronoun.rb +7 -0
  22. data/lib/llt/form/noun.rb +17 -0
  23. data/lib/llt/form/participle.rb +9 -0
  24. data/lib/llt/form/personal_pronoun.rb +13 -0
  25. data/lib/llt/form/ppa.rb +6 -0
  26. data/lib/llt/form/ppp.rb +6 -0
  27. data/lib/llt/form/preposition.rb +32 -0
  28. data/lib/llt/form/pronoun.rb +17 -0
  29. data/lib/llt/form/relative_pronoun.rb +7 -0
  30. data/lib/llt/form/subjunction.rb +7 -0
  31. data/lib/llt/form/supinum.rb +6 -0
  32. data/lib/llt/form/uninflectable.rb +22 -0
  33. data/lib/llt/form/verb.rb +28 -0
  34. data/lib/llt/form/verbal_noun.rb +18 -0
  35. data/lib/llt/form.rb +80 -0
  36. data/lib/llt/form_builder/adjective_builder.rb +86 -0
  37. data/lib/llt/form_builder/adverb_builder.rb +25 -0
  38. data/lib/llt/form_builder/declinable_builder.rb +164 -0
  39. data/lib/llt/form_builder/ethnic_builder.rb +17 -0
  40. data/lib/llt/form_builder/fp_builder.rb +13 -0
  41. data/lib/llt/form_builder/gerund_builder.rb +37 -0
  42. data/lib/llt/form_builder/gerundive_builder.rb +24 -0
  43. data/lib/llt/form_builder/helpers/adjective_like_building.rb +29 -0
  44. data/lib/llt/form_builder/helpers/pronoun_segments.rb +226 -0
  45. data/lib/llt/form_builder/helpers/stem_hash_parser.rb +263 -0
  46. data/lib/llt/form_builder/helpers/verb_segments.rb +562 -0
  47. data/lib/llt/form_builder/infinitivum_builder.rb +19 -0
  48. data/lib/llt/form_builder/irregular_gerund_builder.rb +7 -0
  49. data/lib/llt/form_builder/irregular_gerundive_builder.rb +7 -0
  50. data/lib/llt/form_builder/irregular_ppa_builder.rb +7 -0
  51. data/lib/llt/form_builder/irregular_praesens_builder.rb +5 -0
  52. data/lib/llt/form_builder/irregular_praesens_infinitivum_builder.rb +5 -0
  53. data/lib/llt/form_builder/noun_builder.rb +24 -0
  54. data/lib/llt/form_builder/perfectum_builder.rb +14 -0
  55. data/lib/llt/form_builder/perfectum_infinitivum_builder.rb +7 -0
  56. data/lib/llt/form_builder/personal_pronoun_builder.rb +107 -0
  57. data/lib/llt/form_builder/ppa_builder.rb +20 -0
  58. data/lib/llt/form_builder/ppp_builder.rb +10 -0
  59. data/lib/llt/form_builder/praesens_builder.rb +41 -0
  60. data/lib/llt/form_builder/praesens_infinitivum_builder.rb +9 -0
  61. data/lib/llt/form_builder/pronoun_builder.rb +106 -0
  62. data/lib/llt/form_builder/supinum_builder.rb +23 -0
  63. data/lib/llt/form_builder/verb_builder.rb +37 -0
  64. data/lib/llt/form_builder/version.rb +5 -0
  65. data/lib/llt/form_builder.rb +370 -0
  66. data/lib/llt/stem/adjective_pack.rb +122 -0
  67. data/lib/llt/stem/adjective_stem.rb +23 -0
  68. data/lib/llt/stem/ethnic_stem.rb +9 -0
  69. data/lib/llt/stem/noun_pack.rb +14 -0
  70. data/lib/llt/stem/noun_stem.rb +26 -0
  71. data/lib/llt/stem/pack.rb +46 -0
  72. data/lib/llt/stem/verb_pack.rb +53 -0
  73. data/lib/llt/stem/verb_stem.rb +18 -0
  74. data/lib/llt/stem.rb +145 -0
  75. data/lib/llt/stem_builder.rb +53 -0
  76. data/llt-form_builder.gemspec +30 -0
  77. data/spec/lib/llt/form/adjective_spec.rb +10 -0
  78. data/spec/lib/llt/form/adverb_spec.rb +17 -0
  79. data/spec/lib/llt/form/conjunction_spec.rb +23 -0
  80. data/spec/lib/llt/form/demonstrative_pronoun_spec.rb +14 -0
  81. data/spec/lib/llt/form/fp_spec.rb +12 -0
  82. data/spec/lib/llt/form/functions_spec.rb +13 -0
  83. data/spec/lib/llt/form/gerund_spec.rb +10 -0
  84. data/spec/lib/llt/form/gerundive_spec.rb +13 -0
  85. data/spec/lib/llt/form/noun_spec.rb +18 -0
  86. data/spec/lib/llt/form/ppa_spec.rb +12 -0
  87. data/spec/lib/llt/form/ppp_spec.rb +12 -0
  88. data/spec/lib/llt/form/preposition_spec.rb +43 -0
  89. data/spec/lib/llt/form/supinum_spec.rb +9 -0
  90. data/spec/lib/llt/form/verb_spec.rb +14 -0
  91. data/spec/lib/llt/form_builder/adjective_builder_spec.rb +182 -0
  92. data/spec/lib/llt/form_builder/adverb_builder_spec.rb +27 -0
  93. data/spec/lib/llt/form_builder/ethnic_builder_spec.rb +17 -0
  94. data/spec/lib/llt/form_builder/form_builder_spec.rb +16 -0
  95. data/spec/lib/llt/form_builder/fp_builder_spec.rb +42 -0
  96. data/spec/lib/llt/form_builder/gerund_builder_spec.rb +80 -0
  97. data/spec/lib/llt/form_builder/gerundive_builder_spec.rb +102 -0
  98. data/spec/lib/llt/form_builder/helpers/stem_hash_parser_spec.rb +197 -0
  99. data/spec/lib/llt/form_builder/irregular_gerund_builder_spec.rb +22 -0
  100. data/spec/lib/llt/form_builder/irregular_gerundive_builder_spec.rb +21 -0
  101. data/spec/lib/llt/form_builder/irregular_praesens_builder_spec.rb +14 -0
  102. data/spec/lib/llt/form_builder/irregular_praesens_infinitivum_builder_spec.rb +32 -0
  103. data/spec/lib/llt/form_builder/noun_builder_spec.rb +245 -0
  104. data/spec/lib/llt/form_builder/personal_pronoun_builder_spec.rb +49 -0
  105. data/spec/lib/llt/form_builder/ppa_builder_spec.rb +137 -0
  106. data/spec/lib/llt/form_builder/ppp_builder_spec.rb +45 -0
  107. data/spec/lib/llt/form_builder/pronoun_builder_spec.rb +203 -0
  108. data/spec/lib/llt/form_builder/supinum_builder_spec.rb +24 -0
  109. data/spec/lib/llt/form_builder/verb_builder_spec.rb +557 -0
  110. data/spec/lib/llt/form_spec.rb +27 -0
  111. data/spec/lib/llt/stem/adjective_pack_spec.rb +78 -0
  112. data/spec/lib/llt/stem/adjective_stem_spec.rb +15 -0
  113. data/spec/lib/llt/stem/noun_pack_spec.rb +20 -0
  114. data/spec/lib/llt/stem/noun_stem_spec.rb +14 -0
  115. data/spec/lib/llt/stem/verb_pack_spec.rb +56 -0
  116. data/spec/lib/llt/stem_builder_spec.rb +20 -0
  117. data/spec/spec_helper.rb +21 -0
  118. metadata +330 -0
@@ -0,0 +1,245 @@
1
+ require 'spec_helper'
2
+ describe LLT::FormBuilder do
3
+ include LLT::Helpers::Normalizer
4
+
5
+ describe ".build" do
6
+ def form_builder_strings(args)
7
+ forms = LLT::FormBuilder.build(*args)
8
+ forms.map(&:to_s)
9
+ end
10
+
11
+ def with_noun_options(options)
12
+ args = [{type: :noun, stem: "ros", inflection_class: 1, sexus: :f, options: options }]
13
+ LLT::FormBuilder.build(*args)
14
+ end
15
+
16
+ context "with nouns" do
17
+ context "without options" do
18
+ it "builds all forms of A - nominative need not be given" do
19
+ args = [{type: :noun, stem: "ros", inflection_class: 1, sexus: :f}]
20
+ form_builder_strings(args).should == %w(rosa rosae rosae rosam rosa rosa rosae rosarum rosis rosas rosae rosis)
21
+ end
22
+
23
+ it "builds all forms of A - even if nominative is given" do
24
+ args = [{type: :noun, nominative: "rosa", stem: "ros", inflection_class: 1, sexus: :f}]
25
+ form_builder_strings(args).should == %w(rosa rosae rosae rosam rosa rosa rosae rosarum rosis rosas rosae rosis)
26
+ end
27
+
28
+ context "O - m " do
29
+ it "builds all forms when no nominative is given" do
30
+ args = [{type: :noun, stem: "amic", inflection_class: 2, sexus: :m}]
31
+ form_builder_strings(args).should == %w(amicus amici amico amicum amice amico amici amicorum amicis amicos amici amicis)
32
+ end
33
+
34
+ it "builds all forms - handles vocative properly when nominative is given" do
35
+ args = [{type: :noun, nominative: "amicus", stem: "amic", inflection_class: 2, sexus: :m}]
36
+ form_builder_strings(args).should == %w(amicus amici amico amicum amice amico amici amicorum amicis amicos amici amicis)
37
+ end
38
+
39
+ it "builds all forms - handles vocative for ius forms properly when nominative is given" do
40
+ args = [{type: :noun, nominative: "filius", stem: "fili", inflection_class: 2, sexus: :m}]
41
+ form_builder_strings(args).should == %w(filius filii filio filium fili filio filii filiorum filiis filios filii filiis)
42
+ end
43
+
44
+ it "builds all forms - handles vocative for ius forms properly when no nominative is given" do
45
+ args = [{type: :noun, stem: "fili", inflection_class: 2, sexus: :m}]
46
+ form_builder_strings(args).should == %w(filius filii filio filium fili filio filii filiorum filiis filios filii filiis)
47
+ end
48
+
49
+ it "segmentizes fili vocative correctly" do
50
+ args = [{type: :noun, stem: "fili", inflection_class: 2, sexus: :m}]
51
+ forms = LLT::FormBuilder.build(*args)
52
+ forms[4].to_s(:segmentized).should == "fili"
53
+ end
54
+
55
+ it "builds all forms with er ending - needs nominative given" do
56
+ args = [{type: :noun, stem: "puer", inflection_class: 2, sexus: :m, nominative: "puer"}]
57
+ form_builder_strings(args)[0].should == "puer"
58
+ form_builder_strings(args)[4].should == "puer"
59
+ end
60
+
61
+ it "builds all forms with er ending - needs nominative given" do
62
+ args = [{type: :noun, nominative: "magister", stem: "magistr", inflection_class: 2, sexus: :m}]
63
+ form_builder_strings(args)[0].should == "magister"
64
+ form_builder_strings(args)[4].should == "magister"
65
+ end
66
+
67
+ it "builds all forms without an ending - needs nominative given (vir)" do
68
+ args = [{type: :noun, nominative: "vir", stem: "vir", inflection_class: 2, sexus: :m}]
69
+ strings = form_builder_strings(args)
70
+ strings.should have(12).items
71
+ vir = strings.first
72
+ vir.should == "vir"
73
+ end
74
+ end
75
+
76
+ it "builds all forms of O - n" do
77
+ args = [{type: :noun, stem: "templ", inflection_class: 2, sexus: :n}]
78
+ form_builder_strings(args).should == %w(templum templi templo templum templum templo templa templorum templis templa templa templis)
79
+ end
80
+
81
+ it "builds all forms of C - m" do
82
+ args = [{type: :noun, nominative: "homo", stem: "homin", inflection_class: 3, sexus: :m}]
83
+ form_builder_strings(args).should == %w(homo hominis homini hominem homo homine homines hominum hominibus homines homines hominibus)
84
+ end
85
+
86
+ it "builds all forms of C - n" do
87
+ args = [{type: :noun, nominative: "flumen", stem: "flumin", inflection_class: 3, sexus: :n}]
88
+ form_builder_strings(args).should == %w(flumen fluminis flumini flumen flumen flumine flumina fluminum fluminibus flumina flumina fluminibus)
89
+ end
90
+
91
+ it "builds all forms of wildly irregular words like bos" do
92
+ irregular = [["bos", 1, 1], ["boum", 2, 2], ["bubus", 3, 2], ["bubus", 6, 2]]
93
+ additional = [["bobus", 3, 2], ["bobus", 6, 2]]
94
+ args = [{type: :noun, stem: "bov", inflection_class: 3, sexus: :m, irregular_forms: irregular, additional_forms: additional}]
95
+ form_builder_strings(args).should == %w(bos bovis bovi bovem bos bove boves boum bubus boves boves bubus bobus bobus)
96
+ end
97
+
98
+ it "builds objects with stem and ending separated" do
99
+ args = [{type: :noun, stem: "ros", inflection_class: 1, sexus: :f}]
100
+ forms = LLT::FormBuilder.build(*args)
101
+ # forms.first = all forms of the one stem it was initialized with
102
+ rosa = forms.first
103
+ rosa.stem.should == "ros"
104
+ rosa.ending.should == "a"
105
+ rosa.sexus.should == :f
106
+ end
107
+
108
+ it "builds objects with stem and ending separated even for irregular forms like bubus" do
109
+ irregular = [["bos", 1, 1], ["boum", 2, 2], ["bubus", 3, 2], ["bubus", 6, 2]]
110
+ additional = [["bobus", 3, 2], ["bobus", 6, 2]]
111
+ args = [{type: :noun, stem: "bov", inflection_class: 3, sexus: :m, irregular_forms: irregular, additional_forms: additional}]
112
+ forms = LLT::FormBuilder.build(*args)
113
+ # forms.first = all forms of the one stem it was initialized with
114
+ bubus = forms[11] # ablative plural
115
+ bubus.stem.should == "bu"
116
+ bubus.ending.should == "bus"
117
+ bubus.sexus.should == :m
118
+ end
119
+ end
120
+
121
+
122
+ context "with options that select a specfic form given in a stem" do
123
+ it "returns only forms specified in options" do
124
+ with_noun_options(numerus: 2).should have(6).items
125
+ with_noun_options(casus: 2).should have(2).items
126
+ with_noun_options(numerus: 1, casus: 2).should have(1).item
127
+ end
128
+
129
+ it "works with irregulars as well" do
130
+ irregular = [["bos", 1, 1], ["boum", 2, 2], ["bubus", 3, 2], ["bubus", 6, 2]]
131
+ additional = [["bobus", 3, 2], ["bobus", 6, 2]]
132
+ options = { numerus: 1 }
133
+ args = [{type: :noun, stem: "bov", inflection_class: 3, sexus: :m,
134
+ irregular_forms: irregular, additional_forms: additional, options: options}]
135
+ forms = LLT::FormBuilder.build(*args)
136
+ forms.should have(6).items
137
+ end
138
+
139
+ context "with special nominatives" do
140
+ it "homo" do
141
+ options = { numerus: 1, casus: 1 }
142
+ args = [{type: :noun, nominative: "hŏmō", stem: "hŏmĭn", inflection_class: 3, sexus: :m, options: options}]
143
+ forms = LLT::FormBuilder.build(*args)
144
+ forms.should have(1).item
145
+ end
146
+
147
+ it "magister" do
148
+ options = { numerus: 1, casus: 1 }
149
+ args = [{type: :noun, nominative: "magister", stem: "magistr", inflection_class: 1, sexus: :m, options: options}]
150
+ forms = LLT::FormBuilder.build(*args)
151
+ forms.should have(1).item
152
+ end
153
+
154
+ it "vir" do
155
+ options = { numerus: 1, casus: 1 }
156
+ args = [{type: :noun, nominative: "vir", stem: "vir", inflection_class: 2, sexus: :m, options: options}]
157
+ forms = LLT::FormBuilder.build(*args)
158
+ forms.should have(1).item
159
+ end
160
+ end
161
+
162
+ context "with special vocatives" do
163
+ it "fili" do
164
+ options = { casus: 5, numerus: 1}
165
+ args = { type: :noun, nom: "filius", stem: "fili", itype: 2, sexus: :m, options: options }
166
+ forms = LLT::FormBuilder.build(args)
167
+ forms.should have(1).item
168
+ forms.first.to_s(:segmentized).should == "fili"
169
+ end
170
+ end
171
+ end
172
+
173
+ context "with a metrical stem" do
174
+ it "builds all forms as metrical utf8 strings" do
175
+ args = [{type: :noun, nominative: "hŏmō", stem: "hŏmĭn", inflection_class: 3, sexus: :m}]
176
+ form_builder_strings(args).should == %w(hŏmō hŏmĭnĭs hŏmĭnī hŏmĭnĕm hŏmō hŏmĭnĕ hŏmĭnēs hŏmĭnŭm hŏmĭnĭbŭs hŏmĭnēs hŏmĭnēs hŏmĭnĭbŭs)
177
+ end
178
+ end
179
+
180
+ it "initializes Word objects with inflection class" do
181
+ args = [{type: :noun, stem: "ros", inflection_class: 1, sexus: :f}]
182
+ forms = LLT::FormBuilder.build(*args)
183
+ # forms.first = all forms of the one stem it was initialized with
184
+ rosa = forms.first
185
+ rosa.inflection_class.should == 1
186
+ end
187
+
188
+ it "makes use of LLT::Helpers::Normalizer" do
189
+ args = [{type: :noun, stem: "ros", itype: 1, "gender" => :f}]
190
+ forms = LLT::FormBuilder.build(*args)
191
+ forms.map(&:to_s).should == %w(rosa rosae rosae rosam rosa rosa rosae rosarum rosis rosas rosae rosis)
192
+ rosa = forms.first
193
+ rosa.sexus.should == :f
194
+ end
195
+
196
+ context "with options that indicate the word's components" do
197
+ it "builds correct forms only (one possibility)" do
198
+ res = with_noun_options(ending: "am")
199
+ res.should have(1).item
200
+ res.first.casus.should == 4
201
+ res.first.numerus.should == 1
202
+ end
203
+
204
+ it "builds correct forms only (several possibilities)" do
205
+ res = with_noun_options(ending: "a")
206
+ res.should have(3).item
207
+
208
+ rosa_nom = res.first
209
+ rosa_abl = res[2]
210
+
211
+ rosa_nom.casus.should == 1
212
+ rosa_abl.casus.should == 6
213
+ end
214
+
215
+ it "doesn't build incorrect forms" do
216
+ res = with_noun_options(ending: "um")
217
+ res.should be_empty
218
+ end
219
+
220
+ context "with special nominatives, where ending is an empty string" do
221
+ it "homo" do
222
+ options = { ending: "" }
223
+ args = [{type: :noun, nominative: "hŏmō", stem: "hŏmĭn", inflection_class: 3, sexus: :m, options: options}]
224
+ forms = LLT::FormBuilder.build(*args)
225
+ forms.should have(2).items
226
+ end
227
+
228
+ it "magister" do
229
+ options = { ending: "" }
230
+ args = [{type: :noun, nominative: "magister", stem: "magistr", inflection_class: 2, sexus: :m, options: options}]
231
+ forms = LLT::FormBuilder.build(*args)
232
+ forms.should have(2).items
233
+ end
234
+
235
+ it "vir" do
236
+ options = { ending: "" }
237
+ args = [{type: :noun, nominative: "vir", stem: "vir", inflection_class: 2, sexus: :m, options: options}]
238
+ forms = LLT::FormBuilder.build(*args)
239
+ forms.should have(2).item
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with personal pronouns" do
6
+ context "builds all forms" do
7
+ it "of ego" do
8
+ arg = { type: :personal_pronoun, inflection_class: :ego }
9
+ forms = LLT::FormBuilder.build(arg)
10
+ forms.should have(11).items
11
+ forms.map(&:to_s).should =~ %w{ ego mei mihi me me mecum egomet memet mihimet meimet memet}
12
+ forms.map(&:numerus).all? { |n| n == 1}.should be_true
13
+ end
14
+
15
+ it "of tu" do
16
+ arg = { type: :personal_pronoun, inflection_class: :tu }
17
+ forms = LLT::FormBuilder.build(arg)
18
+ forms.should have(10).items
19
+ forms.map(&:to_s).should =~ %w{ tu tui tibi te te tecum tute tete tete tibimet }
20
+ forms.map(&:numerus).all? { |n| n == 1}.should be_true
21
+ end
22
+
23
+ it "of nos" do
24
+ arg = { type: :personal_pronoun, inflection_class: :nos }
25
+ forms = LLT::FormBuilder.build(arg)
26
+ forms.map(&:to_s).should =~ %w{ nos nostri nostrum nobis nos nobis nobiscum nosmet nosmet nobismet nobismet }
27
+ forms.map(&:numerus).all? { |n| n == 2}.should be_true
28
+ end
29
+
30
+ it "of vos" do
31
+ arg = { type: :personal_pronoun, inflection_class: :vos }
32
+ forms = LLT::FormBuilder.build(arg)
33
+ forms.should have(11).items
34
+ forms.map(&:to_s).should =~ %w{ vos vestri vostrum vobis vos vobis vobiscum vosmet vosmet vobismet vobismet }
35
+ forms.map(&:numerus).all? { |n| n == 2}.should be_true
36
+ end
37
+
38
+ it "of se - sg. & pl." do
39
+ arg = { type: :personal_pronoun, inflection_class: :se }
40
+ forms = LLT::FormBuilder.build(arg)
41
+ forms.should have(14).items
42
+ forms.map(&:to_s).should =~ %w{ sui sibi se sese se secum sese } * 2
43
+ forms[0..6] .map(&:numerus).all? { |n| n == 1}.should be_true
44
+ forms[7..14].map(&:numerus).all? { |n| n == 2}.should be_true
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,137 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ include LLT::Helpers::Normalizer
5
+
6
+ describe ".build" do
7
+ def form_builder_strings(args)
8
+ forms = LLT::FormBuilder.build(*args)
9
+ forms.map(&:to_s)
10
+ end
11
+
12
+ def with_ppa(options)
13
+ args = [{type: :ppa, stem: "ama", inflection_class: 1, options: options}]
14
+ LLT::FormBuilder.build(*args)
15
+ end
16
+
17
+ context "with ppas" do
18
+ context "build all forms" do
19
+ it "a conj" do
20
+ args = [{type: :ppa, stem: "ama", inflection_class: 1, tense: :pr}]
21
+ form_builder_strings(args).should == %w{ amans amantis amanti amantem amans amante amantes amantium amantibus amantes amantes amantibus
22
+ amans amantis amanti amantem amans amante amantes amantium amantibus amantes amantes amantibus
23
+ amans amantis amanti amans amans amante amantia amantium amantibus amantia amantia amantibus }
24
+ end
25
+
26
+ it "e conj" do
27
+ args = [{type: :ppa, stem: "mone", inflection_class: 2, tense: :pr}]
28
+ form_builder_strings(args).should == %w{ monens monentis monenti monentem monens monente monentes monentium monentibus monentes monentes monentibus
29
+ monens monentis monenti monentem monens monente monentes monentium monentibus monentes monentes monentibus
30
+ monens monentis monenti monens monens monente monentia monentium monentibus monentia monentia monentibus }
31
+ end
32
+
33
+ it "c conj" do
34
+ args = [{type: :ppa, stem: "leg", inflection_class: 3, tense: :pr}]
35
+ form_builder_strings(args).should == %w{ legens legentis legenti legentem legens legente legentes legentium legentibus legentes legentes legentibus
36
+ legens legentis legenti legentem legens legente legentes legentium legentibus legentes legentes legentibus
37
+ legens legentis legenti legens legens legente legentia legentium legentibus legentia legentia legentibus }
38
+ end
39
+
40
+ it "i conj" do
41
+ args = [{type: :ppa, stem: "audi", inflection_class: 4, tense: :pr}]
42
+ form_builder_strings(args).should == %w{ audiens audientis audienti audientem audiens audiente audientes audientium audientibus audientes audientes audientibus
43
+ audiens audientis audienti audientem audiens audiente audientes audientium audientibus audientes audientes audientibus
44
+ audiens audientis audienti audiens audiens audiente audientia audientium audientibus audientia audientia audientibus }
45
+ end
46
+
47
+ it "m conj" do
48
+ args = [{type: :ppa, stem: "cap", inflection_class: 5, tense: :pr}]
49
+ form_builder_strings(args).should == %w{ capiens capientis capienti capientem capiens capiente capientes capientium capientibus capientes capientes capientibus
50
+ capiens capientis capienti capientem capiens capiente capientes capientium capientibus capientes capientes capientibus
51
+ capiens capientis capienti capiens capiens capiente capientia capientium capientibus capientia capientia capientibus }
52
+ end
53
+ end
54
+
55
+ context "with options that select a specfic form given in a stem" do
56
+ end
57
+
58
+ context "with options that indicate the word's components" do
59
+ context "builds correct forms only" do
60
+
61
+ it "amantis" do
62
+ res = with_ppa(ending: "is", ppa_fp_or_gerund: "nt")
63
+ res.should have(3).items
64
+ amantis1, amantis2, amantis3 = res
65
+ amantis1.sexus.should == :m
66
+ amantis2.sexus.should == :f
67
+ amantis3.sexus.should == :n
68
+
69
+ amantis1.modus.should == t.participium
70
+ amantis1.tempus.should == t.praesens
71
+
72
+ amantis1.stem.should == "ama"
73
+ amantis1.ending.should == "is"
74
+ amantis1.to_s.should == "amantis"
75
+ amantis1.to_s(:segmentized).should == "ama-nt-is"
76
+ end
77
+
78
+ context "with validate flag" do
79
+ it "ama-nt-is" do
80
+ options = { ending: "is", extension: "nt", validate: true }
81
+ args = [{type: :ppa, stem: "ama", inflection_class: 1, tense: :pr, options: options}]
82
+ forms = LLT::FormBuilder.build(*args)
83
+ forms.should have(3).items
84
+ end
85
+
86
+ context "wrong forms" do
87
+ it "ama-nt-is - no extension given" do
88
+ options = { ending: "is", validate: true }
89
+ args = [{type: :ppa, stem: "ama", inflection_class: 1, tense: :pr, options: options}]
90
+ forms = LLT::FormBuilder.build(*args)
91
+ forms.should have(0).items
92
+ end
93
+
94
+ it "*cap-e-nt-is" do
95
+ options = { thematic: "e", validate: true }
96
+ args = [{type: :ppa, stem: "cap", inflection_class: 5, tense: :pr, options: options}]
97
+ forms = LLT::FormBuilder.build(*args)
98
+ forms.should be_empty
99
+ end
100
+
101
+ it "*cap-nt-is" do
102
+ options = { ending: "is", validate: true }
103
+ args = [{type: :ppa, stem: "cap", inflection_class: 5, tense: :pr, options: options}]
104
+ forms = LLT::FormBuilder.build(*args)
105
+ forms.should be_empty
106
+ end
107
+
108
+ it "*ama-e-nt-is" do
109
+ options = { ending: "is", thematic: "e", validate: true }
110
+ args = [{type: :ppa, stem: "ama", inflection_class: 1, tense: :pr, options: options}]
111
+ forms = LLT::FormBuilder.build(*args)
112
+ forms.should be_empty
113
+ end
114
+
115
+ it "*aud-ie-nt-is" do
116
+ options = { ending: "is", thematic: "ie", validate: true }
117
+ args = [{type: :ppa, stem: "aud", inflection_class: 1, tense: :pr, options: options}]
118
+ forms = LLT::FormBuilder.build(*args)
119
+ forms.should be_empty
120
+ end
121
+ end
122
+ end
123
+
124
+ it "audi-e-nt-is" do
125
+ options = { ending: "is", thematic: "e" }
126
+ args = [{type: :ppa, stem: "audi", inflection_class: 4, tense: :pr, options: options}]
127
+ forms = LLT::FormBuilder.build(*args)
128
+ forms.should have(3).items
129
+ forms.first.to_s.should == "audientis"
130
+ forms.first.to_s(:segmentized).should == "audi-e-nt-is"
131
+ end
132
+ end
133
+ end
134
+
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ include LLT::Helpers::Normalizer
5
+
6
+ describe ".build" do
7
+ def form_builder_strings(args)
8
+ forms = LLT::FormBuilder.build(*args)
9
+ forms.map(&:to_s)
10
+ end
11
+
12
+ context "with ppp" do
13
+ context "build all forms" do
14
+ it "a conj" do
15
+ args = [{type: :ppp, stem: "amat", inflection_class: 1, options: { tempus: :pf }}]
16
+ form_builder_strings(args).should == %w{ amatus amati amato amatum amate amato amati amatorum amatis amatos amati amatis
17
+ amata amatae amatae amatam amata amata amatae amatarum amatis amatas amatae amatis
18
+ amatum amati amato amatum amatum amato amata amatorum amatis amata amata amatis }
19
+ end
20
+ end
21
+
22
+ context "with options that select a specfic form given in a stem" do
23
+ it "builds correct forms only (several possibilities)" do
24
+ options = { casus: 3, numerus: 2 }
25
+ args = [{type: :ppp, stem: "amat", inflection_class: 1, options: options}]
26
+ forms = LLT::FormBuilder.build(*args)
27
+
28
+ forms.should have(6).items # 3 forms ppp, 3 forms fp
29
+ form = forms.first
30
+
31
+ form.casus.should == 3
32
+ form.numerus.should == 2
33
+ form.sexus.should == :m
34
+
35
+ form.participium?.should be_true
36
+ form.part?.should be_true
37
+ form.participle?.should be_true
38
+
39
+ form.tempus.should == t.pf
40
+ form.genus.should == t.passivum
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,203 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ def form_builder_strings(args)
5
+ forms = LLT::FormBuilder.build(*args)
6
+ forms.map(&:to_s)
7
+ end
8
+
9
+ context "with hic" do
10
+ it "builds all forms" do
11
+ args = [{type: :pronoun, inflection_class: :hic}]
12
+ form_builder_strings(args).should == %w{ hic huius huic hunc hoc hi horum his hos his
13
+ haec huius huic hanc hac hae harum his has his
14
+ hoc huius huic hoc hoc haec horum his haec his }
15
+ end
16
+
17
+ it "can build specified forms only" do
18
+ args = {type: :pronoun, inflection_class: :hic, options: { casus: 4 }}
19
+ forms = LLT::FormBuilder.build(args)
20
+ forms.should have(6).items
21
+ forms.first.casus.should == 4
22
+ end
23
+
24
+ it "prints particles as distinct segment" do
25
+ args = {type: :pronoun, inflection_class: :hic, options: { casus: 4, numerus: 1, sexus: :m }}
26
+ forms = LLT::FormBuilder.build(args)
27
+ forms.should have(1).item
28
+ forms.first.to_s(:segmentized).should == "h-un-c"
29
+ end
30
+
31
+ it "works with morphologizer style options" do
32
+ args = {type: :pronoun, inflection_class: :hic, options: { ending: "is" }}
33
+ forms = LLT::FormBuilder.build(args)
34
+ forms.should have(6).item
35
+ end
36
+ end
37
+
38
+ context "with ille" do
39
+ it "builds all forms" do
40
+ args = [{type: :pronoun, inflection_class: :ille}]
41
+ form_builder_strings(args).should == %w{ ille illius illi illum illo illi illorum illis illos illis
42
+ illa illius illi illam illa illae illarum illis illas illis
43
+ illud illius illi illud illo illa illorum illis illa illis }
44
+ end
45
+ end
46
+
47
+ context "with iste" do
48
+ it "builds all forms" do
49
+ args = [{type: :pronoun, inflection_class: :iste}]
50
+ form_builder_strings(args).should == %w{ iste istius isti istum isto isti istorum istis istos istis
51
+ ista istius isti istam ista istae istarum istis istas istis
52
+ istud istius isti istud isto ista istorum istis ista istis }
53
+ end
54
+ end
55
+
56
+ context "with ipse" do
57
+ it "builds all forms" do
58
+ args = [{type: :pronoun, inflection_class: :ipse}]
59
+ form_builder_strings(args).should == %w{ ipse ipsius ipsi ipsum ipso ipsi ipsorum ipsis ipsos ipsis
60
+ ipsa ipsius ipsi ipsam ipsa ipsae ipsarum ipsis ipsas ipsis
61
+ ipsum ipsius ipsi ipsum ipso ipsa ipsorum ipsis ipsa ipsis }
62
+ end
63
+ end
64
+
65
+ context "with qui" do
66
+ it "builds all forms" do
67
+ args = [{type: :pronoun, inflection_class: :qui}]
68
+ form_builder_strings(args).should == %w{ qui cuius cui quem quo quocum qui quorum quibus quos quibus quibuscum
69
+ quae cuius cui quam qua quacum quae quarum quibus quas quibuscum quibus
70
+ quod cuius cui quod quo quocum quae quorum quibus quae quibus quibuscum }
71
+ end
72
+
73
+ it "builds only correct forms - qua" do
74
+ opts = { stem: "qu", ending: "a", validate: true}
75
+ args = {type: :pronoun, inflection_class: :qui, options: opts}
76
+ forms = LLT::FormBuilder.build(args)
77
+ forms.should have(1).item
78
+ qua = forms.first
79
+ qua.to_s(:segmentized).should == "qu-a"
80
+ qua.casus.should == 6
81
+ qua.numerus.should == 1
82
+ qua.sexus.should == :f
83
+ end
84
+
85
+ it "builds only correct forms - quibuscum" do
86
+ opts = { stem: "qu", ending: "ibus", suffix: "cum", validate: true}
87
+ args = {type: :pronoun, inflection_class: :qui, options: opts}
88
+ forms = LLT::FormBuilder.build(args)
89
+ forms.should have(3).item
90
+ forms.map(&:casus).should == [6] * 3
91
+ forms.map(&:numerus).should == [2] * 3
92
+ forms.map(&:sexus).should == %i{ m f n }
93
+ forms.map { |f| f.to_s(:segmentized) }.should == %w{ qu-ibus-cum } * 3
94
+ end
95
+ end
96
+
97
+ context "with quisquam" do
98
+ context "with options" do
99
+ it "builds only correct forms" do
100
+ opts = { stem: "qu", ending: "ic", particle: "quam" }
101
+ args = { type: :pronoun, inflection_class: :quisquam, options: opts}
102
+ forms = LLT::FormBuilder.build(args)
103
+ forms.should have(2).items
104
+ forms.map { |f| f.to_s(true) }.should == %w{ qu-ic-quam } * 2
105
+ end
106
+ end
107
+ end
108
+
109
+ context "with quisquis" do
110
+ context "with options" do
111
+ it "builds only correct forms" do
112
+ opts = { stem: "qu", ending: "ic", particle: "quid" }
113
+ args = { type: :pronoun, inflection_class: :quisquis, options: opts}
114
+ forms = LLT::FormBuilder.build(args)
115
+ forms.should have(2).items
116
+ forms.map { |f| f.to_s(true) }.should == %w{ qu-ic-quid } * 2
117
+ end
118
+ end
119
+ end
120
+
121
+ context "with aliqui" do
122
+ it "builds all forms" do
123
+ args = [{type: :pronoun, inflection_class: :aliqui}]
124
+ form_builder_strings(args).should == %w{ aliqui alicuius alicui aliquem aliquo aliqui aliquorum aliquibus aliquos aliquibus
125
+ aliqua alicuius alicui aliquam aliqua aliquae aliquarum aliquibus aliquas aliquibus
126
+ aliquod alicuius alicui aliquod aliquo aliquae aliquorum aliquibus aliquae aliquibus }
127
+ end
128
+ end
129
+
130
+ context "with quicumque" do
131
+ it "builds all forms" do
132
+ args = [{type: :pronoun, inflection_class: :quicumque}]
133
+ form_builder_strings(args).should == %w{ quicumque cuiuscumque cuicumque quemcumque quocumque quicumque quorumcumque quibuscumque quoscumque quibuscumque
134
+ quaecumque cuiuscumque cuicumque quamcumque quacumque quaecumque quarumcumque quibuscumque quascumque quibuscumque
135
+ quodcumque cuiuscumque cuicumque quodcumque quocumque quaecumque quorumcumque quibuscumque quaecumque quibuscumque }
136
+ end
137
+ end
138
+
139
+ context "with uterque" do
140
+ it "builds all forms" do
141
+ args = [{type: :pronoun, inflection_class: :uterque}]
142
+ form_builder_strings(args).should == %w{ uterque utriusque utrique utrumque utroque utrique utrorumque utrisque utrosque utrisque
143
+ utraque utriusque utrique utramque utraque utraeque utrarumque utrisque utrasque utrisque
144
+ utrumque utriusque utrique utrumque utroque utraque utrorumque utrisque utraque utrisque }
145
+ end
146
+ end
147
+
148
+ context "with is" do
149
+ it "builds all forms" do
150
+ pending
151
+ args = [{type: :pronoun, inflection_class: :is}]
152
+ form_builder_strings(args).should == %w{}
153
+ end
154
+
155
+ it "builds only correct forms" do
156
+ opts = { stem: "E", ending: "o"}
157
+ args = [{type: :pronoun, inflection_class: :is, options: opts}]
158
+ form_builder_strings(args).should include("eo")
159
+ end
160
+
161
+ context "with alternate forms" do
162
+ def strings_of(stem, ending)
163
+ opts = { stem: stem, ending: ending, validate: true }
164
+ args = [{type: :pronoun, inflection_class: :is, options: opts}]
165
+ form_builder_strings(args)
166
+ end
167
+
168
+ it "works with is, iis and eis" do
169
+ strings_of("i", "s") .should == %w{ is } * 7 # nom m as well!
170
+ strings_of("i", "is").should == %w{ iis } * 6
171
+ strings_of("e", "is").should == %w{ eis } * 6
172
+ end
173
+ end
174
+ end
175
+
176
+ context "with idem" do
177
+ it "builds all forms" do
178
+ pending
179
+ args = [{type: :pronoun, inflection_class: :isdem}]
180
+ form_builder_strings(args).should == %{}
181
+ end
182
+
183
+ context "with alternating forms" do
184
+ def strings_of(stem, ending)
185
+ opts = { stem: stem, ending: ending, particle: "dem", validate: true }
186
+ args = [{type: :pronoun, inflection_class: :idem, options: opts}]
187
+ form_builder_strings(args)
188
+ end
189
+
190
+ it "builds only correct forms of is" do
191
+ strings_of("i", "s").should == %w{ isdem } * 6
192
+ end
193
+
194
+ it "builds only correct forms of eis" do
195
+ strings_of("e", "is").should == %w{ eisdem } * 6
196
+ end
197
+
198
+ it "builds only correct forms of iis" do
199
+ strings_of("i", "is").should == %w{ iisdem } * 6
200
+ end
201
+ end
202
+ end
203
+ end