llt-form_builder 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,24 @@
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 supina" do
13
+ it "builds all forms" do
14
+ args = [{type: :supinum, stem: "amat", inflection_class: 1, tense: :pf}]
15
+ forms = LLT::FormBuilder.build(*args)
16
+ forms.map(&:to_s).should == %w{ amatu amatum amatu }
17
+ forms[0].casus.should == 3
18
+ forms[1].casus.should == 4
19
+ forms[2].casus.should == 6
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,557 @@
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 verb_with_options(options)
13
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: options}]
14
+ LLT::FormBuilder.build(*args)
15
+ end
16
+
17
+ def perf_verb_with_options(options)
18
+ args = [{type: :perfectum, stem: "amav", inflection_class: 1, options: options}]
19
+ LLT::FormBuilder.build(*args)
20
+ end
21
+
22
+ context "with verbs" do
23
+ context "without options" do
24
+ context "with praesens stem" do
25
+ context "check variables of a single form" do
26
+ context "a conj" do
27
+ let(:forms) do
28
+ args = [{type: :praesens, stem: "ama", inflection_class: 1}]
29
+ LLT::FormBuilder.build(*args)
30
+ end
31
+
32
+ it "1.st.sg.ind.pr.act." do
33
+ amo = forms[0]
34
+ amo.modus.should == t.indicativus
35
+ amo.genus.should == t.activum
36
+ amo.tempus.should == t.praesens
37
+ amo.numerus.should == t.sg
38
+ amo.persona.should == 1
39
+ end
40
+
41
+ it "3.pl.ind.pr.pass." do
42
+ amantur = forms[11]
43
+ amantur.modus.should == t.indicativus
44
+ amantur.genus.should == t.passivum
45
+ amantur.tempus.should == t.praesens
46
+ amantur.numerus.should == t.pl
47
+ amantur.persona.should == 3
48
+ amantur.to_s(true).should == "ama-ntur"
49
+ end
50
+
51
+ it "3.sg.con.pr.act." do
52
+ amet = forms[14]
53
+ amet.modus.should == t.con
54
+ amet.genus.should == t.act
55
+ amet.tempus.should == t.praesens
56
+ amet.numerus.should == t.sg
57
+ amet.persona.should == 3
58
+ amet.to_s(true).should == "am-e-t"
59
+ end
60
+
61
+ it "2.pl.ind.imp.pass." do
62
+ amabatis = forms[32]
63
+ amabatis.modus.should == t.ind
64
+ amabatis.genus.should == t.act
65
+ amabatis.tempus.should == t.impf
66
+ amabatis.to_s(true).should == "ama-ba-tis"
67
+ amabatis.persona.should == 2
68
+ amabatis.numerus.should == t.pl
69
+ end
70
+
71
+ it "3.pl.ind.fut.pass." do
72
+ amabuntur = forms[63]
73
+ amabuntur.modus.should == t.ind
74
+ amabuntur.genus.should == t.pass
75
+ amabuntur.tempus.should == t.fut
76
+ amabuntur.numerus.should == t.pl
77
+ amabuntur.persona.should == 3
78
+ amabuntur.to_s(true).should == "ama-b-u-ntur"
79
+ end
80
+ end
81
+
82
+ context "c conj" do
83
+ let(:forms) do
84
+ args = [{ type: :praesens, stem: "leg", inflection_class: 3 }]
85
+ LLT::FormBuilder.build(*args)
86
+ end
87
+
88
+ it "1.sg.con.pr.pass." do
89
+ legar = forms[18]
90
+ legar.modus.should == t.con
91
+ legar.genus.should == t.pass
92
+ legar.tempus.should == t.pr
93
+ legar.numerus.should == t.sg
94
+ legar.persona.should == 1
95
+ legar.to_s(true).should == "leg-a-r"
96
+ end
97
+ end
98
+
99
+ context "i conj" do
100
+ let(:forms) do
101
+ args = [{ type: :praesens, stem: "audi", inflection_class: 4 }]
102
+ LLT::FormBuilder.build(*args)
103
+ end
104
+
105
+ it "2.pl.con.impf.pass." do
106
+ audiremini = forms[50]
107
+ audiremini.modus.should == t.con
108
+ audiremini.genus.should == t.pass
109
+ audiremini.tempus.should == t.impf
110
+ audiremini.numerus.should == t.pl
111
+ audiremini.persona.should == 2
112
+ audiremini.to_s(true).should == "audi-re-mini"
113
+ end
114
+
115
+ it "3.pl.ind.pr.act." do
116
+ audiunt = forms[5]
117
+ audiunt.modus.should == t.indicativus
118
+ audiunt.genus.should == t.activum
119
+ audiunt.tempus.should == t.praesens
120
+ audiunt.numerus.should == t.pl
121
+ audiunt.persona.should == 3
122
+ audiunt.to_s(true).should == "audi-u-nt"
123
+ end
124
+ end
125
+
126
+ context "m conj" do
127
+ let(:forms) do
128
+ args = [{ type: :praesens, stem: "cap", inflection_class: 5 }]
129
+ LLT::FormBuilder.build(*args)
130
+ end
131
+
132
+ it "1.pl.ind.fut.act." do
133
+ capiemus = forms[55]
134
+ capiemus.modus.should == t.ind
135
+ capiemus.genus.should == t.act
136
+ capiemus.tempus.should == t.fut
137
+ capiemus.numerus.should == t.pl
138
+ capiemus.persona.should == 1
139
+ capiemus.to_s(true).should == "cap-i-e-mus"
140
+ end
141
+ end
142
+ end
143
+
144
+ context "works with deponentia" do
145
+ it "builds all forms" do
146
+ args = [{ type: :praesens, stem: "horta", inflection_class: 1, deponens: true, options: { finite: true }}]
147
+ forms = LLT::FormBuilder.build(*args)
148
+ forms.should have(35).items
149
+ forms.all? { |f| f.genus == :act }.should be_true
150
+ forms.first.to_s.should == "hortor"
151
+ end
152
+ end
153
+
154
+ context "works with impersonalia" do
155
+ it "builds only 3rd person forms" do
156
+ args = [{ type: :praesens, stem: "oporte", inflection_class: 2, impersonalium: true, options: { finite: true }}]
157
+ forms = LLT::FormBuilder.build(*args)
158
+ forms.should have(24).items
159
+ end
160
+ end
161
+
162
+ context "builds all forms of" do
163
+ it "a conj" do
164
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { finite: true }}]
165
+ form_builder_strings(args).should == %w{ amo amas amat amamus amatis amant
166
+ amor amaris amatur amamur amamini amantur
167
+ amem ames amet amemus ametis ament
168
+ amer ameris ametur amemur amemini amentur
169
+ ama amate amare amamini
170
+
171
+ amabam amabas amabat amabamus amabatis amabant
172
+ amabar amabaris amabatur amabamur amabamini amabantur
173
+ amarem amares amaret amaremus amaretis amarent
174
+ amarer amareris amaretur amaremur amaremini amarentur
175
+
176
+ amabo amabis amabit amabimus amabitis amabunt
177
+ amabor amaberis amabitur amabimur amabimini amabuntur
178
+ amato amato amatote amanto amator amator amantor }
179
+ end
180
+
181
+ it "e conj" do
182
+ args = [{type: :praesens, stem: "mone", inflection_class: 2, options: { finite: true }}]
183
+ form_builder_strings(args).should == %w{ moneo mones monet monemus monetis monent
184
+ moneor moneris monetur monemur monemini monentur
185
+ moneam moneas moneat moneamus moneatis moneant
186
+ monear monearis moneatur moneamur moneamini moneantur
187
+ mone monete monere monemini
188
+
189
+ monebam monebas monebat monebamus monebatis monebant
190
+ monebar monebaris monebatur monebamur monebamini monebantur
191
+ monerem moneres moneret moneremus moneretis monerent
192
+ monerer monereris moneretur moneremur moneremini monerentur
193
+
194
+ monebo monebis monebit monebimus monebitis monebunt
195
+ monebor moneberis monebitur monebimur monebimini monebuntur
196
+ moneto moneto monetote monento monetor monetor monentor }
197
+ end
198
+
199
+ it "c conj" do
200
+ args = [{type: :praesens, stem: "leg", inflection_class: 3, options: { finite: true }}]
201
+ form_builder_strings(args).should == %w{ lego legis legit legimus legitis legunt
202
+ legor legeris legitur legimur legimini leguntur
203
+ legam legas legat legamus legatis legant
204
+ legar legaris legatur legamur legamini legantur
205
+ lege legite legere legimini
206
+
207
+ legebam legebas legebat legebamus legebatis legebant
208
+ legebar legebaris legebatur legebamur legebamini legebantur
209
+ legerem legeres legeret legeremus legeretis legerent
210
+ legerer legereris legeretur legeremur legeremini legerentur
211
+
212
+ legam leges leget legemus legetis legent
213
+ legar legeris legetur legemur legemini legentur
214
+ legito legito legitote legunto legitor legitor leguntor }
215
+ end
216
+
217
+ it "i conj" do
218
+ args = [{type: :praesens, stem: "audi", inflection_class: 4, options: { finite: true }}]
219
+ form_builder_strings(args).should == %w{ audio audis audit audimus auditis audiunt
220
+ audior audiris auditur audimur audimini audiuntur
221
+ audiam audias audiat audiamus audiatis audiant
222
+ audiar audiaris audiatur audiamur audiamini audiantur
223
+ audi audite audire audimini
224
+
225
+ audiebam audiebas audiebat audiebamus audiebatis audiebant
226
+ audiebar audiebaris audiebatur audiebamur audiebamini audiebantur
227
+ audirem audires audiret audiremus audiretis audirent
228
+ audirer audireris audiretur audiremur audiremini audirentur
229
+
230
+ audiam audies audiet audiemus audietis audient
231
+ audiar audieris audietur audiemur audiemini audientur
232
+ audito audito auditote audiunto auditor auditor audiuntor }
233
+ end
234
+
235
+ it "m conj" do
236
+ args = [{type: :praesens, stem: "cap", inflection_class: 5, options: { finite: true }}]
237
+ form_builder_strings(args).should == %w{ capio capis capit capimus capitis capiunt
238
+ capior caperis capitur capimur capimini capiuntur
239
+ capiam capias capiat capiamus capiatis capiant
240
+ capiar capiaris capiatur capiamur capiamini capiantur
241
+ cape capite capere capimini
242
+
243
+ capiebam capiebas capiebat capiebamus capiebatis capiebant
244
+ capiebar capiebaris capiebatur capiebamur capiebamini capiebantur
245
+ caperem caperes caperet caperemus caperetis caperent
246
+ caperer capereris caperetur caperemur caperemini caperentur
247
+
248
+ capiam capies capiet capiemus capietis capient
249
+ capiar capieris capietur capiemur capiemini capientur
250
+ capito capito capitote capiunto capitor capitor capiuntor }
251
+ end
252
+ end
253
+ end
254
+
255
+ context "with praesens infinitive" do
256
+ it "builds all forms" do
257
+ args = [{ type: :praesens_infinitivum, stem: "ama", inflection_class: 1 }]
258
+ forms = LLT::FormBuilder.build(*args)
259
+ forms.should have(2).items
260
+ a = forms.first
261
+ p = forms.last
262
+ a.to_s(:segmentized).should == "ama-re"
263
+ p .to_s(:segmentized).should == "ama-ri"
264
+ a.genus.should == :act
265
+ p.genus.should == :pass
266
+ end
267
+
268
+ it "builds all forms with proper thematic" do
269
+ args = [{ type: :praesens_infinitivum, stem: "leg", inflection_class: 3 }]
270
+ forms = LLT::FormBuilder.build(*args)
271
+ forms.should have(2).items
272
+ a = forms.first
273
+ p = forms.last
274
+ a.to_s(:segmentized).should == "leg-e-re"
275
+ p.to_s(:segmentized).should == "leg-i"
276
+ end
277
+ end
278
+
279
+ context "with perfect stem" do
280
+ it "builds all forms" do
281
+ args = { type: :perfectum, stem: "amav", inflection_class: 1 }
282
+ forms = LLT::FormBuilder.build(args)
283
+ forms.should have(31).items
284
+ end
285
+
286
+ it "builds only correct forms" do
287
+ opts = {:ending=>"t", :extension=>"isse", :validate => true}
288
+ args = {:type=>:perfectum, :stem=>"ven", :inflection_class=>4, options: opts}
289
+ forms = LLT::FormBuilder.build(args)
290
+ forms.should_not be_empty
291
+ end
292
+
293
+ it "builds all forms - even for esse" do
294
+ args = { type: :perfectum, stem: "fu", inflection_class: :esse }
295
+ forms = LLT::FormBuilder.build(args)
296
+ forms.should have(31).items
297
+ end
298
+ end
299
+
300
+ context "with perfect infinitive" do
301
+ it "builds all forms" do
302
+ args = [{ type: :perfectum_infinitivum, stem: "amav", inflection_class: 1 }]
303
+ forms = LLT::FormBuilder.build(*args)
304
+ forms.should have(1).items
305
+ a = forms.first
306
+ a.to_s(:segmentized).should == "amav-isse"
307
+ a.genus.should == :act
308
+ a.tempus.should == :pf
309
+ end
310
+ end
311
+ end
312
+
313
+
314
+ context "of irregular praesens stem" do
315
+ context "with esse" do
316
+ it "builds all forms" do
317
+ args = [{ type: :praesens, stem: "s", inflection_class: :esse }]
318
+ forms = LLT::FormBuilder.build(*args)
319
+ forms.map(&:to_s).should == %w{
320
+ sum es est sumus estis sunt
321
+ sim sis sit simus sitis sint
322
+ es este
323
+ eram eras erat eramus eratis erant
324
+ essem esses esset essemus essetis essent
325
+ ero eris erit erimus eritis erunt
326
+ esto esto estote sunto
327
+ esse
328
+ }
329
+ end
330
+ end
331
+
332
+ context "with fieri" do
333
+ it "builds all forms" do
334
+ args = [{ type: :praesens, stem: "fi", inflection_class: :fieri }]
335
+ forms = LLT::FormBuilder.build(*args)
336
+ forms.map(&:to_s).should == %w{
337
+ fio fis fit fimus fitis fiunt
338
+ fiam fias fiat fiamus fiatis fiant
339
+ fiebam fiebas fiebat fiebamus fiebatis fiebant
340
+ fierem fieres fieret fieremus fieretis fierent
341
+ fiam fies fiet fiemus fietis fient
342
+ fieri
343
+ }
344
+ end
345
+ end
346
+
347
+ context "with malle" do
348
+ it "builds all forms" do
349
+ args = [{ type: :praesens, stem: "mal", inflection_class: :malle }]
350
+ forms = LLT::FormBuilder.build(*args)
351
+ forms.map(&:to_s).should == %w{
352
+ malo mavis mavult malumus mavultis malunt
353
+ malim malis malit malimus malitis malint
354
+ malebam malebas malebat malebamus malebatis malebant
355
+ mallem malles mallet mallemus malletis mallent
356
+ malam males malet malemus maletis malent
357
+ malle
358
+ }
359
+ end
360
+ end
361
+
362
+ context "with velle" do
363
+ it "builds all forms" do
364
+ args = [{ type: :praesens, stem: "vol", inflection_class: :velle }]
365
+ forms = LLT::FormBuilder.build(*args)
366
+ forms.map(&:to_s).should == %w{
367
+ volo vis vult volumus vultis volunt
368
+ velim velis velit velimus velitis velint
369
+ volebam volebas volebat volebamus volebatis volebant
370
+ vellem velles vellet vellemus velletis vellent
371
+ volam voles volet volemus voletis volent
372
+ velle
373
+ }
374
+ end
375
+ end
376
+
377
+ context "with posse" do
378
+ it "builds all forms" do
379
+ args = [{ type: :praesens, stem: "pot", inflection_class: :posse }]
380
+ forms = LLT::FormBuilder.build(*args)
381
+ forms.map(&:to_s).should == %w{
382
+ possum potes potest possumus potestis possunt
383
+ possim possis possit possimus possitis possint
384
+ poteram poteras poterat poteramus poteratis poterant
385
+ possem posses posset possemus possetis possent
386
+ potero poteris poterit poterimus poteritis poterunt
387
+ posse
388
+ }
389
+ end
390
+ end
391
+
392
+ context "with ire" do
393
+ it "builds all forms" do
394
+ args = [{ type: :praesens, stem: "i", inflection_class: :ire }]
395
+ forms = LLT::FormBuilder.build(*args)
396
+ forms.map(&:to_s).should == %w{
397
+ eo is it imus itis eunt
398
+ eor iris itur imur imini euntur
399
+ eam eas eat eamus eatis eant
400
+ ear earis eatur eamur eamini eantur
401
+ i ite ire imini
402
+
403
+ ibam ibas ibat ibamus ibatis ibant
404
+ ibar ibaris ibatur ibamur ibamini ibantur
405
+ irem ires iret iremus iretis irent
406
+ irer ireris iretur iremur iremini irentur
407
+ ibo ibis ibit ibimus ibitis ibunt
408
+ ibor iberis ibitur ibimur ibimini ibuntur
409
+ ito ito itote eunto itor itor euntor
410
+ ire iri
411
+
412
+ iens euntis eunti euntem iens eunte
413
+ euntes euntium euntibus euntes euntes euntibus
414
+ iens euntis eunti euntem iens eunte
415
+ euntes euntium euntibus euntes euntes euntibus
416
+ iens euntis eunti iens iens eunte
417
+ euntia euntium euntibus euntia euntia euntibus
418
+
419
+ eundi eundo eundum eundo
420
+
421
+ eundus eundi eundo eundum eunde eundo
422
+ eundi eundorum eundis eundos eundi eundis
423
+ eunda eundae eundae eundam eunda eunda
424
+ eundae eundarum eundis eundas eundae eundis
425
+ eundum eundi eundo eundum eundum eundo
426
+ eunda eundorum eundis eunda eunda eundis
427
+ }
428
+ end
429
+ end
430
+
431
+ context "with ferre" do
432
+ it "builds all forms" do
433
+ args = [{ type: :praesens, stem: "fer", inflection_class: :ferre }]
434
+ forms = LLT::FormBuilder.build(*args)
435
+ forms.map(&:to_s).should == %w{
436
+ fero fers fert ferimus fertis ferunt
437
+ feror ferris fertur ferimur ferimini feruntur
438
+ feram feras ferat feramus feratis ferant
439
+ ferar feraris feratur feramur feramini ferantur
440
+
441
+ fer ferte ferre ferimini
442
+ ferebam ferebas ferebat ferebamus ferebatis ferebant
443
+ ferebar ferebaris ferebatur ferebamur ferebamini ferebantur
444
+ ferrem ferres ferret ferremus ferretis ferrent
445
+ ferrer ferreris ferretur ferremur ferremini ferrentur
446
+ feram feres feret feremus feretis ferent
447
+ ferar fereris feretur feremur feremini ferentur
448
+ ferto ferto fertote ferunto fertor fertor feruntor
449
+ ferre ferri
450
+
451
+ ferens ferentis ferenti ferentem ferens ferente
452
+ ferentes ferentium ferentibus ferentes ferentes ferentibus
453
+ ferens ferentis ferenti ferentem ferens ferente
454
+ ferentes ferentium ferentibus ferentes ferentes ferentibus
455
+ ferens ferentis ferenti ferens ferens ferente
456
+ ferentia ferentium ferentibus ferentia ferentia ferentibus
457
+
458
+ ferendi ferendo ferendum ferendo
459
+
460
+ ferendus ferendi ferendo ferendum ferende ferendo
461
+ ferendi ferendorum ferendis ferendos ferendi ferendis
462
+ ferenda ferendae ferendae ferendam ferenda ferenda
463
+ ferendae ferendarum ferendis ferendas ferendae ferendis
464
+ ferendum ferendi ferendo ferendum ferendum ferendo
465
+ ferenda ferendorum ferendis ferenda ferenda ferendis
466
+ }
467
+ end
468
+
469
+ end
470
+ end
471
+
472
+ context "with options that select a specfic form given in a stem" do
473
+ context "of praesens stem" do
474
+ context "only forms specified in options" do
475
+ it "returns pr" do
476
+ opts = { tempus: :pr }
477
+ forms = verb_with_options(opts)
478
+ forms.should have(28).items
479
+ end
480
+
481
+ it "returns impf" do
482
+ opts = { tempus: :impf }
483
+ forms = verb_with_options(opts)
484
+ forms.should have(24).items
485
+ end
486
+ end
487
+ end
488
+
489
+ context "of perfect stem" do
490
+ context "only forms specified in options" do
491
+ it "returns pqpf" do
492
+ opts = { tempus: :pqpf }
493
+ forms = perf_verb_with_options(opts)
494
+ forms.should have(12).items
495
+ end
496
+
497
+ it "returns pf con" do
498
+ opts = { tempus: :pf, modus: :con }
499
+ forms = perf_verb_with_options(opts)
500
+ forms.should have(6).items
501
+ end
502
+
503
+ context "impossible forms" do
504
+ it "returns pf pass" do
505
+ opts = { tempus: :pf, genus: :pass }
506
+ forms = perf_verb_with_options(opts)
507
+ forms.should have(0).items
508
+ end
509
+ end
510
+ end
511
+ end
512
+ end
513
+
514
+ context "with options that indicate the word's components" do
515
+ context "of praesens stem" do
516
+ context "with validate flag passed" do
517
+ it "builds only correct forms when extension is given" do
518
+ opts = { extension: "re", validate: true }
519
+ forms = verb_with_options(opts)
520
+ forms.should have(12).items
521
+ forms.all? { |f| f.tempus == :impf }.should be_true
522
+ end
523
+
524
+ it "builds only correct forms when ending is given" do
525
+ opts = { ending: "nt" }
526
+ forms = verb_with_options(opts)
527
+ forms.should have(5).items
528
+ end
529
+
530
+ it "buils only correct forms when ending is given - deponentia" do
531
+ opts = { ending: "s", validate: true}
532
+ args = { type: :praesens, stem: "causa", inflection_class: 1, deponens: true, options: opts }
533
+ forms = LLT::FormBuilder.build(args)
534
+ forms.should be_empty
535
+ end
536
+
537
+ it "returns pr con" do
538
+ opts = { tempus: :pr, modus: :con }
539
+ forms = verb_with_options(opts)
540
+ forms.should have(12).items
541
+ end
542
+ end
543
+
544
+ context "of irregular praesens stem" do
545
+ it "build only correct forms" do
546
+ opts = { prefix: "", stem: "s", thematic: "u", extension: "", ending: "nt", validate: true }
547
+ arg = { type: :praesens, inflection_class: :esse, options: opts }
548
+ forms = LLT::FormBuilder.build(arg)
549
+ forms.should have(1).item
550
+ forms.first.to_s(:segmentized).should == "s-u-nt"
551
+ end
552
+ end
553
+ end
554
+ end
555
+ end
556
+ end
557
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::Form do
4
+ describe '#init_functions' do
5
+ it 'always contains a function name derived from the class name' do
6
+ verb = LLT::Form::Verb.new({})
7
+ noun = LLT::Form::Noun.new({})
8
+ prep = LLT::Form::Preposition.new({})
9
+
10
+ verb.functions.should include :verb
11
+ noun.functions.should include :noun
12
+ prep.functions.should include :preposition
13
+ end
14
+ end
15
+
16
+ describe "#has_f?, #has_function?, #has_not_f?, #has_not_function?" do
17
+ it "queries an objects functions" do
18
+ verb = LLT::Form::Verb.new({})
19
+
20
+ verb.has_f?(:verb).should be_true
21
+ verb.has_function?(:noun).should be_false
22
+
23
+ verb.has_not_f?(:verb).should be_false
24
+ verb.has_not_function?(:noun).should be_true
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::Stem::AdjectivePack do
4
+ let(:ap) { LLT::Stem::AdjectivePack }
5
+
6
+ describe "#lemma" do
7
+ it "returns the nominative value of the positive stem" do
8
+ args = { nom: "altus", stem: "alt", inflectable_class: 1, number_of_endings: 3 }
9
+ adj = ap.new(:adjective, args, "")
10
+ adj.lemma.should == 'altus'
11
+ end
12
+ end
13
+
14
+ describe "#initialize" do
15
+ context "returns extended stems by default, i.e. three stems: positivus, comparativus, superlativus" do
16
+ context "with regulars" do
17
+ it "builds ior and issimus" do
18
+ # adverb might need to follow - or they take a different path with three stems as well.
19
+ args = { nom: "altus", stem: "alt", inflectable_class: 1, number_of_endings: 3 }
20
+
21
+ stems = ap.new(:adjective, args, "").stems
22
+ stems.map(&:stem).should == %w{ alt altior altissim }
23
+ end
24
+
25
+ it "builds ior and limus" do
26
+ args = { nom: "facilis", stem: "facil", inflectable_class: 3, number_of_endings: 2 }
27
+
28
+ stems = ap.new(:adjective, args, "").stems
29
+ stems.map(&:stem).should == %w{ facil facilior facillim }
30
+ end
31
+
32
+ it "builds ior and rimus" do
33
+ args = { nom: "asper", stem: "asper", inflectable_class: 3, number_of_endings: 1 }
34
+
35
+ stems = ap.new(:adjective, args, "").stems
36
+ stems.map(&:stem).should == %w{ asper asperior asperrim }
37
+ end
38
+
39
+ it "builds ior and rimus (with the e catch as in pulcher)" do
40
+ args = { nom: "pulcher", stem: "pulchr", inflectable_class: 1, number_of_endings: 3 }
41
+
42
+ stems = ap.new(:adjective, args, "").stems
43
+ # pulchrior or pulcherior?
44
+ stems.map(&:stem).should == %w{ pulchr pulchrior pulcherrim }
45
+ end
46
+ end
47
+
48
+ it "a comparative stem must not contain the nom info from the positivus stem" do
49
+ args = { nom: "altus", stem: "alt", inflectable_class: 1, number_of_endings: 3 }
50
+
51
+ stems = ap.new(:adjective, args, "").stems
52
+ pos = stems.find { |stem| stem.comparatio == :positivus }
53
+ comp = stems.find { |stem| stem.comparatio == :comparativus }
54
+ sup = stems.find { |stem| stem.comparatio == :superlativus }
55
+
56
+ pos .to_hash[:nom].should be_true
57
+ comp.to_hash[:nom].should be_false
58
+ sup .to_hash[:nom].should be_false
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#check_irregularities" do
64
+ it "sets an irregular adverb flag if needed" do
65
+ args = { nom: "bonus", stem: "bon", inflectable_class: 1, number_of_endings: 3 }
66
+ x = ap.new(:adjective, {}, "", false)
67
+ x.send(:check_irregularities, args)
68
+ args[:irregular_adverb].should be_true
69
+ end
70
+
71
+ it "builds a distinct adverb stem" do
72
+ args = { nom: "bonus", stem: "bon", inflectable_class: 1, number_of_endings: 3 }
73
+ x = ap.new(:adjective, {}, "", false)
74
+ x.should receive(:add)
75
+ x.send(:check_irregularities, args)
76
+ end
77
+ end
78
+ end