latinverb 0.2.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/.gitignore +0 -1
  2. data/Gemfile +1 -2
  3. data/README.markdown +54 -240
  4. data/etc/irreg_skel.json +104 -0
  5. data/{latinirb.gemspec → latinverb.gemspec} +4 -4
  6. data/lib/latinverb/chart.rb +94 -0
  7. data/lib/latinverb/version.rb +10 -0
  8. data/lib/latinverb.rb +710 -0
  9. data/lib/linguistics/latin/verb/classification_types.rb +59 -0
  10. data/lib/linguistics/latin/verb/constants.rb +201 -0
  11. data/lib/linguistics/latin/verb/deponent_tense_methods.rb +98 -0
  12. data/lib/linguistics/latin/verb/infinitives.rb +212 -0
  13. data/lib/linguistics/latin/verb/irregulars.rb +4393 -0
  14. data/lib/linguistics/latin/verb/latinverb/auxiliary_classes.rb +208 -0
  15. data/lib/linguistics/latin/verb/latinverb/classmethods.rb +215 -0
  16. data/lib/linguistics/latin/verb/latinverb/data.rb +90 -0
  17. data/lib/linguistics/latin/verb/latinverb/display.rb +23 -0
  18. data/lib/linguistics/latin/verb/latinverb/metaprogramming.rb +79 -0
  19. data/lib/linguistics/latin/verb/latinverb/validation.rb +66 -0
  20. data/lib/linguistics/latin/verb/participles.rb +202 -0
  21. data/lib/linguistics/latin/verb/phonographia.rb +109 -0
  22. data/lib/linguistics/latin/verb/supine.rb +42 -0
  23. data/lib/linguistics/latin/verb/tense_methods.rb +950 -0
  24. data/test/testAmbiguousLookups.rb +30 -0
  25. data/test/testClusterResolution.rb +20 -0
  26. data/test/testDataStructures.rb +29 -0
  27. data/test/testDefectSemiImp.rb +111 -0
  28. data/test/testDeponentFirstConjugation.rb +64 -0
  29. data/test/testDeponentFourthConjugation.rb +64 -0
  30. data/test/testDeponentSecondConjugation.rb +64 -0
  31. data/test/testDeponentThirdConjugation.rb +64 -0
  32. data/test/testDeponentThirdIOConjugation.rb +64 -0
  33. data/test/testDeserializeInfinitives.rb +38 -0
  34. data/test/testFirstConjugation.rb +388 -0
  35. data/test/testFourthConjugation.rb +190 -0
  36. data/test/testFreakishVerbs.rb +93 -0
  37. data/test/testImperativeBlock.rb +27 -0
  38. data/test/testIrregularSum.rb +22 -0
  39. data/test/testIrregulars.rb +652 -0
  40. data/test/testLatinVerb.rb +195 -0
  41. data/test/testMacronRules.rb +19 -0
  42. data/test/testSecondConjugation.rb +189 -0
  43. data/test/testThirdConjugation.rb +190 -0
  44. data/test/testThirdIOConjugation.rb +190 -0
  45. metadata +70 -18
  46. data/bin/latinirb.rb +0 -7
  47. data/latinverb.rb +0 -544
  48. data/lib/LatinIRB.rb +0 -172
  49. data/lib/latinirb/paradigmatic_verbs.rb +0 -17
  50. data/lib/latinirb/version.rb +0 -10
  51. data/lib/latirb.rb +0 -20
@@ -0,0 +1,202 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'latinverb'
4
+ require 'linguistics/latin/verb/phonographia'
5
+
6
+ module Linguistics
7
+ module Latin
8
+ module Verb
9
+ ##
10
+ # == NAME
11
+ #
12
+ # Participles
13
+ #
14
+ # == DESCRIPTION
15
+ #
16
+ # This module contains the methods that, when mixed into a LatinVerb,
17
+ # will provide it the ability to resolve its participles (verbal
18
+ # adjectives).
19
+ #
20
+ # == REFERENCE
21
+ #
22
+ # Allen and Greenough Se. 155:
23
+ #
24
+ # The following Noun and Adjective forms are also included in the
25
+ # inflection of the Latin Verb:
26
+ #
27
+ # a. Four Participles, viz: --
28
+ # <em>Active</em>: the Present and Future Participles
29
+ # <em>Passive</em>: the Perfect Participle and the Gerundive
30
+ # b. The Gerund: this is in form a neuter noun of the second
31
+ # declension used only in the oblique cases of hte singular.
32
+ # c. The Supine: this is in form a verbal noun of the fourth
33
+ # declension in the accusative (-um) and dative or ablative (-ū)
34
+ # singular
35
+ # ...
36
+ #
37
+ ##
38
+ module Participles
39
+
40
+ ##########################################
41
+ # Participles
42
+ ##########################################
43
+
44
+ ##
45
+ #
46
+ # === GRAMMATICAL FUNCTION
47
+ #
48
+ # A&G,158,a. The Present Participle (ending in -ns) has commly the
49
+ # meaning and use as the English participle in 'ing; as vocāns, calling.
50
+ # For inflection see egēns, sec. 118
51
+ #
52
+ # === ARGUMENTS
53
+ #
54
+ # None
55
+ #
56
+ # === RETURNS
57
+ #
58
+ # Array of participles
59
+ #
60
+ ###
61
+ def present_active_participle
62
+ raise "Participial stem was nil" if @participial_stem.nil?
63
+ endings=%w(ns ntis)
64
+ return endings.collect{ |x| Linguistics::Latin::Phonographia.fix_macrons(@participial_stem+x.chomp)}.join(', ')
65
+ end
66
+
67
+ ##
68
+ #
69
+ # === GRAMMATICAL FUNCTION
70
+ #
71
+ # A&G,158,b. The Future Participle (ending in -ūrus) is oftenest used to
72
+ # express what is likely or about to happen: as, rēctūrus, about to
73
+ # rule...
74
+ #
75
+ # === ARGUMENTS
76
+ #
77
+ # None
78
+ #
79
+ # === RETURNS
80
+ #
81
+ # Array of participles
82
+ #
83
+ ###
84
+ def future_active_participle
85
+ # In case we have an irregular, or somehow already have a /ūrus$/ we shouldn't do this
86
+ mybase = (@pass_perf_part =~ /ūru.$/) ?
87
+ @pass_perf_part.gsub(/u[sm]$/,'')
88
+ :
89
+ @pass_perf_part.gsub(/u[sm]$/, "ūr")
90
+
91
+ singular_endings=%w(us a um)
92
+ return singular_endings.collect{|x| mybase+"#{x}".chomp}.join(', ')
93
+ end
94
+
95
+ ##
96
+ #
97
+ # === GRAMMATICAL FUNCTION
98
+ #
99
+ # 158,c. The Perfect Participle (ending in -tus, -sus) has two uses:
100
+ #
101
+ # 1. It is sometimes equivalent to the English perfect passive
102
+ # participle:
103
+ #
104
+ # as tеctus, sheltered; acceptus, accepted...; and often simply has an
105
+ # adjective meaning: as, acceptus, acceptable.
106
+ #
107
+ # 2. It is used with the verb to be (esse) to form certain tenses of the
108
+ # passive: as, vocātus est, he was (has been) called.
109
+ #
110
+ # === ARGUMENTS
111
+ #
112
+ # None
113
+ #
114
+ # === RETURNS
115
+ #
116
+ # Array of participles
117
+ #
118
+ ###
119
+ def perfect_passive_participle
120
+ mybase=@pass_perf_part.sub(/u[sm]$/,'')
121
+ singular_endings=%w(us a um)
122
+ return singular_endings.collect{|x| mybase+"#{x}".chomp}.join(', ')
123
+ end
124
+
125
+ ##
126
+ #
127
+ # === GRAMMATICAL FUNCTION
128
+ #
129
+ # <em>See</em>: Gerundive
130
+ #
131
+ # === ARGUMENTS
132
+ #
133
+ # None
134
+ #
135
+ # === RETURNS
136
+ #
137
+ # Array of participles
138
+ #
139
+ ###
140
+ def future_passive_participle
141
+ mybase = @participial_stem+"nd"
142
+ singular_endings=%w(us a um)
143
+ return singular_endings.collect{|x|Linguistics::Latin::Phonographia.fix_macrons( mybase+"#{x}".chomp)}.join(', ')
144
+ end
145
+
146
+ ##
147
+ #
148
+ # === GRAMMATICAL FUNCTION
149
+ #
150
+ # A&G, 158,d.
151
+ #
152
+ # The Gerundive (ending in -ndus) has two uses:
153
+ #
154
+ # 1. ...an adjective implying obligation...
155
+ #
156
+ # 2. In the oblique cases the Gerundive commonly has the same meaning as
157
+ # the Gerund ... for examples see sec. 503
158
+ #
159
+ # === ARGUMENTS
160
+ #
161
+ # None
162
+ #
163
+ # === RETURNS
164
+ #
165
+ # Array of participles
166
+ #
167
+ ###
168
+ def gerundive
169
+ self.future_passive_participle
170
+ end
171
+
172
+ ##
173
+ #--
174
+ # The gerund is a verbal noun (loving dancing, running) formed like the
175
+ # gerundive, except that it only has four forms: the n. singular of the
176
+ # gen, dative, acc, and abl (the oblique cases). They are identical to
177
+ # the corresponding cases of the gerundive but ae ative in meaning and
178
+ # correspond to the english "-ing"
179
+ #
180
+ # Gerundive: verbal achective
181
+ # gerund: verbal noun
182
+ #
183
+ # gerund only has oblique
184
+ # gerundive is passive in meaning, gerund is active:
185
+ #
186
+ # A FUNNY THING I ALWAYS FORGET:
187
+ # studium legeni libros ==> studium librorum legendorum
188
+ # discimus legendo libros ==> discimus libris legendis
189
+ #
190
+ # -- Source, Wheelock
191
+ #++
192
+ ##
193
+ #alias_method :gerund, :gerundive
194
+ def gerund
195
+ b = gerundive.sub /.*\s+(.*)um.*$/, "\\1"
196
+ b += "ī, ō, etc."
197
+ return b
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,109 @@
1
+ # encoding: UTF-8
2
+
3
+ module Linguistics
4
+ module Latin
5
+ ##
6
+ #
7
+ # The Phonographia module handles the phonography of written Latin: how
8
+ # the sound of Latin is written. In particular, the sounds that need
9
+ # special notation are the vowels which may bear a long ("ā") or short
10
+ # ("a") quantity.
11
+ #
12
+ # When forming Latin words from heuristic ( as LatinVerb does ), certain
13
+ # phonographical structures arise that one does not see in the language as
14
+ # practiced by humans. For example, given "amāre," the stem is "amā."
15
+ # When the heuristic postpends "t" to get the present, indicative, third
16
+ # person singular, the result is "amāt," which, by rules of Latin
17
+ # phonology, must be made to bear a short sound in the ultimate vowel.
18
+ # This state is _phonographically_ notes as "amat." This module
19
+ # implements the appropriate rules for proper phonetic compliance.
20
+ #
21
+ ##
22
+ module Phonographia
23
+ class << self
24
+ # === DESCRIPTION
25
+ #
26
+ # Latin has several rules pertaining to how long sounds must behave
27
+ # based on their neighboring characters. The rules that +fix_macrons+
28
+ # tests are the following
29
+ #
30
+ # === RULES
31
+ #
32
+ # <b>Rule 1: </b>:: m/r/t at end of line shortens preceding vowel
33
+ # <b>Rule 2: </b>:: macron-bearing vowel before vowel, regardless of
34
+ # its quantity
35
+ # <b>Rule 3: </b>:: macron-bearing vowel before /n[td]/ anywhere in the string
36
+ #
37
+ # === ARGUMENTS
38
+ #
39
+ # +s+ :: a string which needs to be processed for Latin phonographic
40
+ # compliance
41
+ #
42
+ # === RETURNS
43
+ #
44
+ # String with consonants properly converted
45
+ #
46
+ # === EXAMPLE
47
+ #
48
+ # fix_macrons(fabām) #=> fabam ( Rule 1 )
49
+ # fix_macrons(cāīō) #=> caiō ( Rule 1, Rule 2 )
50
+ #
51
+ ##
52
+ def fix_macrons(s)
53
+ raise if s.nil?
54
+ return "" if s.empty?
55
+ macron_table = {"\xc4\x81" => 'a',
56
+ "\xc4\x93" => 'e',
57
+ "\xc4\xab" => 'i',
58
+ "\xc5\x8d" => 'o',
59
+ "\xc5\xab" => 'u',
60
+ "\xc4\x80" => 'A',
61
+ "\xc4\x92" => 'E',
62
+ "\xc4\xaa" => 'I',
63
+ "\xc5\x8c" => 'O',
64
+ "\xc5\xaa" => 'U',
65
+ "ā" => 'a',
66
+ "ē" => 'e',
67
+ "ī" => 'i',
68
+ "ō" => 'o',
69
+ "ū" => 'u',
70
+ "Ā" => 'A',
71
+ "Ē" => 'E',
72
+ "Ī" => 'I',
73
+ "Ō" => 'O',
74
+ "Ū" => 'U',
75
+ }
76
+
77
+
78
+ # m/r/t at end of line shortens preceding vowel
79
+ if s =~ /^(.*)([āēīōūĀĒĪŌŪ])([mrt])$/i
80
+ s = $1 + macron_table[$2] + $3
81
+ end
82
+
83
+ # macron before vowel
84
+ if s =~ /(.*)([āēīōūĀĒĪŌŪ])([āēīōūĀĒĪŌŪaeiouAEIOU])(.*)/i
85
+ s = self.fix_macrons $1 + macron_table[$2] + $3 + $4
86
+ end
87
+
88
+ if s=~ /n[td]/
89
+ # n[td]
90
+ mutaturum = s.split //
91
+ mutatum = []
92
+ mutaturum.each_with_index do |e, i|
93
+ if ( e == "n" and
94
+ mutaturum[i+1] =~ /[td]/ and
95
+ not macron_table[mutaturum[i-1]].nil? )
96
+ mutatum[i-1]=macron_table[mutaturum[i-1]]
97
+ end
98
+ mutatum << e
99
+ end
100
+
101
+ return mutatum.join ''
102
+ end
103
+
104
+ return s
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+ #
3
+ module Linguistics
4
+ module Latin
5
+ module Verb
6
+ class LatinVerb
7
+ ##
8
+ #
9
+ # === GRAMMATICAL FUNCTION
10
+ #
11
+ # The supine is:
12
+ #
13
+ # * 4th declension verbal noun
14
+ # * Formed on the same stem as the perfect passive participle
15
+ # * Only two forms in common use: accusative and ablative singular
16
+ #
17
+ # Ablative is used with the neuter of certain adjectives to indicate
18
+ # what respect a particular quality is applicable: <em>mirabile
19
+ # dictu</em>, <em>facile factu</em>. The accusative is used with
20
+ # verbs of motion to indicate purpose.
21
+ #
22
+ # -- Source <em>Wheelock</em>
23
+ #
24
+ # === ARGUMENTS
25
+ #
26
+ # None
27
+ #
28
+ # === RETURNS
29
+ #
30
+ # Hash with keys based on [:accusative] or [:ablative]
31
+ #
32
+ ###
33
+ def supine
34
+ acc = @pass_perf_part
35
+ abl = acc.sub /^(.*)um$/, "\\1"
36
+ abl += "ū"
37
+ {:ablative => abl, :accusative => acc}
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end