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
data/lib/latinverb.rb CHANGED
@@ -1,442 +1,86 @@
1
- # encoding: UTF-8
2
- # vim: set fdm=marker tw=80 sw=2:
3
- #
4
- #------------------------------------------------------------------------------
5
- # DEPENDENCIES
6
- #------------------------------------------------------------------------------
7
- # External dependencies
8
- require 'verbvector'
9
- require 'yaml'
10
- require 'json'
11
1
  require 'active_support'
2
+ require 'forwardable'
12
3
 
13
- ### {{{
14
- #--
15
- # Internal dependencies
16
- # If the library is in the latin/verb, then it is a feature of the actual
17
- # Latin language as abstracted into Ruby. If it is in the latin/verb/latinverb directory, it is part
18
- # of the mechanics of the representation of that language as Ruby, i.e. this
19
- # program. It's the difference between "This is part of Latin" and "This is
20
- # Part of the machinery I use to represent Latin in Ruby."
21
- #++
22
- ### }}}
4
+ require 'byebug' # who am I kidding?
5
+ require 'linguistics_latin'
23
6
 
24
- # Latin Language Rules
25
- require 'linguistics/latin/verb/classification_types'# {{{
26
- require 'linguistics/latin/verb/tense_block'
27
- require 'linguistics/latin/verb/participle_block'
28
- require 'linguistics/latin/verb/infinitive_block'
29
- require 'linguistics/latin/verb/imperative_block'
30
- require 'linguistics/latin/verb/tense_definitions/impersonal'
31
- require 'linguistics/latin/verb/tense_definitions/invariant'
32
- require 'linguistics/latin/verb/tense_definitions/first'
33
- require 'linguistics/latin/verb/tense_definitions/second'
34
- require 'linguistics/latin/verb/tense_definitions/third'
35
- require 'linguistics/latin/verb/tense_definitions/third_io'
36
- require 'linguistics/latin/verb/tense_definitions/fourth'
37
- require 'linguistics/latin/verb/tense_definitions/irregular'
38
- require 'linguistics/latin/verb/deponent_tense_methods'
39
- require 'linguistics/latin/verb/supine'
40
- require 'linguistics/latin/verb/phonographia'
41
- require 'linguistics/latin/verb/constants'
42
- require 'linguistics/latin/verb/infinitives'
43
- require 'linguistics/latin/verb/participles'
44
- require 'linguistics/latin/verb/irregulars'# }}}
45
-
46
- # LatinVerb design
47
- require 'linguistics/latin/verb/latinverb/impersonal'# {{{
48
- require 'linguistics/latin/verb/latinverb/irregular'
49
- require 'linguistics/latin/verb/latinverb/semideponent'
50
- require 'linguistics/latin/verb/latinverb/deponent'
51
- require 'linguistics/latin/verb/latinverb/latinverb_classifier'
52
- require 'linguistics/latin/verb/latinverb/latinverb_pp_extractor'
53
- require 'linguistics/latin/verb/latinverb/latinverb_input_sanitizer'
54
- require 'linguistics/latin/verb/latinverb/defective_checker'
55
- require 'linguistics/latin/verb/latinverb/latin_verb_type_evaluator'
56
- require 'linguistics/latin/verb/latinverb/classmethods'
57
- require 'linguistics/latin/verb/latinverb/verbvector_description'
58
- require 'linguistics/latin/verb/latinverb/metaprogramming'
59
- require 'linguistics/latin/verb/latinverb/validation'
60
- require 'linguistics/latin/verb/latinverb/data'
61
- require 'linguistics/latin/verb/latinverb/display'# }}}
62
-
63
- require 'latinverb/version'# {{{
64
- require 'latinverb/chart.rb'# }}}
65
-
66
- =begin rdoc
67
- # {{{
68
- ==DESCRIPTION
69
-
70
- Linguistics is a module that forms a primordial node for storing Modules and classes dealing with linguistics. The namespace is immediately sub-divided by language (e.g. Latin, Spanish) then part of speech (e.g. Noun, Verb) or function (e.g. Phonographia).
71
- # }}}
72
- =end
7
+ require 'latinverb/errors'
8
+ require 'latinverb/components'
9
+ require 'latinverb/tense_block'
10
+ require 'latinverb/imperative_block'
11
+ require 'latinverb/serialization'
12
+ require 'latinverb/version'
13
+ require 'latinverb/dynamic_method_resolver'
14
+ require 'latinverb/tense_method_applicator'
73
15
 
74
16
  module Linguistics
75
- # Generalized module for handling linguistics related to Latin
76
17
  module Latin
77
- # Generalized module for handling linguistics related to Latin's verbal aspects
78
18
  module Verb
79
- ### {{{
80
- # == SYNOPSIS# {{{# {{{
81
- #
82
- # Abstraction of a Verb in the Latin language.
83
- ## }}}
84
- # == DESCRIPTION# {{{
85
- #
86
- # LatinVerb is:
87
- # * a tool to help the student of Latin understand the rules of
88
- # conjugation's heuristics by presenting said heuristics in Ruby
89
- # * a way to get out of having to lug the 501 Latin Verbs book around
90
- # (when wrapped in an application ;) )
91
- # * a way to discover some of the interesting metacongnitive structures
92
- # between natural language and programming language
93
- # * <em>...and so much more...</em>
94
- ## }}}
95
- # === OPERATION# {{{
96
- #
97
- # LatinVerb operates by instantiating a LatinVerb based on a string
98
- # containing the "four principal parts" that are used to describe a
99
- # Latin verb. From this simple entry, one calls "vectors' upon the
100
- # object. Vectors represent the unique, "fully-qualified" locus of a
101
- # conjugated form. A feature that was of paramount importance in its
102
- # implementation was that the conjugation <b>should occur by
103
- # heruristic</b> in the exact same way that <b>humans have been
104
- # taught</b> in Latin classes for _milennia_!
105
- #
106
- # An example should illustrate:
107
- ## }}}
108
- # === EXAMPLE# {{{
109
- #
110
- # <pre>
111
- # to_love = LatinVerb.new("amō amāre amāvī amatum")
112
- # to_love.active_voice_indicative_mood_present_tense_second_person_singular_number #=> amās
113
- # to_love.active_voice_indicative_mood_present_tense_third_person_singular_number #=> amat
114
- # </pre>
115
- ## }}}
116
- # === EXPLICATION# {{{
117
- #
118
- # Considering the above example, when the object was insantiated, it
119
- # realized what its conjugation was, realized what its stem ("amā") was,
120
- # and then added to itself support for
121
- # <tt>active_voice_indicative_mood_present_tense</tt> which is defined
122
- # as "take the stem and postpend "ō, s, t, mus, tis, nt" to the stem and
123
- # return it as an array. It is through (mis-?)use of method_missing
124
- # that this simple "vector" method for interfacing with a verb is
125
- # possible. <em>Puto hoc bonum esse</em>.
126
- ## }}}
127
- # === MACRONS / QUANTITY# {{{
128
- #
129
- # In reference texts, quanitiy of vowel duration ("long" or "short") is
130
- # marked with a macron. *LatinVerb assumes it will be provided strings
131
- # with macrons*. This makes sense as per the previous section, the
132
- # conjugation is done by heuristic. What isn't there cannot be altered.
133
- # <em>Si hoc non aderit, non mutabitur</em>. To make this easier I
134
- # wrote the MacronConversion library which supports conversion of
135
- # LaTeX-styled ASCII macron transgraphia (e.g. \={a} => ā).
136
- ## }}}
137
- # === REFERENCE# {{{
138
- ## }}}
139
- # ==== Voices# {{{
140
- # A&G Sec. 156:
141
- #
142
- # The Active and Passive Voices in Latin generally correspond to the
143
- # active and passive in English; but --
144
- #
145
- # a. The passive voice often has a reflexive meaning: --
146
- # b. Many verbs are passive in form, but active or reflexive in
147
- # meaning. These are called Deponents (sec 190.)...
148
- # c. Some verbs with active meaning have the passive form in the
149
- # perfect tenses; these are called Semi-Deponents
150
- ## }}}
151
- # ==== Moods# {{{
152
- #
153
- # a. The Indicative Mood is used for most <em>direct assertions</em>
154
- # and <em>interrogations</em>
155
- # b. The Subjunctive Mood has many idiomatic uses, as in
156
- # <em>commands</em>, <em>conditions</em>, and various <em>dependent
157
- # clauses</em>.
158
- # c. The Imperative is used for <em>exhortation</em>,
159
- # <em>entreaty</em>, or <em>command</em>; but the Subjunctive is often
160
- # used instead
161
- ## }}}
162
- # === WORKS CITED# {{{
163
- #
164
- # Allen, J.H. Allen and Greenough's New Latin Grammar. Dover,
165
- # Mineola: 2006. Cited herein as "A&G."
166
- #
167
- # Wheelock, Frederic M. Wheelock's Latin. Collins, New York: 2005.
168
- # Cited herein as "Wheelock."# }}}# }}}
169
- #
170
- ### }}}
171
19
  class LatinVerb
172
- # Modules used to validate the input in initialize# {{{
173
- include Linguistics::Latin::Verb::Validation
174
- include Linguistics::Latin::Verb::Participles
175
- include Linguistics::Latin::Verb::Infinitives
176
- # }}}
177
-
178
- # Attributes for storing submitted data. This will help remember the origin state# {{{
179
- attr_reader :original_string
180
-
181
- # Attributes for storing calculated status.
182
- attr_reader :verb_methods
183
-
184
- # Access the Module that provides all the methods
185
- attr_reader :latin_verbvector_generator, :latin_verb_methods# }}}
186
-
187
- ### {{{
188
- #
189
- # The constructor for a Latinverb
190
- #
191
- # ===ARGUMENTS
192
- #
193
- # *s:* :: +s+ is class-tested and supports String or Hash classes,
194
- # with the standard path having been designed to accept a string
195
- # containing 4 words ("four principal parts"). Latin's principal
196
- # irregular verbs are also accepted (see CONSTANTS) as possible
197
- # entries. +s+ also accepts a Hash as input. This is used for
198
- # deserialization from JSON which initialized based on a Hash.
199
- #
200
- # == SEE ALSO
201
- #
202
- # #initialize does very little work. Therefore special attention
203
- # should be paid to the #_init_by_string and _add_vector_methods.
204
- # These are the workhorses of this class and do most of the decoration
205
- # activity. In the case of extending to support irregular verbs,
206
- # #_irregular_handler is a critical path to explore.
207
- #
208
- # == TODO
209
- #
210
- # * Array support for the argument
211
- #
212
- ### }}}
213
- #
214
- def initialize(data)# {{{
215
- raise LatinVerbInitializationError if data.nil?
216
-
217
- ### {{{
218
- # Generates all the methods to which a verb must be able to respond
219
- # by implementing Linguistics::Verbs::Verbvector::VerbvectorGenerator.
220
- #
221
- # This conforms to the definition provided in Allen & Greenough Sec.
222
- # 154:
223
- #
224
- # Through its conjugation the Verb expresses Voice, Mood, Tense
225
- # Person, and Number.
226
- #
227
- # a. The Voices are two: Active and Passive
228
- # b. The Moods are four: Indicative,Subjuncitve, Imperative, and
229
- # Infinitive
230
- #
231
- # ...
232
- #
233
- # c. The Tenses are six, viz: --
234
- # 1. For continued action: Present, Imperfect, Future
235
- # 2. For completed action, Perfect, Pluperfect, Future Perfect
236
- #
237
- # The Indicative Mood has all six tenses, but the Subjunctive has
238
- # no future or future perfect and the Imperative has only the
239
- # present and the future. The Infinitive has the present, perfect,
240
- # and future.
241
- #
242
- # d. The Persons are three: First, Secon, Third.
243
- # e. The Numbers are two: Singular and Plural
244
- ### }}}
245
- @latin_verbvector_generator =
246
- Linguistics::Verbs::Verbvector::VerbvectorGenerator.new(
247
- &Linguistics::Latin::Verb::LatinVerb::LATIN_VERBVECTOR_DESCRIPTION )
248
-
249
- # We're restoring a standard verb from JSON
250
- data = data['original_string'] if init_data_is_a_hash_of_a_regular_restorable_verb(data)
251
-
252
- if data.is_a? String
253
- @sanitizer = LatinVerbInputSanitizer.new data
254
- @original_string = @sanitizer.to_s
255
- @classifier = LatinVerbClassifier.new @original_string
256
- @prin_parts_extractor = LatinVerbPPExtractor.new @sanitizer.to_s, @classifier
257
- @verb_type = LatinVerbTypeEvaluator.new first_person_singular, present_active_infinitive, @classifier
258
-
259
- load_tense_methods
260
- generate_methods_for_accessing_tense_blocks_from_tense_methods_components
261
- include_classification_specific_mixins
262
- check_and_mutate_defectives
263
- end
264
- end# }}}
265
-
266
- ######################################################################
267
- # Instance methods
268
- ######################################################################
269
- ##
270
-
271
- def present_only?# {{{
272
- @present_only ||= @classifier.present_only?
273
- end# }}}
274
- def short_class# {{{
275
- return classification.to_s.gsub(/.*::(\w+)$/,"\\1")
276
- end# }}}
277
-
278
- ### {{{
279
- #
280
- # Returns the four principal parts and regularity designation
281
- ### }}}
282
- def to_s# {{{
283
- return sprintf("%s [%s]", short_class, original_string)
284
- end# }}}
285
-
286
- ### {{{
287
- #
288
- # When working in irb or LatinIRB it's good to find out what the
289
- # instance methods are on this# }}}
290
- def instance_methods# {{{
291
- @latin_verbvector_generator.vector_list
292
- end# }}}
293
-
294
- def regular?# {{{
295
- @classifier.regular?
296
- end# }}}
297
-
298
- def irregular?# {{{
299
- @classifier.irregular?
300
- end# }}}
301
-
302
- def classification# {{{
303
- @classifier.classification
304
- end# }}}
305
-
306
- def verb_type# {{{
307
- @verb_type.inspect
308
- end# }}}
309
-
310
- def stem# {{{
311
- unless classified_as.irregular?
312
- @stem ||= @prin_parts_extractor.stem
20
+ extend Forwardable
21
+
22
+ def_delegators :@validator, :valid?
23
+ def_delegators :@classifier, :classification, :irregular?, :present_only?, :regular?, :set_as_defective, :short_class
24
+ def_delegators :@prin_parts_extractor, :first_person_perfect, :first_person_perfect, :first_person_singular, :passive_perfect_participle, :present_active_infinitive, :present_active_infinitive, :principal_parts
25
+ def_delegators :@participler, :supine, :future_active_participle, :future_passive_participle, :gerund, :gerundive, :perfect_passive_participle, :present_active_participle
26
+ def_delegators :@infinitivizer, :future_active_infinitive, :future_passive_infinitive, :infinitives, :perfect_active_infinitive, :perfect_passive_infinitive, :present_passive_infinitive
27
+ def_delegators :@stem_deriver, :stem, :participial_stem
28
+ def_delegators :@chart_presenter, :chart, :c
29
+ def_delegator :@imperative_handler, :imperatives
30
+
31
+ def_delegator :@classifier, :to_s, :conjugation
32
+ def_delegator :@classifier, :dup, :classified_as
33
+ def_delegator :@classifier, :dup, :classified_as
34
+ def_delegator :@type_evaluator, :type, :verb_type
35
+
36
+ attr_reader :original_string, :verb_methods, :classifier
37
+
38
+ def initialize(data)
39
+ classify(data)
40
+ build_validator
41
+ apply_parts_of_speech!
42
+ apply_tenses!
43
+ apply_chart_capabilities!
313
44
  end
314
- end# }}}
315
45
 
316
- def conjugation# {{{
317
- classification.to_s
318
- end# }}}
319
-
320
- def principal_parts# {{{
321
- @principal_parts ||= @prin_parts_extractor.principal_parts
322
- end# }}}
323
-
324
- def classified_as# {{{
325
- return @classifier
326
- end# }}}
327
-
328
- def first_person_singular# {{{
329
- @first_person_singular ||= @prin_parts_extractor.first_person_singular
330
- end# }}}
331
-
332
- def present_active_infinitive# {{{
333
- @present_active_infinitive ||= @prin_parts_extractor.present_active_infinitive
334
- end# }}}
335
-
336
- def first_person_perfect# {{{
337
- @first_person_perfect ||= @prin_parts_extractor.first_person_perfect
338
- end# }}}
339
-
340
- def passive_perfect_participle# {{{
341
- @passive_perfect_participle ||= @prin_parts_extractor.passive_perfect_participle
342
- end# }}}
343
-
344
- def participial_stem# {{{
345
- @participial_stem ||= @prin_parts_extractor.participial_stem
346
- end# }}}
347
-
348
- # ===============================================================================
349
-
350
- private
351
-
352
- def load_tense_methods# {{{
353
- load_tense_methods_that_do_not_vary_by_verb_type
354
- load_tense_methods_based_on_verb_type
355
- end# }}}
356
-
357
- def load_tense_methods_that_do_not_vary_by_verb_type# {{{
358
- self.extend Linguistics::Latin::Verb::TenseDefinitions::Invariant
359
- end# }}}
360
-
361
- def load_tense_methods_based_on_verb_type #{{{
362
- # Turn Linguistics::Latin::Verb::VerbTypes::First into
363
- # Linguistics::Latin::Verb::TenseDefinitions::First and extend with it
364
- mod_path = @verb_type.inspect.to_s
365
- return if mod_path.empty?
366
- mod_path.sub!('VerbTypes', 'TenseDefinitions' )
367
- the_mod = mod_path.split('::').inject(Object) do |mod, class_name|
368
- mod.const_get(class_name)
369
- end
370
- self.extend the_mod
371
- end# }}}
372
-
373
- def verify_generated_tense_list# {{{
374
- # Given the use of method_missing to handle resolution, it's wise to
375
- # make sure that every cluster method /is/ actually defined.
376
- @tense_list.each do |m|
377
- raise "FAILURE: Critical method #{m} was not defined." unless
378
- (self.respond_to? m.to_sym)
379
- end
380
- end# }}}
381
-
382
- def init_data_is_a_hash_of_a_regular_restorable_verb(data)# {{{
383
- (data.is_a?(Hash) && !data['irregular'] && data.has_key?('original_string'))
384
- end# }}}
385
-
386
- def generate_methods_for_accessing_tense_blocks_from_tense_methods_components# {{{
387
- self.extend @latin_verbvector_generator.method_extension_module
388
- @tense_list =
389
- @latin_verbvector_generator.cluster_methods[:tense_list].call
390
- verify_generated_tense_list
391
- end# }}}
46
+ def to_s
47
+ sprintf("%s [%s]", short_class, original_string)
48
+ end
392
49
 
393
- def include_classification_specific_mixins# {{{
394
- the_mod = if classified_as.impersonal?
395
- Linguistics::Latin::Verb::LatinVerb::Impersonal
396
- elsif classified_as.irregular?
397
- Linguistics::Latin::Verb::LatinVerb::Irregular
398
- elsif classified_as.deponent?
399
- Linguistics::Latin::Verb::LatinVerb::Deponent
400
- elsif classified_as.semideponent?
401
- Linguistics::Latin::Verb::LatinVerb::Semideponent
402
- elsif classified_as.present_only?
403
- Linguistics::Latin::Verb::LatinVerb::PresentOnly
404
- end
50
+ def display
51
+ pretty_generate
52
+ end
405
53
 
406
- return unless the_mod
54
+ private
407
55
 
408
- # Tell the instance to pull in the instance methods in the module by
409
- # extending itself.
410
- self.instance_eval do
411
- self.extend the_mod
412
- end
56
+ def classify(data)
57
+ @original_string = (data['original_string'] || data)
58
+ @classifier = LatinVerbClassifier.new(@original_string)
59
+ @prin_parts_extractor = LatinVerbPrincipalPartsExtractor.new(@original_string, @classifier)
60
+ end
413
61
 
414
- end# }}}
62
+ def build_validator
63
+ @validator = Validator.new(self)
64
+ end
415
65
 
416
- def check_and_mutate_defectives# {{{
417
- is_defective = Linguistics::Latin::Verb::LatinVerb::DefectiveChecker::is_it_defective?(self)
418
- if is_defective
419
- @classifier.set_as_defective
420
- remove_perfect_tenses
66
+ def apply_parts_of_speech!
67
+ @stem_deriver = LatinverbStemDeriver.new(self)
68
+ @type_evaluator = LatinVerbTypeEvaluator.new(self)
69
+ @participler = Participler.new(self)
70
+ @infinitivizer = Infinitivizer.new(self)
71
+ @imperative_handler = ImperativesHandler.new(self)
421
72
  end
422
- end# }}}
423
73
 
424
- def remove_perfect_tenses# {{{
425
- # Get perfect system methods
426
- tense_blocks_to_eclipse =
427
- self.methods.grep( /^(active|passive).*(_|past|future)perfect_/ )
74
+ def apply_chart_capabilities!
75
+ @chart_presenter = ChartPresenter.new(self)
76
+ end
428
77
 
429
- # Re-assign their methods to point to a blank TenseBlock, thus
430
- # eclipsing any values thatm ight come in.
431
- tense_blocks_to_eclipse.each do |s|
432
- singleton_class.class_eval do
433
- define_method s do
434
- return TenseBlock.null_tense_block
435
- end
436
- end
78
+ def apply_tenses!
79
+ TenseMethodApplicator.new(self)
437
80
  end
438
- end# }}}
439
81
  end
440
82
  end
441
83
  end
442
84
  end
85
+
86
+ require 'latinverb/paradigmatic_verbs'
@@ -4,7 +4,7 @@ require "minitest/autorun"
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
6
  require 'latinverb'
7
- require 'linguistics/latin/verb/classification_types'
7
+ require 'linguistics_latin'
8
8
 
9
9
  # Internal dependencies
10
10
 
@@ -4,7 +4,7 @@ require "minitest/autorun"
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
6
  require 'latinverb'
7
- require 'linguistics/latin/verb/classification_types'
7
+ require 'linguistics_latin'
8
8
 
9
9
  # Internal dependencies
10
10
 
@@ -4,7 +4,7 @@ require "minitest/autorun"
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
6
  require 'latinverb'
7
- require 'linguistics/latin/verb/classification_types'
7
+ require 'linguistics_latin'
8
8
 
9
9
  # Internal dependencies
10
10
 
@@ -4,7 +4,7 @@ require "minitest/autorun"
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
6
  require 'latinverb'
7
- require 'linguistics/latin/verb/classification_types'
7
+ require 'linguistics_latin'
8
8
 
9
9
  # Internal dependencies
10
10
 
@@ -14,7 +14,7 @@ class TestDeponentThirdConjugation < MiniTest::Unit::TestCase # :nodoc:
14
14
  end
15
15
 
16
16
  def test_depo
17
- assert_equal(Linguistics::Latin::Verb::Classifications::Deponent, @aDep.classification)
17
+ assert_equal(Linguistics::Latin::Verb::Classification::Deponent, @aDep.classification)
18
18
 
19
19
  assert_equal 'sequor', @aDep.active_voice_indicative_mood_present_tense_first_person_singular_number
20
20
  assert_equal 'sequeris', @aDep.active_voice_indicative_mood_present_tense_second_person_singular_number
@@ -4,7 +4,7 @@ require "minitest/autorun"
4
4
 
5
5
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
6
6
  require 'latinverb'
7
- require 'linguistics/latin/verb/classification_types'
7
+ require 'linguistics_latin'
8
8
 
9
9
  # Internal dependencies
10
10
 
@@ -194,7 +194,7 @@ class TestLatinVerbFirstConj < MiniTest::Unit::TestCase # :nodoc:
194
194
  serializedFirstconj = @aFirst.to_json
195
195
  assert(serializedFirstconj)
196
196
 
197
- revivified = JSON.parse serializedFirstconj
197
+ revivified = JSON.load serializedFirstconj
198
198
  assert_equal(6, revivified.active_voice_imperative_mood_present_tense.to_a.length)
199
199
 
200
200
  _test_first_conj_exhaustively_post_reviv revivified
@@ -369,17 +369,13 @@ class TestLatinVerbFirstConj < MiniTest::Unit::TestCase # :nodoc:
369
369
  assert_equal "amatus, amata, amatum esse", a.perfect_passive_infinitive
370
370
  end
371
371
 
372
- def testInstanceMethods
373
- assert @aFirst.instance_methods, "Should respond to #instance_methods"
374
- end
375
-
376
372
  def test_meaning # :nodoc:
377
373
  assert @aFirst.active_voice_indicative_mood_present_tense.meaning
378
374
  end
379
375
 
380
376
  def test_chart
381
- assert @aFirst.respond_to? :chart
382
- assert @aFirst.respond_to? :c
377
+ assert @aFirst.respond_to? :chart, "Should respond to chart method"
378
+ assert @aFirst.respond_to? :c, "Should respond to c alias to chart method"
383
379
  end
384
380
 
385
381
  def test_chart_infinitives
@@ -5,21 +5,21 @@ require 'json'
5
5
 
6
6
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
7
7
  require 'latinverb'
8
- require 'linguistics/latin/verb/classification_types'
8
+ require 'linguistics_latin'
9
9
 
10
10
  # Internal dependencies
11
11
 
12
12
  class TestFreakishVerbs < MiniTest::Unit::TestCase # :nodoc:
13
13
  def test_present_only?
14
14
  v = Linguistics::Latin::Verb::LatinVerb.new 'maerō maēre maīvī maestum'
15
- assert v.present_only?
15
+ assert v.present_only?, "Must be present_only: was #{v.classification}"
16
16
  assert_equal 6, v.active_voice_indicative_mood_perfect_tense.length, "active.indicative.perfect should have length of 6"
17
17
  assert_equal '', v.active_voice_indicative_mood_perfect_tense_first_person_singular_number, "a perfect tense for a present only verb should be empty"
18
18
  end
19
19
 
20
20
  def test_present_only_from_sing
21
21
  v = Linguistics::Latin::Verb::LatinVerb.new 'aiō'
22
- assert v.present_only?
22
+ assert v.present_only?, "Must be present_only: was #{v.classification}"
23
23
 
24
24
  # Primary use of this verb
25
25
  assert_equal 'ait', v.active_voice_indicative_mood_present_tense_third_person_singular_number,
@@ -32,7 +32,7 @@ class TestFreakishVerbs < MiniTest::Unit::TestCase # :nodoc:
32
32
 
33
33
  choices.each do |v|
34
34
  vi = Linguistics::Latin::Verb::LatinVerb.new v
35
- assert vi.present_only?, "#{v} must be present only"
35
+ assert vi.present_only?, "Must be present_only: was #{vi.classification}"
36
36
  end
37
37
  end
38
38
 
@@ -5,7 +5,7 @@ require 'json'
5
5
 
6
6
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
7
7
  require 'latinverb'
8
- require 'linguistics/latin/verb/classification_types'
8
+ require 'linguistics_latin'
9
9
 
10
10
  # Internal dependencies
11
11
 
@@ -5,7 +5,7 @@ require 'json'
5
5
 
6
6
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
7
7
  require 'latinverb'
8
- require 'linguistics/latin/verb/classification_types'
8
+ require 'linguistics_latin'
9
9
 
10
10
  # Internal dependencies
11
11