latinverb 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +28 -6
  4. data/README.markdown +1 -1
  5. data/Rakefile +1 -0
  6. data/latinverb.gemspec +5 -3
  7. data/lib/latinverb/components/chart_presenter.rb +81 -0
  8. data/lib/latinverb/components/classifier/strategies/defective_verb_classification_strategy.rb +19 -0
  9. data/lib/latinverb/components/classifier/strategies/deponent_verb_classification_strategy.rb +19 -0
  10. data/lib/latinverb/components/classifier/strategies/impersonal_verb_classification_strategy.rb +19 -0
  11. data/lib/latinverb/components/classifier/strategies/irregular_verb_classification_strategy.rb +19 -0
  12. data/lib/latinverb/components/classifier/strategies/present_only_verb_classification_strategy.rb +21 -0
  13. data/lib/latinverb/components/classifier/strategies/regular_verb_classification_strategy.rb +19 -0
  14. data/lib/latinverb/components/classifier/strategies/semideponent_verb_classification_strategy.rb +19 -0
  15. data/lib/latinverb/components/classifier/strategies/verb_classification_strategy.rb +31 -0
  16. data/lib/latinverb/components/classifier/strategies/very_irregular_verb_classification_strategy.rb +20 -0
  17. data/lib/latinverb/components/classifier.rb +76 -0
  18. data/lib/latinverb/components/imperatives_handler.rb +40 -0
  19. data/lib/latinverb/components/infinitivizer.rb +50 -0
  20. data/lib/latinverb/components/participler.rb +58 -0
  21. data/lib/latinverb/components/passive_infinitive_factory.rb +42 -0
  22. data/lib/latinverb/components/present_only_checker.rb +32 -0
  23. data/lib/latinverb/components/principal_parts_extractor.rb +35 -0
  24. data/lib/latinverb/components/stem_deriver.rb +81 -0
  25. data/lib/latinverb/components/type_evaluator.rb +35 -0
  26. data/lib/latinverb/components/validator.rb +33 -0
  27. data/lib/latinverb/components.rb +9 -0
  28. data/lib/latinverb/dynamic_method_resolver.rb +41 -0
  29. data/lib/latinverb/errors.rb +10 -0
  30. data/lib/latinverb/imperative_block/imperative_rule_factory.rb +35 -0
  31. data/lib/latinverb/imperative_block.rb +71 -0
  32. data/lib/latinverb/paradigmatic_verbs.rb +21 -0
  33. data/lib/latinverb/serialization/hash.rb +17 -0
  34. data/lib/latinverb/serialization/json.rb +41 -0
  35. data/lib/latinverb/serialization/yaml.rb +15 -0
  36. data/lib/latinverb/serialization.rb +3 -0
  37. data/lib/latinverb/tense_block/null_tense_block.rb +12 -0
  38. data/lib/latinverb/tense_block/vector_resolution_delegate.rb +89 -0
  39. data/lib/latinverb/tense_block.rb +52 -0
  40. data/lib/latinverb/tense_method_applicator/defective_checker.rb +21 -0
  41. data/lib/{linguistics/latin/verb/latinverb/classmethods.rb → latinverb/tense_method_applicator/deponent_string_deriver.rb} +15 -69
  42. data/lib/latinverb/tense_method_applicator/first_builder.rb +98 -0
  43. data/lib/latinverb/tense_method_applicator/fourth.rb +100 -0
  44. data/lib/latinverb/tense_method_applicator/fourth_builder.rb +100 -0
  45. data/lib/latinverb/tense_method_applicator/irregular_builder.rb +117 -0
  46. data/lib/latinverb/tense_method_applicator/mutator_for_classification_factory.rb +38 -0
  47. data/lib/latinverb/tense_method_applicator/mutator_for_verb_type.rb +38 -0
  48. data/lib/latinverb/tense_method_applicator/mutators/deponent/imperative_mutator.rb +49 -0
  49. data/lib/latinverb/tense_method_applicator/mutators/deponent/infinitive_mutator.rb +42 -0
  50. data/lib/latinverb/tense_method_applicator/mutators/deponent/participle_mutator.rb +47 -0
  51. data/lib/latinverb/tense_method_applicator/mutators/deponent/tense_block_mutator.rb +55 -0
  52. data/lib/latinverb/tense_method_applicator/mutators/deponent.rb +41 -0
  53. data/lib/latinverb/tense_method_applicator/mutators/impersonal.rb +27 -0
  54. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_imperative_mood_future_tense_strategy.rb +29 -0
  55. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_imperative_mood_present_tense_strategy.rb +29 -0
  56. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_future_tense_strategy.rb +35 -0
  57. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_futureperfect_tense_strategy.rb +28 -0
  58. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_imperfect_tense_strategy.rb +24 -0
  59. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_pastperfect_tense_strategy.rb +28 -0
  60. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_perfect_tense_strategy.rb +29 -0
  61. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_present_tense_strategy.rb +24 -0
  62. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_imperfect_tense_strategy.rb +29 -0
  63. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_pastperfect_tense_strategy.rb +30 -0
  64. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_perfect_tense_strategy.rb +30 -0
  65. data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_present_tense_strategy.rb +24 -0
  66. data/lib/latinverb/tense_method_applicator/mutators/invariant/imperatives.rb +53 -0
  67. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_future_tense_strategy.rb +24 -0
  68. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_futureperfect_tense_strategy.rb +27 -0
  69. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_imperfect_tense_strategy.rb +24 -0
  70. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_pastperfect_tense_strategy.rb +27 -0
  71. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_perfect_tense_strategy.rb +27 -0
  72. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_present_tense_strategy.rb +24 -0
  73. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_imperfect_tense_strategy.rb +30 -0
  74. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_pastperfect_tense_strategy.rb +33 -0
  75. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_perfect_tense_strategy.rb +33 -0
  76. data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_present_tense_strategy.rb +24 -0
  77. data/lib/latinverb/tense_method_applicator/mutators/invariant/triplicate_and_pluralize_formatters.rb +26 -0
  78. data/lib/latinverb/tense_method_applicator/mutators/invariant.rb +65 -0
  79. data/lib/latinverb/tense_method_applicator/mutators/irregular/infinitives_builder.rb +35 -0
  80. data/lib/latinverb/tense_method_applicator/mutators/irregular/json_deserializer.rb +52 -0
  81. data/lib/latinverb/tense_method_applicator/mutators/irregular/json_revivifier.rb +48 -0
  82. data/lib/latinverb/tense_method_applicator/mutators/irregular/participles_builder.rb +35 -0
  83. data/lib/latinverb/tense_method_applicator/mutators/irregular/present_only_irregular_mask.rb +37 -0
  84. data/lib/latinverb/tense_method_applicator/mutators/irregular.rb +25 -0
  85. data/lib/latinverb/tense_method_applicator/mutators/present_only.rb +18 -0
  86. data/lib/latinverb/tense_method_applicator/mutators/regular.rb +17 -0
  87. data/lib/latinverb/tense_method_applicator/mutators/semideponent.rb +88 -0
  88. data/lib/latinverb/tense_method_applicator/perfect_tense_remover.rb +26 -0
  89. data/lib/latinverb/tense_method_applicator/second_builder.rb +105 -0
  90. data/lib/latinverb/tense_method_applicator/tense_methods_vectorizer.rb +73 -0
  91. data/lib/latinverb/tense_method_applicator/third_builder.rb +93 -0
  92. data/lib/latinverb/tense_method_applicator/thirdio_builder.rb +100 -0
  93. data/lib/latinverb/tense_method_applicator.rb +55 -0
  94. data/lib/latinverb/version.rb +2 -3
  95. data/lib/latinverb.rb +63 -419
  96. data/test/{testDeponentFirstConjugation.rb → integration/deponent_first_conjugation_test.rb} +1 -1
  97. data/test/{testDeponentFourthConjugation.rb → integration/deponent_fourth_conjugation_test.rb} +1 -1
  98. data/test/{testDeponentSecondConjugation.rb → integration/deponent_second_conjugation_test.rb} +1 -1
  99. data/test/{testDeponentThirdConjugation.rb → integration/deponent_third_conjugation_test.rb} +2 -2
  100. data/test/{testDeponentThirdIOConjugation.rb → integration/deponent_third_io_conjugation_test.rb} +1 -1
  101. data/test/{testFirstConjugation.rb → integration/first_conjugation_test.rb} +3 -7
  102. data/test/{testFreakishVerbs.rb → integration/freakish_vs.rb_test.rb} +4 -4
  103. data/test/{testIrregularSum.rb → integration/irregular_sum_test.rb} +1 -1
  104. data/test/{testIrregulars.rb → integration/irregulars_test.rb} +1 -1
  105. data/test/{testLatinVerb.rb → integration/latin_verb_test.rb} +5 -25
  106. data/test/{testThirdConjugation.rb → integration/third_conjugation_test.rb} +19 -21
  107. data/test/unit/latinverb_accessible_reader_test.rb +18 -0
  108. data/test/unit/principal_parts_extractor_test.rb +33 -0
  109. metadata +151 -79
  110. data/lib/latinverb/chart.rb +0 -94
  111. data/lib/linguistics/latin/verb/classification_types.rb +0 -61
  112. data/lib/linguistics/latin/verb/constants.rb +0 -201
  113. data/lib/linguistics/latin/verb/deponent_tense_methods.rb +0 -85
  114. data/lib/linguistics/latin/verb/imperative_block.rb +0 -118
  115. data/lib/linguistics/latin/verb/infinitive_block.rb +0 -39
  116. data/lib/linguistics/latin/verb/infinitives.rb +0 -212
  117. data/lib/linguistics/latin/verb/irregulars.rb +0 -4393
  118. data/lib/linguistics/latin/verb/latinverb/data.rb +0 -87
  119. data/lib/linguistics/latin/verb/latinverb/defective_checker.rb +0 -17
  120. data/lib/linguistics/latin/verb/latinverb/deponent.rb +0 -159
  121. data/lib/linguistics/latin/verb/latinverb/display.rb +0 -22
  122. data/lib/linguistics/latin/verb/latinverb/impersonal.rb +0 -34
  123. data/lib/linguistics/latin/verb/latinverb/irregular.rb +0 -83
  124. data/lib/linguistics/latin/verb/latinverb/latin_verb_type_evaluator.rb +0 -32
  125. data/lib/linguistics/latin/verb/latinverb/latinverb_classifier.rb +0 -100
  126. data/lib/linguistics/latin/verb/latinverb/latinverb_input_sanitizer.rb +0 -32
  127. data/lib/linguistics/latin/verb/latinverb/latinverb_pp_extractor.rb +0 -106
  128. data/lib/linguistics/latin/verb/latinverb/metaprogramming.rb +0 -80
  129. data/lib/linguistics/latin/verb/latinverb/semideponent.rb +0 -28
  130. data/lib/linguistics/latin/verb/latinverb/validation.rb +0 -42
  131. data/lib/linguistics/latin/verb/latinverb/verbvector_description.rb +0 -50
  132. data/lib/linguistics/latin/verb/participle_block.rb +0 -36
  133. data/lib/linguistics/latin/verb/participles.rb +0 -202
  134. data/lib/linguistics/latin/verb/phonographia.rb +0 -109
  135. data/lib/linguistics/latin/verb/supine.rb +0 -42
  136. data/lib/linguistics/latin/verb/tense_block.rb +0 -227
  137. data/lib/linguistics/latin/verb/tense_definitions/first.rb +0 -92
  138. data/lib/linguistics/latin/verb/tense_definitions/fourth.rb +0 -92
  139. data/lib/linguistics/latin/verb/tense_definitions/impersonal.rb +0 -25
  140. data/lib/linguistics/latin/verb/tense_definitions/invariant.rb +0 -613
  141. data/lib/linguistics/latin/verb/tense_definitions/irregular.rb +0 -82
  142. data/lib/linguistics/latin/verb/tense_definitions/second.rb +0 -97
  143. data/lib/linguistics/latin/verb/tense_definitions/third.rb +0 -86
  144. data/lib/linguistics/latin/verb/tense_definitions/third_io.rb +0 -91
  145. data/test/testDeserializeInfinitives.rb +0 -36
  146. /data/test/{testAmbiguousLookups.rb → integration/ambiguous_lookups_test.rb} +0 -0
  147. /data/test/{testClusterResolution.rb → integration/cluster_resolution_test.rb} +0 -0
  148. /data/test/{testDataStructures.rb → integration/data_structures_test.rb} +0 -0
  149. /data/test/{testDefectSemiImp.rb → integration/defect_semi_imp_test.rb} +0 -0
  150. /data/test/{testFourthConjugation.rb → integration/fourth_conjugation_test.rb} +0 -0
  151. /data/test/{testImperativeBlock.rb → integration/imperative_block_test.rb} +0 -0
  152. /data/test/{testMacronRules.rb → integration/macron_rules_test.rb} +0 -0
  153. /data/test/{testSecondConjugation.rb → integration/second_conjugation_test.rb} +0 -0
  154. /data/test/{testThirdIOConjugation.rb → integration/third_io_conjugation_test.rb} +0 -0
@@ -1,12 +1,8 @@
1
- # encoding: UTF-8
2
-
3
1
  module Linguistics
4
2
  module Latin
5
3
  module Verb
6
4
  class LatinVerb
7
-
8
- class << self
9
-
5
+ class DeponentStringDeriver
10
6
  ##
11
7
  #
12
8
  # Deponent verbs can be conceived as being the <em>the passive</em> results of
@@ -36,8 +32,18 @@ module Linguistics
36
32
  # A pseudo-mapped, four principal-part string
37
33
  #
38
34
  ##
39
- def create_pseudo_active_mask_for_deponent(s)
40
- parts = s.split( /\s+/ )
35
+
36
+ attr_reader :proxy_string
37
+
38
+ def initialize(s)
39
+ @original_string = s
40
+ @proxy_string = create_pseudo_active_mask_for_deponent
41
+ end
42
+
43
+ private
44
+
45
+ def create_pseudo_active_mask_for_deponent
46
+ parts = @original_string.split( /\s+/ )
41
47
 
42
48
  # Turn the passive form into something that looks active
43
49
  parts[0].sub!( /or$/, 'ō' )
@@ -49,6 +55,7 @@ module Linguistics
49
55
  # Applying the first's rule to the second results in 'seque' not
50
56
  # 'sequere'. Ergo the conditional.
51
57
  #
58
+ parts[1] ||= ""
52
59
  parts[1].sub!( /ī$/, 'e' )
53
60
 
54
61
  # Fixes sequī -> sequere
@@ -58,6 +65,7 @@ module Linguistics
58
65
  parts[3] = parts[2]
59
66
 
60
67
  # Another modification for third conjugation deponents
68
+ parts[3] ||= ""
61
69
  parts[3].sub!( /us$/, 'um' )
62
70
 
63
71
  # This value shouldn't be used
@@ -65,70 +73,8 @@ module Linguistics
65
73
 
66
74
  parts.join(' ')
67
75
  end
68
-
69
- ##
70
- #
71
- # == ARGUMENTS
72
- #
73
- # * present_active_infinitive
74
- #
75
- # == RETURNS
76
- #
77
- # The “stem” of a Latin Verb
78
- #
79
- # == PURPOSE
80
- #
81
- # Based on the present active infinitive, identify the “stem” and set the +@stem+
82
- # iVar. The method also returns the stem value.
83
- #
84
- ##
85
-
86
- ##
87
- #
88
- # == ARGUMENTS
89
- #
90
- # * first_person_singular
91
- # * present_active_infinitive
92
- #
93
- # == RETURNS
94
- #
95
- # The participial “stem” of a Latin Verb, used for participle
96
- # formation
97
- #
98
- # == PURPOSE
99
- #
100
- # Calculate the participial stem, used in forming participles.
101
- #
102
- ##
103
- def calculate_participial_stem(first_person_singular, present_active_infinitive)
104
- raise("present_active_infinitive was nil![#{first_person_singular} and #{present_active_infinitive}]") if
105
- present_active_infinitive.empty? or first_person_singular.empty?
106
-
107
- if present_active_infinitive.to_s =~ /(.*ā)re$/
108
- return $1
109
- end
110
-
111
- if present_active_infinitive.to_s =~ /(.*ē)re$/
112
- return $1
113
- end
114
-
115
- if present_active_infinitive.to_s =~ /(.*)ere$/
116
- match=$1
117
- if first_person_singular =~ /iō/
118
- return match + "iē"
119
- else
120
- return match + "e"
121
- end
122
- end
123
-
124
- if present_active_infinitive.to_s =~ /(.*)īre$/
125
- return $1 + "iē"
126
- end
127
- end
128
-
129
76
  end
130
77
  end
131
78
  end
132
79
  end
133
80
  end
134
-
@@ -0,0 +1,98 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class TenseMethodApplicator
6
+ class MutatorForVerbType
7
+ class FirstBuilder
8
+ def initialize(verb)
9
+ @verb = verb
10
+ end
11
+
12
+ def build!
13
+ @verb.instance_eval do
14
+ def active_voice_indicative_mood_future_tense
15
+ return TenseBlock.new(
16
+ [AF_ONE_TWO_ENDINGS.collect{|x| stem + x}].flatten,
17
+ { :meaning => MEANINGS[:active_voice_indicative_mood_future_tense] }
18
+ )
19
+ end
20
+
21
+ def active_voice_indicative_mood_imperfect_tense
22
+ return TenseBlock.new(
23
+ [AI_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS.collect{|x| stem + x}].flatten,
24
+ { :meaning => MEANINGS[:active_voice_indicative_mood_imperfect_tense] }
25
+ )
26
+ end
27
+
28
+ def active_voice_indicative_mood_present_tense
29
+ return TenseBlock.new(
30
+ [ first_person_singular, AP_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS.collect{ |ending| stem + ending} ].flatten,
31
+ { :meaning => MEANINGS[:active_voice_indicative_mood_present_tense] }
32
+ )
33
+ end
34
+
35
+ def active_voice_subjunctive_mood_present_tense
36
+ key = verb_type.ordinal_name_key
37
+ asp_base = stem[0..-2] + ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS[key]
38
+ endings_coll = ['m', AP_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS].flatten!
39
+ collection = endings_coll.map{ |ending| asp_base + ending }
40
+ TenseBlock.new(
41
+ collection,
42
+ { :meaning => Linguistics::Latin::Verb::MEANINGS[:active_voice_subjunctive_mood_present_tense] }
43
+ )
44
+ end
45
+
46
+ def passive_voice_indicative_mood_future_tense
47
+ fp_stem = stem + "bi"
48
+ standards = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[2..-1].map{|x| fp_stem + x}
49
+ standards.pop
50
+ fp_stem.sub!(/.$/,'u')
51
+ collection =
52
+ [ stem + "b\xc5\x8dr",
53
+ stem + "beris",
54
+ standards,
55
+ fp_stem + PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.last].flatten!
56
+
57
+ TenseBlock.new(
58
+ collection,
59
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_future_tense] }
60
+ )
61
+ end
62
+
63
+ def passive_voice_indicative_mood_imperfect_tense
64
+ imperfect_stem = stem + "b\xc4\x81"
65
+ collection = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map{|x| imperfect_stem + x}
66
+ return TenseBlock.new(
67
+ collection,
68
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_imperfect_tense] }
69
+ )
70
+ end
71
+
72
+ def passive_voice_indicative_mood_present_tense
73
+ local_pe = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.clone
74
+ collection = [first_person_singular.to_s + "r", local_pe[1..-1].map{|x| stem + x}].flatten
75
+ return TenseBlock.new(
76
+ collection,
77
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_present_tense] }
78
+ )
79
+ end
80
+
81
+ def passive_voice_subjunctive_mood_present_tense
82
+ key = verb_type.ordinal_name_key
83
+ short_base = stem[0..-2] + ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS[key]
84
+ collection = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map { |ending| short_base + ending }
85
+ TenseBlock.new(
86
+ collection,
87
+ { :meaning => MEANINGS[:passive_voice_subjunctive_mood_present_tense] }
88
+ )
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,100 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class TenseMethodApplicator
6
+ class MutatorForVerbType
7
+ class ThirdIOBuilder
8
+ def initialize(verb)
9
+ @verb = verb
10
+ end
11
+
12
+ def build!
13
+ @verb.instance_eval do
14
+ def active_voice_indicative_mood_future_tense
15
+ return TenseBlock.new(
16
+ [AF_OTHER_ENDINGS.collect{|x| stem + "i" + x}].flatten,
17
+ { :meaning => MEANINGS[:active_voice_indicative_mood_future_tense] }
18
+ )
19
+ end
20
+
21
+ def active_voice_indicative_mood_imperfect_tense
22
+ return TenseBlock.new(
23
+ [AI_THIRD_CONJUG_PERS_ENDINGS.collect do |x|
24
+ stem + "i" + x end ].flatten!,
25
+ { :meaning => MEANINGS[:active_voice_indicative_mood_imperfect_tense] }
26
+ )
27
+ end
28
+
29
+ def active_voice_indicative_mood_present_tense
30
+ return TenseBlock.new(
31
+ [ first_person_singular,
32
+ AP_THIRDIO_CONJG_PERS_ENDINGS.collect{ |ending| stem + ending }
33
+ ].flatten!,
34
+ { :meaning => MEANINGS[:active_voice_indicative_mood_present_tense] }
35
+ )
36
+ end
37
+
38
+ def active_voice_subjunctive_mood_present_tense
39
+ key = verb_type.ordinal_name_key
40
+ asp_base = stem[0..-1] + ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS[key]
41
+ elems = ['m',
42
+ AP_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS].flatten!.map do |ending|
43
+ asp_base + ending
44
+ end
45
+
46
+ TenseBlock.new(
47
+ elems,
48
+ { :meaning => MEANINGS[:active_voice_subjunctive_mood_present_tense] }
49
+ )
50
+ end
51
+
52
+ def passive_voice_indicative_mood_future_tense
53
+ ie_base = stem + "iē"
54
+ elems = [stem + "ia" + PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[0],
55
+ PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[1..-1].map{|x| ie_base + x}].flatten!
56
+ TenseBlock.new(
57
+ elems,
58
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_future_tense] }
59
+ )
60
+ end
61
+
62
+ def passive_voice_indicative_mood_imperfect_tense
63
+ base = stem + "iēbā"
64
+ elems = [PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map{|x| base + x}].flatten!
65
+ return TenseBlock.new(
66
+ elems,
67
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_imperfect_tense] }
68
+ )
69
+ end
70
+
71
+ def passive_voice_indicative_mood_present_tense
72
+ base = stem + "ī"
73
+ elems = [first_person_singular + "r",
74
+ PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[1..-2].map{|x| base + x},
75
+ base + PASSIVE_ENDINGS_OTHER[-1]].flatten!
76
+ return TenseBlock.new(
77
+ elems,
78
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_present_tense] }
79
+ )
80
+ end
81
+
82
+ def passive_voice_subjunctive_mood_present_tense
83
+ subjunctive_stem = stem + "iā"
84
+ elems = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map do |ending|
85
+ subjunctive_stem + ending
86
+ end
87
+ TenseBlock.new(
88
+ elems,
89
+ { :meaning => MEANINGS[:passive_voice_subjunctive_mood_present_tense] }
90
+ )
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,100 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class TenseMethodApplicator
6
+ class MutatorForVerbType
7
+ class FourthBuilder
8
+ def initialize(verb)
9
+ @verb = verb
10
+ end
11
+
12
+ def build!
13
+ @verb.instance_eval do
14
+ def active_voice_indicative_mood_future_tense
15
+ return TenseBlock.new(
16
+ [AF_OTHER_ENDINGS.collect{|x| stem + "i" + x}].flatten,
17
+ { :meaning => MEANINGS[:active_voice_indicative_mood_future_tense] }
18
+ )
19
+ end
20
+
21
+ def active_voice_indicative_mood_imperfect_tense
22
+ return TenseBlock.new(
23
+ [AI_THIRD_CONJUG_PERS_ENDINGS.collect do |x|
24
+ stem + "i" + x end ].flatten,
25
+ { :meaning => MEANINGS[:active_voice_indicative_mood_imperfect_tense] }
26
+ )
27
+ end
28
+
29
+ def active_voice_indicative_mood_present_tense
30
+ return TenseBlock.new(
31
+ [ first_person_singular,
32
+ AP_THIRDIO_CONJG_PERS_ENDINGS.collect{ |ending| stem + ending }
33
+ ].flatten,
34
+ { :meaning => MEANINGS[:active_voice_indicative_mood_present_tense] }
35
+ )
36
+ end
37
+
38
+ def active_voice_subjunctive_mood_present_tense
39
+ key = verb_type.ordinal_name_key
40
+ asp_base = stem[0..-1] + ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS[key]
41
+ collection = ['m',
42
+ AP_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS].flatten.map do |ending|
43
+ asp_base + ending
44
+ end
45
+
46
+ TenseBlock.new(
47
+ collection,
48
+ { :meaning => MEANINGS[:active_voice_subjunctive_mood_present_tense] }
49
+ )
50
+ end
51
+
52
+ def passive_voice_indicative_mood_future_tense
53
+ ie_base = stem + "iē"
54
+ collection = [stem + "ia" + PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[0],
55
+ PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[1..-1].map{|x| ie_base + x}].flatten
56
+ TenseBlock.new(
57
+ collection,
58
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_future_tense] }
59
+ )
60
+ end
61
+
62
+ def passive_voice_indicative_mood_imperfect_tense
63
+ base = stem + "iēbā"
64
+ collection = [PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map{|x| base + x}].flatten
65
+ return TenseBlock.new(
66
+ collection,
67
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_imperfect_tense] }
68
+ )
69
+ end
70
+
71
+ def passive_voice_indicative_mood_present_tense
72
+ base = stem + "ī"
73
+ collection = [first_person_singular + "r",
74
+ PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG[1..-2].map{|x| base + x},
75
+ base + PASSIVE_ENDINGS_OTHER[-1]].flatten
76
+ return TenseBlock.new(
77
+ collection,
78
+ { :meaning => MEANINGS[:passive_voice_indicative_mood_present_tense] }
79
+ )
80
+ end
81
+
82
+ def passive_voice_subjunctive_mood_present_tense
83
+ subjunctive_stem = stem + "iā"
84
+ collection = PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG.map do |ending|
85
+ subjunctive_stem + ending
86
+ end
87
+ TenseBlock.new(
88
+ collection,
89
+ { :meaning => MEANINGS[:passive_voice_subjunctive_mood_present_tense] }
90
+ )
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,117 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ class TenseMethodApplicator
6
+ class MutatorForVerbType
7
+ class IrregularBuilder
8
+ extend Forwardable
9
+ def_delegators :@verb, :original_string, :classified_as
10
+
11
+ def initialize(verb)
12
+ @verb = verb
13
+ end
14
+
15
+ def build!
16
+ if classified_as.impersonal?
17
+ impersonal_builder
18
+ else
19
+ irregular_from_stored_definition
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def impersonal_builder
26
+ @verb.instance_eval do
27
+ def active_voice_indicative_mood_present_tense
28
+ TenseBlock.new ["", "", @original_string,
29
+ "", "", ""]
30
+ end
31
+
32
+ def active_voice_indicative_mood_present_tense_third_person_singular_number
33
+ return active_voice_indicative_mood_present_tense[2]
34
+ end
35
+ end
36
+ end
37
+
38
+ def irregular_from_stored_definition
39
+ validate(serialized_verb = find_serialized_irregular_verb)
40
+ revivify!(serialized_verb)
41
+
42
+ rescue => error
43
+ warn "#{original_string} was identified as irregular but did not have a definition provided."
44
+ raise error
45
+ end
46
+
47
+ def find_serialized_irregular_verb
48
+ Linguistics::Latin::Verb.const_get(serialized_irregular_verb_lookup_key)
49
+ rescue NameError => e
50
+ puts "Unable to find a definition for #{original_string}. Please provide one."
51
+ raise e
52
+ end
53
+
54
+
55
+ def validate(serialized_verb)
56
+ raise "Found a JSON string with null length!" if serialized_verb.length <= 10
57
+ end
58
+
59
+ def revivify!(serialized_verb)
60
+ revivified_data_structure = JSON.load(serialized_verb)
61
+ revivified_data_structure['tense_blocks'].each_pair do |k,v|
62
+ singleton_class.class_eval do
63
+ define_method k.to_sym do
64
+ TenseBlock.new v, { :meaning => MEANINGS[k.to_sym] }
65
+ end
66
+ end
67
+ end
68
+
69
+ @verb.instance_eval do
70
+ irregular_infinitives = revivified_data_structure['infinitives']
71
+ irregular_participles = revivified_data_structure['participles']
72
+ end
73
+
74
+ return if @irregular_infinitives.nil?
75
+ return if @irregular_participles.nil?
76
+
77
+ @verb.instance_eval do
78
+ def present_active_infinitive; return @irregular_infinitives.present_active_infinitive; end
79
+ def present_passive_infinitive; return @irregular_infinitives.present_passive_infinitive; end
80
+ def perfect_active_infinitive; return @irregular_infinitives.perfect_active_infinitive; end
81
+ def perfect_passive_infinitive; return @irregular_infinitives.perfect_passive_infinitive; end
82
+ def future_passive_infinitive; return @irregular_infinitives.future_passive_infinitive; end
83
+ def future_active_infinitive; return @irregular_infinitives.future_active_infinitive; end
84
+ end
85
+
86
+ @verb.instance_eval do
87
+ def present_active_participle; return @irregular_participles.present_active_participle; end
88
+ def future_active_participle; return @irregular_participles.future_active_participle; end
89
+ def perfect_passive_participle; return @irregular_participles.perfect_passive_participle; end
90
+ def future_passive_participle; return @irregular_participles.future_passive_participle; end
91
+ def gerundive; return @irregular_participles.gerundive; end
92
+ def gerund; return @irregular_participles.d; end
93
+ end
94
+
95
+ rescue JSON::ParserError => e
96
+ puts "Unable to parse JSON for #{original_string} [o:#{o}] [o_sym:#{o_upcase_and_symbolic}]. Please verify your syntax."
97
+ raise e
98
+ end
99
+
100
+ def serialized_irregular_verb_lookup_key
101
+ o = ActiveSupport::Multibyte::Chars.new( original_string.gsub(/\s+/,'_') ).upcase
102
+
103
+ if o.match(/^([ĀĒĪŌŪ])(.*)/)
104
+ x = o[0,1].tr 'ĀĒĪŌŪ', 'AEIOU'
105
+ y = o[1,o.length]
106
+ o = x + y
107
+ end
108
+
109
+ o.to_sym
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,38 @@
1
+ require_relative './mutator_for_verb_type'
2
+ require_relative './mutators/deponent'
3
+ require_relative './mutators/impersonal'
4
+ require_relative './mutators/invariant'
5
+ require_relative './mutators/irregular'
6
+ require_relative './mutators/present_only'
7
+ require_relative './mutators/regular'
8
+ require_relative './mutators/semideponent'
9
+
10
+ module Linguistics
11
+ module Latin
12
+ module Verb
13
+ class LatinVerb
14
+ class TenseMethodApplicator
15
+ class MutatorForClassificationFactory
16
+ MAPPING = {
17
+ Impersonal: Mutators::Impersonal,
18
+ PresentOnly: Mutators::PresentOnly,
19
+ Irregular: Mutators::Irregular,
20
+ Deponent: Mutators::Deponent,
21
+ Semideponent: Mutators::Semideponent,
22
+ Regular: Mutators::Regular
23
+ }
24
+
25
+ def initialize(verb)
26
+ @verb = verb
27
+ @classification = verb.classification
28
+ end
29
+
30
+ def mutator
31
+ MAPPING[@classification.short_name_key].new(@verb)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require_relative './first_builder'
2
+ require_relative './second_builder'
3
+ require_relative './third_builder'
4
+ require_relative './thirdio_builder'
5
+ require_relative './fourth_builder'
6
+ require_relative './irregular_builder'
7
+
8
+ module Linguistics
9
+ module Latin
10
+ module Verb
11
+ class LatinVerb
12
+ class TenseMethodApplicator
13
+ class MutatorForVerbType
14
+ extend Forwardable
15
+ def_delegators :@verb, :verb_type
16
+
17
+ MAPPING = {
18
+ First: FirstBuilder,
19
+ Second: SecondBuilder,
20
+ ThirdIO: ThirdIOBuilder,
21
+ Third: ThirdBuilder,
22
+ Fourth: FourthBuilder,
23
+ Irregular: IrregularBuilder
24
+ }
25
+
26
+ def initialize(verb)
27
+ @verb = verb
28
+ end
29
+
30
+ def mutate!
31
+ MAPPING[verb_type.ordinal_name_key].new(@verb).build!
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,49 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ module Mutators
6
+ class Deponent
7
+ class ImperativeMutator
8
+ def initialize(verb, proxyVerb)
9
+ @verb =verb
10
+ @proxyVerb = proxyVerb
11
+ mutate!
12
+ end
13
+
14
+ ##
15
+ #
16
+ # The deponent's imperatives require a bit of consideration. They don't
17
+ # follow the stem/stem+'ite' format.
18
+ #
19
+ ##
20
+
21
+ def mutate!
22
+ proxyVerb = @proxyVerb
23
+ @verb.instance_eval do
24
+ extend Linguistics::Latin::Phonographia
25
+ @proxyVerb = proxyVerb
26
+
27
+ def active_voice_imperative_mood_present_tense_second_person_singular_number
28
+ @proxyVerb.send(:present_active_infinitive)
29
+ end
30
+
31
+ def active_voice_imperative_mood_present_tense_second_person_plural_number
32
+ return @proxyVerb.send :passive_voice_indicative_mood_present_tense_second_person_plural_number
33
+ end
34
+
35
+ def active_voice_imperative_mood_future_tense_second_person_singular_number
36
+ k = @proxyVerb.send :passive_voice_indicative_mood_present_tense_second_person_plural_number
37
+ k.sub!(/minī$/, '')
38
+ k += 'tor'
39
+ fix_macrons k
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end