latinverb 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/Gemfile +4 -1
  2. data/Gemfile.lock +24 -0
  3. data/Guardfile +10 -0
  4. data/README.markdown +1 -1
  5. data/Rakefile +12 -9
  6. data/latinverb.gemspec +4 -0
  7. data/lib/latinverb/chart.rb +5 -5
  8. data/lib/latinverb/version.rb +1 -1
  9. data/lib/latinverb.rb +266 -534
  10. data/lib/linguistics/latin/verb/classification_types.rb +19 -17
  11. data/lib/linguistics/latin/verb/constants.rb +14 -14
  12. data/lib/linguistics/latin/verb/deponent_tense_methods.rb +8 -21
  13. data/lib/linguistics/latin/verb/imperative_block.rb +118 -0
  14. data/lib/linguistics/latin/verb/infinitive_block.rb +39 -0
  15. data/lib/linguistics/latin/verb/infinitives.rb +181 -181
  16. data/lib/linguistics/latin/verb/irregulars.rb +74 -74
  17. data/lib/linguistics/latin/verb/latinverb/classmethods.rb +36 -117
  18. data/lib/linguistics/latin/verb/latinverb/data.rb +12 -15
  19. data/lib/linguistics/latin/verb/latinverb/defective_checker.rb +17 -0
  20. data/lib/linguistics/latin/verb/latinverb/deponent.rb +159 -0
  21. data/lib/linguistics/latin/verb/latinverb/display.rb +1 -2
  22. data/lib/linguistics/latin/verb/latinverb/impersonal.rb +34 -0
  23. data/lib/linguistics/latin/verb/latinverb/irregular.rb +83 -0
  24. data/lib/linguistics/latin/verb/latinverb/latin_verb_type_evaluator.rb +32 -0
  25. data/lib/linguistics/latin/verb/latinverb/latinverb_classifier.rb +100 -0
  26. data/lib/linguistics/latin/verb/latinverb/latinverb_input_sanitizer.rb +32 -0
  27. data/lib/linguistics/latin/verb/latinverb/latinverb_pp_extractor.rb +106 -0
  28. data/lib/linguistics/latin/verb/latinverb/metaprogramming.rb +30 -29
  29. data/lib/linguistics/latin/verb/latinverb/semideponent.rb +28 -0
  30. data/lib/linguistics/latin/verb/latinverb/validation.rb +5 -29
  31. data/lib/linguistics/latin/verb/latinverb/verbvector_description.rb +50 -0
  32. data/lib/linguistics/latin/verb/participle_block.rb +36 -0
  33. data/lib/linguistics/latin/verb/participles.rb +25 -25
  34. data/lib/linguistics/latin/verb/phonographia.rb +51 -51
  35. data/lib/linguistics/latin/verb/supine.rb +6 -6
  36. data/lib/linguistics/latin/verb/tense_block.rb +227 -0
  37. data/lib/linguistics/latin/verb/tense_definitions/first.rb +92 -0
  38. data/lib/linguistics/latin/verb/tense_definitions/fourth.rb +92 -0
  39. data/lib/linguistics/latin/verb/tense_definitions/impersonal.rb +25 -0
  40. data/lib/linguistics/latin/verb/tense_definitions/invariant.rb +613 -0
  41. data/lib/linguistics/latin/verb/tense_definitions/irregular.rb +82 -0
  42. data/lib/linguistics/latin/verb/tense_definitions/second.rb +97 -0
  43. data/lib/linguistics/latin/verb/tense_definitions/third.rb +86 -0
  44. data/lib/linguistics/latin/verb/tense_definitions/third_io.rb +91 -0
  45. data/test/testClusterResolution.rb +0 -1
  46. data/test/testDataStructures.rb +8 -5
  47. data/test/testDefectSemiImp.rb +9 -10
  48. data/test/testDeponentFirstConjugation.rb +2 -2
  49. data/test/testDeponentFourthConjugation.rb +2 -2
  50. data/test/testDeponentSecondConjugation.rb +2 -2
  51. data/test/testDeponentThirdConjugation.rb +2 -2
  52. data/test/testDeponentThirdIOConjugation.rb +2 -2
  53. data/test/testDeserializeInfinitives.rb +2 -4
  54. data/test/testFirstConjugation.rb +53 -53
  55. data/test/testFourthConjugation.rb +11 -11
  56. data/test/testFreakishVerbs.rb +12 -11
  57. data/test/testIrregulars.rb +24 -23
  58. data/test/testLatinVerb.rb +46 -55
  59. data/test/testSecondConjugation.rb +27 -27
  60. data/test/testThirdConjugation.rb +14 -14
  61. data/test/testThirdIOConjugation.rb +13 -13
  62. metadata +95 -53
  63. data/lib/linguistics/latin/verb/latinverb/auxiliary_classes.rb +0 -208
  64. data/lib/linguistics/latin/verb/tense_methods.rb +0 -950
@@ -7,7 +7,7 @@ module Linguistics
7
7
 
8
8
  class << self
9
9
 
10
- ##
10
+ ##
11
11
  #
12
12
  # Deponent verbs can be conceived as being the <em>the passive</em> results of
13
13
  # a regular verb where the passive form's result is then applied to the active
@@ -37,10 +37,10 @@ module Linguistics
37
37
  #
38
38
  ##
39
39
  def create_pseudo_active_mask_for_deponent(s)
40
- parts = s.split /\s+/
40
+ parts = s.split( /\s+/ )
41
41
 
42
42
  # Turn the passive form into something that looks active
43
- parts[0].sub! /or$/, 'ō'
43
+ parts[0].sub!( /or$/, 'ō' )
44
44
 
45
45
  # Turn the passive infinitive into something that looks active.
46
46
  # There's a subtle difference between:
@@ -49,160 +49,79 @@ module Linguistics
49
49
  # Applying the first's rule to the second results in 'seque' not
50
50
  # 'sequere'. Ergo the conditional.
51
51
  #
52
- parts[1].sub! /ī$/, 'e'
52
+ parts[1].sub!( /ī$/, 'e' )
53
53
 
54
54
  # Fixes sequī -> sequere
55
55
  parts[1] += 're' unless parts[1] =~ /[āīē]re/
56
56
 
57
57
  # Set the 4th part to the value in the 3rd slot
58
58
  parts[3] = parts[2]
59
-
59
+
60
60
  # Another modification for third conjugation deponents
61
- parts[3].sub! /us$/, 'um'
61
+ parts[3].sub!( /us$/, 'um' )
62
62
 
63
- # This value shouldn't be used...(I don't think...)
64
- parts[2] = "JUNK" #
63
+ # This value shouldn't be used
64
+ parts[2] = "PreventDeponentInfiniteRegress"
65
65
 
66
66
  parts.join(' ')
67
67
  end
68
- ##
69
- #
70
- # == ARGUMENTS
71
- #
72
- # * s :: a "four principal parts" string whence can be derived
73
- # the first person singular present indicative as well as the
74
- # infinitive
75
- #
76
- # == RETURNS
77
- #
78
- # The classification, a subclass of VerbType
79
- #
80
- # == PURPOSE
81
- #
82
- # Given the principal parts as a string, decide which conjuation is
83
- # in play
84
- #
85
- #
86
- ##
87
- def classify(s)
88
-
89
- if s.class == String
90
- divided_string = s.split /\s+/
91
-
92
- first_pres = divided_string[0]
93
- infinitive = divided_string[1]
94
-
95
- return Linguistics::Latin::Verb::VerbTypes::Defective if
96
- Linguistics::Latin::Verb::LatinVerb::DEFECTIVE_VERBS.member? first_pres
97
-
98
- return Linguistics::Latin::Verb::VerbTypes::Irregular if
99
- Linguistics::Latin::Verb::LatinVerb::IRREGULAR_VERBS.member? first_pres
100
-
101
- return Linguistics::Latin::Verb::VerbTypes::Semideponent if
102
- ( Linguistics::Latin::Verb::LatinVerb::SEMI_DEPONENTS.keys.any?{ |k| first_pres=~/#{k}$/} and
103
- s !~ /JUNK/ )
104
-
105
- return Linguistics::Latin::Verb::VerbTypes::Impersonal if
106
- Linguistics::Latin::Verb::LatinVerb::IMPERSONAL_VERBS.member? s
107
-
108
- if infinitive =~ /āre$/
109
- return Linguistics::Latin::Verb::VerbTypes::First
110
- elsif infinitive =~ /ēre$/
111
- return Linguistics::Latin::Verb::VerbTypes::Second
112
- elsif infinitive =~ /ere$/
113
- if first_pres =~ /i.$/
114
- return Linguistics::Latin::Verb::VerbTypes::ThirdIO
115
- else
116
- return Linguistics::Latin::Verb::VerbTypes::Third
117
- end
118
- elsif infinitive =~ /.+īre$/
119
- return Linguistics::Latin::Verb::VerbTypes::Fourth
120
- elsif (infinitive =~ /ī$/ and first_pres =~ /r$/)
121
- return Linguistics::Latin::Verb::VerbTypes::Deponent
122
- # Very irregular irregulars, A&G206, e/f
123
- elsif s =~ %r'^(aiō|quaesō|ovāre)$'
124
- return Linguistics::Latin::Verb::VerbTypes::Irregular
125
- else
126
- raise "Could not find a verb type for this verb #{infinitive} and #{first_pres}"
127
- end
128
- end
129
- end
130
68
 
131
69
  ##
132
- #
70
+ #
133
71
  # == ARGUMENTS
134
- #
135
- # * pres_act_inf
136
- #
137
- # == RETURNS
138
- #
72
+ #
73
+ # * present_active_infinitive
74
+ #
75
+ # == RETURNS
76
+ #
139
77
  # The “stem” of a Latin Verb
140
- #
141
- # == PURPOSE
142
- #
78
+ #
79
+ # == PURPOSE
80
+ #
143
81
  # Based on the present active infinitive, identify the “stem” and set the +@stem+
144
82
  # iVar. The method also returns the stem value.
145
- #
83
+ #
146
84
  ##
147
- def calculate_stem(pres_act_inf)
148
- # TODO: For efficiency, if the iVar @stem is defined, don't go through this structure?
149
- if pres_act_inf =~ /āre$/
150
- return pres_act_inf.gsub(/(.*)āre$/,'\\1ā')
151
- end
152
- if pres_act_inf =~ /ēre$/
153
- return pres_act_inf.gsub(/(.*)ēre$/,'\\1ē')
154
- end
155
- if pres_act_inf =~ /ere$/
156
- if @first_pers_singular =~ /iō$/
157
- return pres_act_inf.gsub(/(.*)ere$/,'\\1')
158
- else
159
- return pres_act_inf.gsub(/(.*)ere$/,'\\1')
160
- end
161
- end
162
- if pres_act_inf =~ /īre$/
163
- return pres_act_inf.gsub(/(.*)īre$/,'\\1')
164
- end
165
- end
166
85
 
167
86
  ##
168
- #
87
+ #
169
88
  # == ARGUMENTS
170
- #
89
+ #
171
90
  # * first_person_singular
172
- # * pres_act_inf
173
- #
174
- # == RETURNS
175
- #
91
+ # * present_active_infinitive
92
+ #
93
+ # == RETURNS
94
+ #
176
95
  # The participial “stem” of a Latin Verb, used for participle
177
96
  # formation
178
- #
179
- # == PURPOSE
180
- #
97
+ #
98
+ # == PURPOSE
99
+ #
181
100
  # Calculate the participial stem, used in forming participles.
182
- #
101
+ #
183
102
  ##
184
- def calculate_participial_stem(first_pers_singular, pres_act_inf)
185
- raise("pres_act_inf was nil![#{first_pers_singular} and #{pres_act_inf}]") if
186
- pres_act_inf.empty? or first_pers_singular.empty?
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?
187
106
 
188
- if pres_act_inf.to_s =~ /(.*ā)re$/
107
+ if present_active_infinitive.to_s =~ /(.*ā)re$/
189
108
  return $1
190
109
  end
191
110
 
192
- if pres_act_inf.to_s =~ /(.*ē)re$/
111
+ if present_active_infinitive.to_s =~ /(.*ē)re$/
193
112
  return $1
194
113
  end
195
114
 
196
- if pres_act_inf.to_s =~ /(.*)ere$/
115
+ if present_active_infinitive.to_s =~ /(.*)ere$/
197
116
  match=$1
198
- if first_pers_singular =~ /iō/
117
+ if first_person_singular =~ /iō/
199
118
  return match + "iē"
200
119
  else
201
120
  return match + "e"
202
121
  end
203
122
  end
204
123
 
205
- if pres_act_inf.to_s =~ /(.*)īre$/
124
+ if present_active_infinitive.to_s =~ /(.*)īre$/
206
125
  return $1 + "iē"
207
126
  end
208
127
  end
@@ -1,6 +1,4 @@
1
1
  # encoding: UTF-8
2
- require 'json'
3
-
4
2
  module Linguistics
5
3
  module Latin
6
4
  module Verb
@@ -13,21 +11,22 @@ module Linguistics
13
11
  def self.json_create(o)
14
12
  new( o )
15
13
  end
16
-
17
- ##
14
+
15
+ ##
18
16
  #
19
17
  # Presents the LatinVerb expressed as a hash with the names of the TenseBlock
20
18
  # specifiers as keys, and corresponding TenseBlock objects, converted to
21
19
  # Arrays, as the values. It also contains the +original_string+.
22
20
  #
23
21
  ##
24
- def to_hash
22
+ def to_hash
23
+ data_structure = {}
25
24
  @tense_list.each do |t|
26
25
  ts = t.to_sym
27
- @data_structure[ts]=self.send ts
26
+ data_structure[ts]=self.send ts
28
27
  end
29
- @data_structure['original_string'] = @original_string
30
- return @data_structure
28
+ data_structure['original_string'] = @original_string
29
+ return data_structure
31
30
  end
32
31
 
33
32
  alias_method :to_h, :to_hash
@@ -37,11 +36,9 @@ module Linguistics
37
36
  # Takes the hash that results from to_hash and then converts it to
38
37
  # YAML.
39
38
  #
40
- ##
39
+ ##
41
40
  def to_yaml
42
- @data_structure.empty? ?
43
- to_hash.to_yaml:
44
- @data_structure.to_yaml
41
+ to_hash.to_yaml
45
42
  end
46
43
 
47
44
  alias_method :to_y, :to_yaml
@@ -53,7 +50,7 @@ module Linguistics
53
50
  ##
54
51
  def to_json(*a)
55
52
  json_hash = {'json_class' => self.class.name}
56
-
53
+
57
54
  # In the case that we're working with a regular verb, the only thing
58
55
  # we need to save is the original string, since everything can be
59
56
  # re-derived from it easily.
@@ -68,7 +65,7 @@ module Linguistics
68
65
  end
69
66
  json_hash['tense_list' ] = {}
70
67
  @tense_list.each do |t|
71
- json_hash['tense_list'][t.to_s] = self.send t.to_sym
68
+ json_hash['tense_list'][t.to_s] = self.send t.to_sym
72
69
  end
73
70
  json_hash['irregular'] = irregular?
74
71
  return json_hash.to_json(*a)
@@ -81,7 +78,7 @@ module Linguistics
81
78
  #
82
79
  ##
83
80
  def pretty_generate
84
- JSON.pretty_generate(@data_structure.keys.length < 1 ? to_hash : @data_structure)
81
+ JSON.pretty_generate( self.to_h )
85
82
  end
86
83
 
87
84
  end
@@ -0,0 +1,17 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ module DefectiveChecker
6
+ def self.is_it_defective?(instance)
7
+ first_person_present_tense = instance.first_person_singular
8
+ present_active_infinitive = instance.present_active_infinitive
9
+ found = Linguistics::Latin::Verb::LatinVerb::PRESENT_ONLY.member?( first_person_present_tense ) ||
10
+ Linguistics::Latin::Verb::LatinVerb::PRESENT_ONLY.member?( present_active_infinitive )
11
+ return Linguistics::Latin::Verb::Classification::PresentOnly if found
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,159 @@
1
+ # encoding: UTF-8
2
+
3
+ module Linguistics
4
+ module Latin
5
+ module Verb
6
+ class LatinVerb
7
+ module Deponent
8
+ # In a bit of cleverness, if the verb is deponent, we have built out
9
+ # this verb as if it were regular, but we have also created a
10
+ # @proxyVerb which is the active 'pseudo verb' corresponding to this
11
+ # verb. We should be able to take this verb's active formulations
12
+ # and set their results to the @proxyVerb's passive formulations
13
+ #
14
+ # Ergo: miror/mirari/miratus =~
15
+ # miro/mirare/PreventDeponentInfiniteRegress/miratus Therefore make a
16
+ # LatinVerb.new(miro/mirare/PreventDeponentInfiniteRegress/miratus).
17
+ # Take its passives and set them to this verb's actives. This is
18
+ # actually what students do heuristically in Latin classes.
19
+
20
+ def self.included(including_class)
21
+ debugger
22
+ puts 'hi'
23
+ end
24
+
25
+ def self.extended(extending_instance)
26
+ extending_instance.instance_eval do
27
+ @proxy_verb_string = Linguistics::Latin::Verb::LatinVerb.create_pseudo_active_mask_for_deponent @original_string
28
+ @proxyVerb = Linguistics::Latin::Verb::LatinVerb.new @proxy_verb_string
29
+ apply_deponent_masking
30
+ end
31
+ end
32
+ ##
33
+ #
34
+ # Top-level method used to call the sub-methods which create a facade so that
35
+ # active_ vectors can be called on a deponent which actually forwards that
36
+ # call to a "fake" non-deponent (+@proxyVerb+) whose passives fit the correct
37
+ # morphology
38
+ #
39
+ # It calls the following methods, each of which applies the masking to a
40
+ # certain collection of vectors:
41
+ #
42
+ # * +deponent_swap+ :: active_voice* remaps "standard" calls like
43
+ # +active_voice_indicative_mood_present_tense...+
44
+ # * +deponent_imperative_mutations+ :: masks the imperatives
45
+ # * +deponent_participle_mutations+ :: masks the participles
46
+ # * +deponent_infinitive_mutations+ :: masks the infinitives
47
+ #
48
+ ##
49
+
50
+ def apply_deponent_masking
51
+ deponent_swap
52
+ deponent_imperative_mutations
53
+ deponent_participle_mutations
54
+ deponent_infinitive_mutations
55
+ end
56
+
57
+ ##
58
+ #
59
+ # The deponent's imperatives require a bit of consideration. They don't
60
+ # follow the stem/stem+'ite' format.
61
+ #
62
+ ##
63
+
64
+ def deponent_imperative_mutations # :nodoc:
65
+ self.singleton_class.class_eval do
66
+ def active_voice_imperative_mood_present_tense_second_person_singular_number
67
+ return @proxyVerb.instance_variable_get '@present_active_infinitive'
68
+ end
69
+ def active_voice_imperative_mood_present_tense_second_person_plural_number
70
+ return @proxyVerb.send :passive_voice_indicative_mood_present_tense_second_person_plural_number
71
+ end
72
+ def active_voice_imperative_mood_future_tense_second_person_singular_number
73
+ k=@proxyVerb.send :passive_voice_indicative_mood_present_tense_second_person_plural_number
74
+ k.sub!(/minī$/, '')
75
+ k += 'tor'
76
+ Linguistics::Latin::Phonographia.fix_macrons k
77
+ end
78
+ end
79
+ end
80
+
81
+ def deponent_participle_mutations # :nodoc:
82
+ self.singleton_class.class_eval do
83
+ def present_active_participle
84
+ return @proxyVerb.present_active_participle
85
+ end
86
+
87
+ def future_active_participle
88
+ return @proxyVerb.future_active_participle
89
+ end
90
+
91
+ def perfect_active_participle
92
+ return @proxyVerb.perfect_passive_participle
93
+ end
94
+
95
+ def future_passive_participle
96
+ return @proxyVerb.future_passive_participle
97
+ end
98
+
99
+ # Mask the supine
100
+ def supine
101
+ return @proxyVerb.supine
102
+ end
103
+ end
104
+ end
105
+
106
+ def deponent_infinitive_mutations # :nodoc:
107
+ self.singleton_class.class_eval do
108
+ def present_active_infinitive
109
+ return @proxyVerb.send :present_passive_infinitive
110
+ end
111
+ def perfect_active_infinitive
112
+ return @proxyVerb.send :perfect_passive_infinitive
113
+ end
114
+ def future_active_infinitive
115
+ return @proxyVerb.send :future_active_infinitive
116
+ end
117
+ end
118
+ end
119
+
120
+ ##
121
+ #
122
+ # Swaps this verb's active_ vectors and replaces them with
123
+ # @proxyVerb's passive_ vectors. This is pretty darned sneaky. See
124
+ # Also deponent_swap
125
+ #
126
+ ##
127
+
128
+ def deponent_swap
129
+ # First, get the methods that were defined in the proxy as passive
130
+
131
+ storage = {}
132
+
133
+ @tense_list.grep(/^passive/).each do |pass|
134
+ # Find the active correlate
135
+ active_corr = pass.to_s.sub( /^passive(.*)/, "active\\1" )
136
+
137
+ # Keep @proxyVerb in the binding scope
138
+ pV = @proxyVerb
139
+
140
+ # In self, find the passive and save it's resultant object into a
141
+ # hash for future use.
142
+ self.singleton_class.class_eval do
143
+ storage[active_corr.to_sym] = pV.send(pass)
144
+ end
145
+ end
146
+
147
+ # Take the stored hashes and define instance methods on self such
148
+ # that we intercept the mixed-in methods ( C-c-c-combo breaker! ).
149
+ storage.each_pair do |k,v|
150
+ self.singleton_class.class_eval do
151
+ define_method k, lambda { return v }
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module Linguistics
3
2
  module Latin
4
3
  module Verb
@@ -14,7 +13,7 @@ module Linguistics
14
13
  # by more view-oriented libraries or applications.
15
14
  ##
16
15
  def display
17
- STDERR.puts "You should not be going much displaying here as this is a LIBRARY. Implement this elsewhere."
16
+ STDERR.puts "You should not be doing much displaying here as this is a LIBRARY. Implement this elsewhere."
18
17
  pretty_generate
19
18
  end
20
19
  end
@@ -0,0 +1,34 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ class LatinVerb
5
+ ##
6
+ #
7
+ # Some verbs only take a active/indic/pres/3rd/sg ("it rains"). For
8
+ # these we will not add the full vectors of methods, but will only
9
+ # respond to THAT vector.
10
+ #
11
+ ##
12
+ module Impersonal
13
+ def self.extended(extending_instance)
14
+ extending_instance.instance_eval do
15
+ prepare_present_only
16
+ end
17
+ end
18
+
19
+ def prepare_present_only
20
+ singleton_class.class_eval do
21
+ def active_voice_indicative_mood_present_tense
22
+ TenseBlock.new ["", "", @original_string,
23
+ "", "", ""]
24
+ end
25
+ def active_voice_indicative_mood_present_tense_third_person_singular_number
26
+ return active_voice_indicative_mood_present_tense[2]
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,83 @@
1
+ # encoding: UTF-8
2
+ module Linguistics
3
+ module Latin
4
+ module Verb
5
+ class LatinVerb
6
+ module Irregular
7
+ def self.extended(extending_instance)
8
+ extending_instance.instance_eval do
9
+ begin
10
+ os_sym = symbolize_original_string
11
+ json_string = Linguistics::Latin::Verb.const_get os_sym
12
+
13
+ raise "Found a JSON string with an absurdly small length!" if json_string.length <= 10
14
+ revivified_data_structure = JSON.parse( json_string )
15
+ rescue JSON::ParserError => e
16
+ puts "We were unable to parse JSON for #{@original_string} [o:#{o}] [o_sym:#{o_upcase_and_symbolic}]. Please verify your syntax."
17
+ raise e
18
+ rescue NameError => e
19
+ puts "We were unable to find a definition for #{@original_string}"
20
+ raise e
21
+ rescue => error
22
+ warn "#{@original_string} was identified as irregular but did not have a definition provided."
23
+ raise error
24
+ end
25
+
26
+ revivified_data_structure['tense_blocks'].each_pair do |k,v|
27
+ singleton_class.class_eval do
28
+ define_method k.to_sym do
29
+ TenseBlock.new v, { :meaning => MEANINGS[k.to_sym] }
30
+ end
31
+ end
32
+ end
33
+
34
+ @irregular_infinitives = revivified_data_structure['infinitives']
35
+ @irregular_participles = revivified_data_structure['participles']
36
+
37
+ return if @irregular_infinitives.nil?
38
+ return if @irregular_participles.nil?
39
+
40
+ self.instance_eval do
41
+ def present_active_infinitive; return @irregular_infinitives.present_active_infinitive; end
42
+ def present_passive_infinitive; return @irregular_infinitives.present_passive_infinitive; end
43
+ def perfect_active_infinitive; return @irregular_infinitives.perfect_active_infinitive; end
44
+ def perfect_passive_infinitive; return @irregular_infinitives.perfect_passive_infinitive; end
45
+ def future_passive_infinitive; return @irregular_infinitives.future_passive_infinitive; end
46
+ def future_active_infinitive; return @irregular_infinitives.future_active_infinitive; end
47
+ end
48
+
49
+ self.instance_eval do
50
+ def present_active_participle; return @irregular_participles.present_active_participle; end
51
+ def future_active_participle; return @irregular_participles.future_active_participle; end
52
+ def perfect_passive_participle; return @irregular_participles.perfect_passive_participle; end
53
+ def future_passive_participle; return @irregular_participles.future_passive_participle; end
54
+ def gerundive; return @irregular_participles.gerundive; end
55
+ def gerund; return @irregular_participles.d; end
56
+ end
57
+ end
58
+ end
59
+
60
+ def symbolize_original_string
61
+ # Translation added to account for Ruby not liking constants /^/
62
+ # with a multibyte. Probably a bug.
63
+ #
64
+ # This bug can be discovered by running #constants on
65
+ # Linguistics::Latin::Verb and seeing that Ōxxx is not found. To
66
+ # fix this i had to store it as ODI_. To make /that/ hack work, I
67
+ # had to add this bit beginning two lines below :-/
68
+ o = ActiveSupport::Multibyte::Chars.new( @original_string.gsub(/\s+/,'_') ).upcase
69
+
70
+ if o.match(/^([ĀĒĪŌŪ])(.*)/)
71
+ x=o[0,1].tr 'ĀĒĪŌŪ', 'AEIOU'
72
+ y=o[1,o.length]
73
+ o= x+y
74
+ end
75
+
76
+ o.to_sym
77
+ end
78
+
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ module Linguistics
3
+ module Latin
4
+ module Verb
5
+ class LatinVerb
6
+ class LatinVerbTypeEvaluator
7
+ def initialize(first_pres, infinitive, classifier)
8
+ return unless classifier.classification.to_s.split('::').last.eql?("Regular")
9
+ @type = if infinitive =~ /āre$/
10
+ Linguistics::Latin::Verb::VerbTypes::First
11
+ elsif infinitive =~ /ēre$/
12
+ Linguistics::Latin::Verb::VerbTypes::Second
13
+ elsif infinitive =~ /ere$/
14
+ first_pres =~ /i.$/ ? Linguistics::Latin::Verb::VerbTypes::ThirdIO : Linguistics::Latin::Verb::VerbTypes::Third
15
+ elsif infinitive =~ /.+īre$/
16
+ Linguistics::Latin::Verb::VerbTypes::Fourth
17
+ elsif (infinitive =~ /ī$/ and first_pres =~ /r$/)
18
+ Linguistics::Latin::Verb::VerbTypes::Deponent
19
+ else
20
+ raise "Could not find a verb type for this verb #{infinitive} and #{first_pres}"
21
+ end
22
+ end
23
+
24
+ def inspect
25
+ return @type
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+