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,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with ethnics" do
6
+ context "with options" do
7
+ it "builds only correct forms" do
8
+ opts = { stem: "Haedu", ending: "orum" }
9
+ args = { type: :ethnic, stem: "Haedu", inflection_class: 1, options: opts }
10
+ forms = LLT::FormBuilder.build(args)
11
+ forms.should have(2).items
12
+ forms.first.to_s.should == "Haeduorum" # check if it's still capitalized
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
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
+ it "has a version" do
13
+ LLT::FormBuilder::VERSION.should_not be_nil
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,42 @@
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 fp" do
13
+ it "builds all forms - a conj" do
14
+ args = [{type: :fp, stem: "amat", inflection_class: 1, tense: :pf}]
15
+ form_builder_strings(args).should == %w{ amaturus amaturi amaturo amaturum amature amaturo amaturi amaturorum amaturis amaturos amaturi amaturis
16
+ amatura amaturae amaturae amaturam amatura amatura amaturae amaturarum amaturis amaturas amaturae amaturis
17
+ amaturum amaturi amaturo amaturum amaturum amaturo amatura amaturorum amaturis amatura amatura amaturis }
18
+ end
19
+
20
+ context "with options that select a specfic form given in a stem" do
21
+ it "builds correct forms only (several possibilities)" do
22
+ options = { casus: 2 }
23
+ args = [{type: :fp, stem: "amat", inflection_class: 1,
24
+ tense: :fut, options: options}]
25
+ forms = LLT::FormBuilder.build(*args)
26
+
27
+ forms.should have(6).items
28
+ form = forms[2]
29
+
30
+ form.casus.should == 2
31
+ form.numerus.should == 1
32
+ form.sexus.should == :f
33
+
34
+ form.participium?.should be_true
35
+
36
+ form.tempus.should == t.fut
37
+ form.genus.should == t.act
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,80 @@
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 gerunds" do
13
+ context "build all forms" do
14
+ it "a conj" do
15
+ args = [{type: :gerund, stem: "ama", inflection_class: 1, tense: :pr}]
16
+ forms = LLT::FormBuilder.build(*args)
17
+ forms.map(&:to_s).should == %w{ amandi amando amandum amando }
18
+ forms[0].casus.should == 2
19
+ forms[3].casus.should == 6
20
+ end
21
+
22
+ it "c conj" do
23
+ args = [{type: :gerund, stem: "leg", inflection_class: 3, tense: :pr}]
24
+ forms = LLT::FormBuilder.build(*args)
25
+ forms.map(&:to_s).should == %w{ legendi legendo legendum legendo }
26
+ forms[0].casus.should == 2
27
+ forms[3].casus.should == 6
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with options that select a specfic form given in a stem" do
33
+ context "with gerunds" do
34
+ it "builds correct forms only (several possibilities)" do
35
+ options = { casus: 4 }
36
+ args = [{type: :gerund, stem: "ama", inflection_class: 1, options: options}]
37
+ forms = LLT::FormBuilder.build(*args)
38
+
39
+ forms.should have(1).items
40
+ form = forms[0]
41
+
42
+ form.casus.should == 4
43
+ form.numerus.should == 1
44
+ form.sexus.should == :n
45
+ form.ending.should == "um"
46
+ form.extension.should == "nd"
47
+
48
+ form.gerund?.should be_true
49
+
50
+ form.tempus.should be_nil
51
+ form.genus.should be_nil
52
+ end
53
+
54
+ it "builds correct forms only, ending given" do
55
+ options = { ending: "um" }
56
+ args = [{type: :gerund, stem: "ama", inflection_class: 1, options: options}]
57
+ forms = LLT::FormBuilder.build(*args)
58
+ forms.should have(1).item
59
+ forms.first.casus.should == 4
60
+ end
61
+
62
+ context "with validate flag" do
63
+ it "doesn't build forms when extension is not given" do
64
+ options = { ending: "um", validate: true }
65
+ args = [{type: :gerund, stem: "ama", inflection_class: 1, options: options}]
66
+ forms = LLT::FormBuilder.build(*args)
67
+ forms.should be_empty
68
+ end
69
+
70
+ it "needs the extension to be given" do
71
+ options = { ending: "um", extension: "nd", validate: true }
72
+ args = [{type: :gerund, stem: "ama", inflection_class: 1, options: options}]
73
+ forms = LLT::FormBuilder.build(*args)
74
+ forms.should have(1).items
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,102 @@
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 gerundiva" do
13
+ context "build all forms" do
14
+ it "a conj" do
15
+ args = [{type: :gerundive, stem: "ama", inflection_class: 1, tense: :pr}]
16
+ form_builder_strings(args).should == %w{ amandus amandi amando amandum amande amando amandi amandorum amandis amandos amandi amandis
17
+ amanda amandae amandae amandam amanda amanda amandae amandarum amandis amandas amandae amandis
18
+ amandum amandi amando amandum amandum amando amanda amandorum amandis amanda amanda amandis }
19
+ end
20
+
21
+ it "m conj" do
22
+ args = [{type: :gerundive, stem: "cap", inflection_class: 5, tense: :pr}]
23
+ form_builder_strings(args).should == %w{ capiendus capiendi capiendo capiendum capiende capiendo capiendi capiendorum capiendis capiendos capiendi capiendis
24
+ capienda capiendae capiendae capiendam capienda capienda capiendae capiendarum capiendis capiendas capiendae capiendis
25
+ capiendum capiendi capiendo capiendum capiendum capiendo capienda capiendorum capiendis capienda capienda capiendis }
26
+ end
27
+ end
28
+ end
29
+
30
+ context "with options that select a specfic form given in a stem" do
31
+ context "with gerundives" do
32
+ it "builds correct forms only (several possibilities)" do
33
+ options = { numerus: 2 }
34
+ args = [{type: :gerundive, stem: "ama", inflection_class: 1, options: options}]
35
+ forms = LLT::FormBuilder.build(*args)
36
+
37
+ forms.should have(18).items
38
+ form = forms.last
39
+
40
+ form.casus.should == 6
41
+ form.numerus.should == 2
42
+ form.sexus.should == :n
43
+ form.ending.should == "is"
44
+ form.extension.should == "nd"
45
+
46
+ form.gerundive?.should be_true
47
+
48
+ form.tempus.should be_nil
49
+ form.genus.should be_nil
50
+ end
51
+
52
+ it "builds correct forms only, ending given" do
53
+ options = { ending: "um" }
54
+ args = [{type: :gerundive, stem: "ama", inflection_class: 1, options: options}]
55
+ forms = LLT::FormBuilder.build(*args)
56
+ forms.should have(4).items
57
+ forms.map(&:casus).should == [4, 1, 4, 5]
58
+ forms.map(&:sexus).should == %i{ m n n n }
59
+ end
60
+
61
+ context "with validate flag" do
62
+ it "needs the extension to be given" do
63
+ options = { ending: "um", extension: "nd", validate: true }
64
+ args = [{type: :gerundive, stem: "ama", inflection_class: 1, options: options}]
65
+ forms = LLT::FormBuilder.build(*args)
66
+ forms.should have(4).items
67
+ end
68
+
69
+ it "doesn't build forms when extension is not given" do
70
+ # no extension given, no result
71
+ options = { ending: "um", validate: true }
72
+ args = [{type: :gerundive, stem: "ama", inflection_class: 1, options: options}]
73
+ forms = LLT::FormBuilder.build(*args)
74
+ forms.should be_empty
75
+ end
76
+
77
+ context "with archaic forms" do
78
+ let(:archaic_forms) do
79
+ options = { thematic: "u", extension: "nd", ending: "i", validate: true }
80
+ args = { type: :gerundive, stem: "audi", inflection_class: 4, options: options }
81
+ LLT::FormBuilder.build(args)
82
+ end
83
+
84
+ it "builds the correct forms" do
85
+ archaic_forms.should have(4).items
86
+ archaic_forms.map(&:numerus).should =~ [1, 2, 2, 1]
87
+ archaic_forms.map(&:casus).should =~ [2, 1, 5, 2]
88
+ end
89
+
90
+ it "produces the correct string value for archaic forms" do
91
+ archaic_forms.map(&:to_s).should == %w{ audiundi } * 4
92
+ end
93
+
94
+ it "marks forms as archaic" do
95
+ archaic_forms.map(&:classification).should == %i{ archaic } * 4
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,197 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder::StemHashParser do
4
+ def shp(arg)
5
+ LLT::FormBuilder::StemHashParser.new(arg)
6
+ end
7
+
8
+ include LLT::Helpers::Normalizer
9
+
10
+ describe "#parse" do
11
+ context "with praesens" do
12
+ it "changes type to gerund and gerundive with options extensions: 'nd'" do
13
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { extension: "nd" }}]
14
+ shp(args).parse.should =~ [{type: :gerund, stem: "ama", inflection_class: 1, options: { extension: "nd" }},
15
+ {type: :gerundive, stem: "ama", inflection_class: 1, options: { extension: "nd" }} ]
16
+ end
17
+
18
+ it "changes type to gerund with options modus: 'gerund'" do
19
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { modus: "gerund" }}]
20
+ shp(args).parse.should =~ [{type: :gerund, stem: "ama", inflection_class: 1, options: { modus: :gerundium }}]
21
+ end
22
+
23
+ it "changes type to gerundive with options modus: 'gerundive'" do
24
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { modus: "gerundive" }}]
25
+ shp(args).parse.should =~ [{type: :gerundive, stem: "ama", inflection_class: 1, options: { modus: :gerundivum }}]
26
+ end
27
+
28
+ it "changes type to ppa with options extension: 'nt' or 'n'" do
29
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { extension: "n" }}]
30
+ shp(args).parse.should =~ [{type: :ppa, stem: "ama", inflection_class: 1, options: { extension: "n" }}]
31
+ end
32
+
33
+ it "changes type to ppa with options modus: 'participle'" do
34
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { modus: :participium }}]
35
+ shp(args).parse.should =~ [{type: :ppa, stem: "ama", inflection_class: 1, options: { modus: :part }}]
36
+ end
37
+
38
+ it "changes type to ppa with options modus: 'infinitive'" do
39
+ args = [{type: :praesens, stem: "ama", inflection_class: 1, options: { modus: :infinitive }}]
40
+ shp(args).parse.should =~ [{type: :praesens_infinitivum, stem: "ama", inflection_class: 1, options: { modus: :inf }}]
41
+ end
42
+
43
+ it "returns hashes of the types praesens praesens_infinitivum ppa gerund gerundive without options" do
44
+ args = [{type: :praesens, stem: "ama", inflection_class: 1}]
45
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ praesens praesens_infinitivum ppa gerund gerundive }
46
+ end
47
+
48
+ context "confronted with irregulars" do
49
+ it "returns irregular prasens and no verbal nouns for esse" do
50
+ args = [{type: :praesens, inflection_class: :esse}]
51
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
52
+ end
53
+
54
+ it "returns irregular prasens and no verbal nouns for esse" do
55
+ opts = {:stem=>"es", :ending=>"se"}
56
+ args = [{type: :praesens, inflection_class: :esse, options: opts}]
57
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
58
+ end
59
+
60
+
61
+ it "handles options with ease for irregulars" do
62
+ opts = { ending: "nt", thematic: "u", stem: "s", prefix: "", extension: "" }
63
+ args = [{type: :praesens, inflection_class: :esse, options: opts}]
64
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens }
65
+ end
66
+
67
+ it "returns irregular prasens and no verbal nouns for fieri" do
68
+ args = [{type: :praesens, inflection_class: :fieri}]
69
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
70
+ end
71
+
72
+ it "returns irregular prasens and no verbal nouns for velle" do
73
+ args = [{type: :praesens, inflection_class: :velle}]
74
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
75
+ end
76
+
77
+ it "returns irregular prasens and no verbal nouns for malle" do
78
+ args = [{type: :praesens, inflection_class: :malle}]
79
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
80
+ end
81
+
82
+ it "returns irregular prasens and no verbal nouns for edere" do
83
+ args = [{type: :praesens, inflection_class: :edere}]
84
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
85
+ end
86
+
87
+ it "returns irregular prasens and nouns for ferre" do
88
+ args = [{type: :praesens, inflection_class: :ferre}]
89
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum ppa gerund gerundive }
90
+ end
91
+
92
+ it "returns irregular prasens and verbal nouns for ire" do
93
+ args = [{type: :praesens, inflection_class: :ire}]
94
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum irregular_ppa irregular_gerund irregular_gerundive }
95
+ end
96
+
97
+ it "returns irregular prasens and no verbal nouns for posse" do
98
+ args = [{type: :praesens, inflection_class: :posse}]
99
+ shp(args).parse.map { |h| h[:type] }.should =~ %i{ irregular_praesens irregular_praesens_infinitivum }
100
+ end
101
+ end
102
+ end
103
+
104
+ context "with perfectum" do
105
+ it "changes type to perfectum_infinitivum with options modus: 'infinitive'" do
106
+ args = [{type: :perfectum, stem: "amav", inflection_class: 1, options: { modus: :infinitive }}]
107
+ shp(args).parse.should =~ [{type: :perfectum_infinitivum, stem: "amav", inflection_class: 1, options: { modus: :inf }}]
108
+ end
109
+
110
+ it "returns perfectum and perfectum_infinitivum without options" do
111
+ args = [{type: :perfectum, stem: "amav", inflection_class: 1 }]
112
+ shp(args).parse.should =~ [{type: :perfectum, stem: "amav", inflection_class: 1},
113
+ {type: :perfectum_infinitivum, stem: "amav", inflection_class: 1}]
114
+ end
115
+
116
+ it "returns perfectum with detailed options like venisset has" do
117
+ opts = {:ending=>"t", :extension=>"isse", :validate => true}
118
+ args = [{:type=>:perfectum, :stem=>"ven", :inflection_class=>4, options: opts}]
119
+ shp(args).parse.should =~ [{type: :perfectum, stem: "ven", inflection_class: 4, options: opts}]
120
+ end
121
+ end
122
+
123
+ context "with ppp" do
124
+ it "changes type to fp with options extensions: 'ur'" do
125
+ args = [{type: :ppp, stem: "amat", inflection_class: 1, options: { extension: "ur" }}]
126
+ shp(args).parse.should =~ [{type: :fp, stem: "amat", inflection_class: 1, options: { extension: "ur" }}]
127
+ end
128
+
129
+ it "changes type to ... with options modus: 'participle'" do
130
+ args = [{type: :ppp, stem: "amat", inflection_class: 1, options: { modus: :participium }}]
131
+ shp(args).parse.should =~ [{type: :ppp, stem: "amat", inflection_class: 1, options: { modus: :part }},
132
+ {type: :fp, stem: "amat", inflection_class: 1, options: { modus: :part }} ]
133
+ end
134
+
135
+ it "changes type supinum with options modus: 'supinum'" do
136
+ args = [{type: :ppp, stem: "amat", inflection_class: 1, options: { modus: :supinum }}]
137
+ shp(args).parse.should =~ [{type: :supinum, stem: "amat", inflection_class: 1, options: { modus: :supinum } }]
138
+ end
139
+
140
+ it "returns ppp, fp and supinum without options" do
141
+ args = [{type: :ppp, stem: "amat", inflection_class: 1}]
142
+ shp(args).parse.should =~ [{type: :ppp, stem: "amat", inflection_class: 1 },
143
+ {type: :fp, stem: "amat", inflection_class: 1 },
144
+ {type: :supinum, stem: "amat", inflection_class: 1 }]
145
+ end
146
+ end
147
+
148
+ context "with adjectives" do
149
+ it "returns adjective and adverb stems" do
150
+ args = [{type: :adjective, stem: "alt", inflection_class: 1, comparatio: :positivus}]
151
+ shp(args).parse.should =~ [ {type: :adjective, stem: "alt", inflection_class: 1, comparatio: :positivus},
152
+ {type: :adverb, stem: "alt", inflection_class: 1, comparatio: :positivus}]
153
+ end
154
+
155
+ it "corrects the comparativus stem" do
156
+ args = [{type: :adjective, stem: "altior", inflection_class: 1, comparatio: :comparativus}]
157
+ shp(args).parse.should =~ [ {type: :adjective, stem: "altior", inflection_class: 1, comparatio: :comparativus},
158
+ {type: :adverb, stem: "altius", inflection_class: 1, comparatio: :comparativus}]
159
+
160
+ end
161
+
162
+ it "returns only adjecive stem when irregular adverb building is present" do
163
+ args = [{type: :adjective, stem: "bon", inflection_class: 1, comparatio: :positivus, irregular_adverb: true}]
164
+ shp(args).parse.should =~ [ {type: :adjective, stem: "bon", inflection_class: 1, comparatio: :positivus, irregular_adverb: true} ]
165
+ end
166
+ end
167
+
168
+ context "with pronouns" do
169
+ context "with quisque" do
170
+ it "returns substantivic AND adjectivic stem, when options come with ending is" do
171
+ args = [{type: :pronoun, inflection_class: :quisque, options: { ending: "is"} }]
172
+ stems = shp(args).parse
173
+ stems.should have(2).items
174
+ stems.map { |st| st[:inflection_class] }.should == %i{ quisque quisque_s }
175
+
176
+ args = [{type: :pronoun, inflection_class: :quisque_s, options: { ending: "is"} }]
177
+ stems = shp(args).parse
178
+ stems.should have(2).items
179
+ stems.map { |st| st[:inflection_class] }.should == %i{ quisque quisque_s }
180
+ end
181
+ end
182
+ end
183
+
184
+ context "with unusquisque" do
185
+ it "works like quisque" do
186
+ args = [{type: :pronoun, inflection_class: :unusquisque, options: { ending: "is"} }]
187
+ stems = shp(args).parse
188
+ stems.should have(2).items
189
+ stems.map { |st| st[:inflection_class] }.should == %i{ unusquisque unusquisque_s }
190
+
191
+ args = [{type: :pronoun, inflection_class: :unusquisque_s, options: { ending: "is"} }]
192
+ stems = shp(args).parse
193
+ stems.should have(2).items
194
+ end
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with irregular gerundiva" do
6
+ context "with gerundives" do
7
+ context "with options that select a specfic form given in a stem" do
8
+ context "with validate flag" do
9
+ it "builds correct forms only" do
10
+ options = { prefix: "ad", ending: "um" }
11
+ args = [{type: :irregular_gerund, inflection_class: :ferre, options: options}]
12
+ forms = LLT::FormBuilder.build(*args)
13
+ forms.should have(1).item
14
+ forms.first.to_s(:segmentized).should == "ad-fer-e-nd-um"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with irregular gerundiva" do
6
+ context "with gerundives" do
7
+ context "with options that select a specfic form given in a stem" do
8
+ context "with validate flag" do
9
+ it "builds correct forms only" do
10
+ options = { prefix: "ad", ending: "um" }
11
+ args = [{type: :irregular_gerundive, inflection_class: :ferre, options: options}]
12
+ forms = LLT::FormBuilder.build(*args)
13
+ forms.should have(4).items
14
+ forms.first.to_s(:segmentized).should == "ad-fer-e-nd-um"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with options" do
6
+ it "builds the form fiebat" do
7
+ opts = {:stem=>"fi", :thematic=>"e", :extension=>"ba", :ending=>"t", validate: true}
8
+ args = { type: :praesens, inflection_class: :fieri, options: opts}
9
+ forms = LLT::FormBuilder.build(args)
10
+ forms.should have(1).item
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe LLT::FormBuilder do
4
+ describe ".build" do
5
+ context "with irregular praesens infinitive" do
6
+ context "with options" do
7
+ it "builds the form esse" do
8
+ opts = {:stem=>"es", :ending=>"se"}
9
+ args = { type: :praesens, inflection_class: :esse, options: opts}
10
+ forms = LLT::FormBuilder.build(args)
11
+ forms.should have(1).item
12
+ end
13
+
14
+ it "builds the form posse" do
15
+ opts = {:stem=>"pos", :ending=>"se"}
16
+ args = { type: :praesens, inflection_class: :posse, options: opts}
17
+ forms = LLT::FormBuilder.build(args)
18
+ forms.should have(1).item
19
+ end
20
+
21
+ it "builds the form abesse" do
22
+ opts = {:stem=>"es", :prefix=>"ab", :ending=>"se"}
23
+ args = { type: :praesens, inflection_class: :esse, options: opts}
24
+ forms = LLT::FormBuilder.build(args)
25
+ forms.should have(1).item
26
+ forms.first.to_s(:segmentized).should == "ab-es-se"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+