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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a646c0ab62b83ed7eb989de75e56050ccf66ce9e
4
+ data.tar.gz: 5ef3973cb4fd232122c3106c3914746a5400dd0e
5
+ SHA512:
6
+ metadata.gz: db00fe6da74e40ec70a5224c2e73727082db3e0928bb58d433df1409595a2954e20594ebd11c378441ff0dbbb775126af46510456fc9c39f192efc2ca9d0740a
7
+ data.tar.gz: 0f0295536d3d88e9a659cb8336df56d29c30b884c086083286d4d826a93d0fdc542e3b439ef0bb61de3851549962b544a2296ccb76df38cf9f22a61ef430a159
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --tty
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - jruby-20mode
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in llt-form_builder.gemspec
4
+ gemspec
5
+ gem 'coveralls', require: false
6
+ gem 'llt-constants', git: 'git@github.com:latin-language-toolkit/llt-constants.git'
7
+ gem 'llt-core_extensions', git: 'git@github.com:latin-language-toolkit/llt-core_extensions.git'
8
+ gem 'llt-helpers', git: 'git@github.com:latin-language-toolkit/llt-helpers.git'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 LFDM
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # LLT::FormBuilder
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'llt-form_builder'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install llt-form_builder
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.rspec_opts = '-f d --color'
6
+ end
7
+
8
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ module LLT
2
+ class Form
3
+ class Adjective < Declinable
4
+ def init_keys
5
+ super + %i{ comparatio number_of_endings comparison_sign }
6
+ end
7
+
8
+ def segmentized
9
+ unless @ending.empty? && ! @comparatio
10
+ super.chomp("-")
11
+ end
12
+ end
13
+
14
+ def segments
15
+ [@stem, @comparison_sign, @ending]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ module LLT
2
+ class Form
3
+ class Adverb < Adjective
4
+ # TODO 27.09.13 00:20 by LFDM
5
+ # Might need a simpler initialize routine than direct inheritance
6
+ # A simple adverb like semper is bloated with instance variables.
7
+
8
+ def stem
9
+ @string
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ require 'llt/helpers/roman_numerals'
2
+
3
+ module LLT
4
+ class Form
5
+ class Cardinal < Form
6
+ def initialize(args)
7
+ extract_args!(args)
8
+ end
9
+
10
+ def init_keys
11
+ %i{ roman decimal string casus sexus }
12
+ end
13
+
14
+ def arabic
15
+ @decimal
16
+ end
17
+
18
+ def to_roman
19
+ @roman || Helpers::RomanNumerals.to_roman(@decimal)
20
+ end
21
+
22
+ def to_decimal
23
+ @decimal || Helpers::RomanNumerals.to_decimal(@roman)
24
+ end
25
+
26
+ def to_s
27
+ @roman || @string
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class Conjunction < Uninflectable
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ module LLT
2
+ class Form
3
+ class Declinable < Form
4
+ require 'llt/form/noun'
5
+ require 'llt/form/adjective'
6
+ require 'llt/form/ethnic'
7
+
8
+ extend Helpers::QueryMethods
9
+
10
+ def init_keys
11
+ super + %i{ stem ending sexus casus numerus }
12
+ end
13
+
14
+ def init_functions
15
+ super + %i{ substantive }
16
+ end
17
+
18
+ def segments
19
+ [@stem, @ending]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class DemonstrativePronoun < Pronoun
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module LLT
2
+ class Form
3
+ class Ethnic < Declinable
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module LLT
2
+ class Form
3
+ class Fp < Participle
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ module LLT
2
+ class Form
3
+ class Gerund < VerbalNoun
4
+ def init_functions
5
+ super + %i{ substantive }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module LLT
2
+ class Form
3
+ class Gerundive < VerbalNoun
4
+ # Beware! The gerund is not really a substantive.
5
+ # This is basically a hack to make a Gerundive dominant
6
+ # by default.
7
+ def init_functions
8
+ super + %i{ substantive }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class IndefinitePronoun < Pronoun
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module LLT
2
+ class Form
3
+ class Infinitive < Form
4
+ def init_keys
5
+ super + %i{ stem tempus genus modus thematic ending prefix }
6
+ end
7
+
8
+ def segments
9
+ [@prefix, @stem, @thematic, @ending]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class InterrogativePronoun < Pronoun
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module LLT
2
+ class Form
3
+ class Noun < Declinable
4
+ def init_keys
5
+ super + %i{ persona place }
6
+ end
7
+
8
+ def segmentized
9
+ unless @ending.empty?
10
+ super
11
+ else
12
+ @string
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module LLT
2
+ class Form
3
+ class Participle < VerbalNoun
4
+ def init_functions
5
+ super + %i{ substantive adjective participle }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module LLT
2
+ class Form
3
+ class PersonalPronoun < Form
4
+ def init_keys
5
+ %i{ stem inflection_class casus numerus suffix index }
6
+ end
7
+
8
+ def segments
9
+ [@stem, @suffix]
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ module LLT
2
+ class Form
3
+ class Ppa < Participle
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module LLT
2
+ class Form
3
+ class Ppp < Participle
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,32 @@
1
+ module LLT
2
+ class Form
3
+ class Preposition < Uninflectable
4
+ def init_keys
5
+ %i{ string takes_4th takes_6th }
6
+ end
7
+
8
+ def valency
9
+ @valency ||= valencies
10
+ end
11
+
12
+ def needs?(arg)
13
+ valency.include?(arg)
14
+ end
15
+
16
+ def valencies
17
+ v = []
18
+ v << 4 if @takes_4th
19
+ v << 6 if @takes_6th
20
+ v
21
+ end
22
+
23
+ def takes_4th?
24
+ @takes_4th
25
+ end
26
+
27
+ def takes_6th?
28
+ @takes_6th
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module LLT
2
+ class Form
3
+ class Pronoun < Declinable
4
+ def init_keys
5
+ super + %i{ particle prefixed_particle suffix }
6
+ end
7
+
8
+ def init_functions
9
+ super + [@inflection_class]
10
+ end
11
+
12
+ def segments
13
+ [@prefixed_particle, @stem, @ending, @particle, @suffix]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class RelativePronoun < Pronoun
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module LLT
2
+ class Form
3
+ class Subjunction < Uninflectable
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module LLT
2
+ class Form
3
+ class Supinum < VerbalNoun
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,22 @@
1
+ module LLT
2
+ class Form
3
+ class Uninflectable < Form
4
+ def initialize(args)
5
+ extract_args!(args)
6
+ end
7
+
8
+ def init_keys
9
+ %i{ string }
10
+ end
11
+
12
+ def stem
13
+ @string
14
+ end
15
+ alias_method :lemma, :stem
16
+
17
+ def segments
18
+ [@string]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ module LLT
2
+ class Form
3
+ class Verb < Form
4
+ def init_keys
5
+ %i{ inflection_class stem thematic extension ending persona tempus modus genus numerus contraction prefix }
6
+ end
7
+
8
+ def init_functions
9
+ f = super
10
+ # if it has a name, it's an irregular verb
11
+ f << @inflection_class if @inflection_class.is_a?(Symbol)
12
+ f
13
+ end
14
+
15
+ def contracted?
16
+ @contraction
17
+ end
18
+
19
+ def segments
20
+ if @extension == "b"
21
+ [@prefix, @stem, @extension, @thematic, @ending]
22
+ else
23
+ [@prefix, @stem, @thematic, @extension, @ending]
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ module LLT
2
+ class Form
3
+ class VerbalNoun < Form
4
+
5
+ extend Helpers::QueryMethods
6
+
7
+ add_query_methods_for(:modus)
8
+
9
+ def init_keys
10
+ super + %i{ stem thematic extension sexus casus numerus ending modus tempus genus prefix }
11
+ end
12
+
13
+ def segments
14
+ [@prefix, @stem, @thematic, @extension, @ending]
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/llt/form.rb ADDED
@@ -0,0 +1,80 @@
1
+ require 'llt/helpers'
2
+ require 'llt/constants'
3
+
4
+ module LLT
5
+ class Form
6
+ require 'llt/form/declinable'
7
+ require 'llt/form/uninflectable'
8
+ require 'llt/form/adverb'
9
+ require 'llt/form/cardinal'
10
+ require 'llt/form/verbal_noun'
11
+ require 'llt/form/participle'
12
+ require 'llt/form/ppa'
13
+ require 'llt/form/ppp'
14
+ require 'llt/form/fp'
15
+ require 'llt/form/gerundive'
16
+ require 'llt/form/gerund'
17
+ require 'llt/form/infinitive'
18
+ require 'llt/form/pronoun'
19
+ require 'llt/form/indefinite_pronoun'
20
+ require 'llt/form/relative_pronoun'
21
+ require 'llt/form/demonstrative_pronoun'
22
+ require 'llt/form/interrogative_pronoun'
23
+ require 'llt/form/personal_pronoun'
24
+ require 'llt/form/preposition'
25
+ require 'llt/form/conjunction'
26
+ require 'llt/form/subjunction'
27
+ require 'llt/form/supinum'
28
+ require 'llt/form/verb'
29
+
30
+ include Helpers::Constantize
31
+ include Helpers::Initialize
32
+ include Helpers::Functions
33
+ include Helpers::Normalizer
34
+ include Helpers::Metrical
35
+
36
+
37
+ attr_accessor :string, :stem, :ending, :inflection_class, :casus, :numerus, :sexus,
38
+ :comparison_sign, :index, :modus, :tempus, :genus, :extension, :persona, :stems,
39
+ :particle, :place, :suffix, :prefix, :classification
40
+
41
+ def initialize(args)
42
+ extract_args!(args)
43
+ @string = args[:string] || segments.join # a custom string might be present for irregular forms
44
+ evaluate_metrical_presence(@string)
45
+ end
46
+
47
+ def init_keys
48
+ %i{ inflection_class index classification }
49
+ end
50
+
51
+ # Should be called through super by subclasses
52
+ def init_functions
53
+ [class_name_to_sym]
54
+ end
55
+
56
+ def functions
57
+ @functions ||= Set.new(init_functions)
58
+ end
59
+
60
+ def segmentized
61
+ segments.compact * "-"
62
+ end
63
+
64
+ def to_s(in_segments = false)
65
+ if in_segments
66
+ segmentized
67
+ else
68
+ @string
69
+ end
70
+ end
71
+ alias :inspect :to_s
72
+
73
+ private
74
+
75
+ def class_name_to_sym
76
+ cl_name = self.class.name.split('::').last
77
+ cl_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase.to_sym
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,86 @@
1
+ module LLT
2
+ class AdjectiveBuilder < DeclinableBuilder
3
+ builds_like_an :adjective
4
+ builds_with :comparatio
5
+
6
+ validate :comparison_sign
7
+
8
+ endings_defined_through :inflection_class, :number_of_endings, :comparatio
9
+
10
+ def init_keys
11
+ super + %i{ comparatio number_of_endings }
12
+ end
13
+
14
+ def nominatives
15
+ res = [[@nom, 1, 1]]
16
+ if @number_of_endings == 1 && @inflection_class == 3
17
+ res += [[@nom, 1, 1, :f], [@nom, 1, 1, :n]]
18
+ end
19
+ res
20
+ end
21
+
22
+ def pronominal_declension?
23
+ @inflection_class == 5 && @number_of_endings == 3
24
+ end
25
+
26
+ # having this not implemented separately in the adjective builder
27
+ # led to problems with vocatives! The infl class for detecting O
28
+ # is different here!
29
+ def regular_o_declension?
30
+ @inflection_class == 1 && @nom.to_s =~ /us$/ # to_s because it might be nil
31
+ end
32
+
33
+ def corrections(args)
34
+ extract_comparison_sign(args)
35
+ end
36
+
37
+ def extract_comparison_sign(args)
38
+ return if @comparatio == :positivus
39
+
40
+ st = args[:stem]
41
+
42
+ case @comparatio
43
+ when :comparativus
44
+ new_stem, new_comp_sign = comparativus_extraction(st, args)
45
+ when :superlativus
46
+ st.match(/(#{marker(:RIM)}|#{marker(:LIM)}|#{marker(:ISSIM)})$/)
47
+ new_stem = st.chomp($1)
48
+ new_comp_sign = $1
49
+ end
50
+
51
+ args[:stem] = new_stem
52
+ args[:comparison_sign] = new_comp_sign
53
+ end
54
+
55
+ def comparativus_extraction(stem, args)
56
+ c = args[:casus]
57
+ s = args[:sexus]
58
+ n = args[:numerus]
59
+
60
+ new_stem = stem.chomp(marker(:COMP_MF)) # do not use chomp! as other forms will get severed
61
+ raise "No comparison sign for comparative present" if new_stem == stem
62
+ [new_stem, comp_sign(c, s, n)]
63
+ end
64
+
65
+ def comp_sign(c, s, n)
66
+ if s == :n && n == 1 && c.to_s.match(/^(1|4|5)$/)
67
+ marker(:COMP_N)
68
+ else
69
+ marker(:COMP_MF)
70
+ end
71
+ end
72
+
73
+ def markers_path
74
+ path = constant_by_type(namespace: LLT::Constants::Markers)
75
+ metrical? ? path::Metrical : path
76
+ end
77
+
78
+ def marker(const)
79
+ markers_path.const_get(const)
80
+ end
81
+
82
+ def er_nominative_possible?
83
+ @inflection_class == 1
84
+ end
85
+ end
86
+ end