latinverb 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +28 -6
- data/README.markdown +1 -1
- data/Rakefile +1 -0
- data/latinverb.gemspec +5 -3
- data/lib/latinverb/components/chart_presenter.rb +81 -0
- data/lib/latinverb/components/classifier/strategies/defective_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/deponent_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/impersonal_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/irregular_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/present_only_verb_classification_strategy.rb +21 -0
- data/lib/latinverb/components/classifier/strategies/regular_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/semideponent_verb_classification_strategy.rb +19 -0
- data/lib/latinverb/components/classifier/strategies/verb_classification_strategy.rb +31 -0
- data/lib/latinverb/components/classifier/strategies/very_irregular_verb_classification_strategy.rb +20 -0
- data/lib/latinverb/components/classifier.rb +76 -0
- data/lib/latinverb/components/imperatives_handler.rb +40 -0
- data/lib/latinverb/components/infinitivizer.rb +50 -0
- data/lib/latinverb/components/participler.rb +58 -0
- data/lib/latinverb/components/passive_infinitive_factory.rb +42 -0
- data/lib/latinverb/components/present_only_checker.rb +32 -0
- data/lib/latinverb/components/principal_parts_extractor.rb +35 -0
- data/lib/latinverb/components/stem_deriver.rb +81 -0
- data/lib/latinverb/components/type_evaluator.rb +35 -0
- data/lib/latinverb/components/validator.rb +33 -0
- data/lib/latinverb/components.rb +9 -0
- data/lib/latinverb/dynamic_method_resolver.rb +41 -0
- data/lib/latinverb/errors.rb +10 -0
- data/lib/latinverb/imperative_block/imperative_rule_factory.rb +35 -0
- data/lib/latinverb/imperative_block.rb +71 -0
- data/lib/latinverb/paradigmatic_verbs.rb +21 -0
- data/lib/latinverb/serialization/hash.rb +17 -0
- data/lib/latinverb/serialization/json.rb +41 -0
- data/lib/latinverb/serialization/yaml.rb +15 -0
- data/lib/latinverb/serialization.rb +3 -0
- data/lib/latinverb/tense_block/null_tense_block.rb +12 -0
- data/lib/latinverb/tense_block/vector_resolution_delegate.rb +89 -0
- data/lib/latinverb/tense_block.rb +52 -0
- data/lib/latinverb/tense_method_applicator/defective_checker.rb +21 -0
- data/lib/{linguistics/latin/verb/latinverb/classmethods.rb → latinverb/tense_method_applicator/deponent_string_deriver.rb} +15 -69
- data/lib/latinverb/tense_method_applicator/first_builder.rb +98 -0
- data/lib/latinverb/tense_method_applicator/fourth.rb +100 -0
- data/lib/latinverb/tense_method_applicator/fourth_builder.rb +100 -0
- data/lib/latinverb/tense_method_applicator/irregular_builder.rb +117 -0
- data/lib/latinverb/tense_method_applicator/mutator_for_classification_factory.rb +38 -0
- data/lib/latinverb/tense_method_applicator/mutator_for_verb_type.rb +38 -0
- data/lib/latinverb/tense_method_applicator/mutators/deponent/imperative_mutator.rb +49 -0
- data/lib/latinverb/tense_method_applicator/mutators/deponent/infinitive_mutator.rb +42 -0
- data/lib/latinverb/tense_method_applicator/mutators/deponent/participle_mutator.rb +47 -0
- data/lib/latinverb/tense_method_applicator/mutators/deponent/tense_block_mutator.rb +55 -0
- data/lib/latinverb/tense_method_applicator/mutators/deponent.rb +41 -0
- data/lib/latinverb/tense_method_applicator/mutators/impersonal.rb +27 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_imperative_mood_future_tense_strategy.rb +29 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_imperative_mood_present_tense_strategy.rb +29 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_future_tense_strategy.rb +35 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_futureperfect_tense_strategy.rb +28 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_imperfect_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_pastperfect_tense_strategy.rb +28 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_perfect_tense_strategy.rb +29 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_indicative_mood_present_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_imperfect_tense_strategy.rb +29 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_pastperfect_tense_strategy.rb +30 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_perfect_tense_strategy.rb +30 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/active_voice_subjunctive_mood_present_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/imperatives.rb +53 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_future_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_futureperfect_tense_strategy.rb +27 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_imperfect_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_pastperfect_tense_strategy.rb +27 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_perfect_tense_strategy.rb +27 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_indicative_mood_present_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_imperfect_tense_strategy.rb +30 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_pastperfect_tense_strategy.rb +33 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_perfect_tense_strategy.rb +33 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/passive_voice_subjunctive_mood_present_tense_strategy.rb +24 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant/triplicate_and_pluralize_formatters.rb +26 -0
- data/lib/latinverb/tense_method_applicator/mutators/invariant.rb +65 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular/infinitives_builder.rb +35 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular/json_deserializer.rb +52 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular/json_revivifier.rb +48 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular/participles_builder.rb +35 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular/present_only_irregular_mask.rb +37 -0
- data/lib/latinverb/tense_method_applicator/mutators/irregular.rb +25 -0
- data/lib/latinverb/tense_method_applicator/mutators/present_only.rb +18 -0
- data/lib/latinverb/tense_method_applicator/mutators/regular.rb +17 -0
- data/lib/latinverb/tense_method_applicator/mutators/semideponent.rb +88 -0
- data/lib/latinverb/tense_method_applicator/perfect_tense_remover.rb +26 -0
- data/lib/latinverb/tense_method_applicator/second_builder.rb +105 -0
- data/lib/latinverb/tense_method_applicator/tense_methods_vectorizer.rb +73 -0
- data/lib/latinverb/tense_method_applicator/third_builder.rb +93 -0
- data/lib/latinverb/tense_method_applicator/thirdio_builder.rb +100 -0
- data/lib/latinverb/tense_method_applicator.rb +55 -0
- data/lib/latinverb/version.rb +2 -3
- data/lib/latinverb.rb +63 -419
- data/test/{testDeponentFirstConjugation.rb → integration/deponent_first_conjugation_test.rb} +1 -1
- data/test/{testDeponentFourthConjugation.rb → integration/deponent_fourth_conjugation_test.rb} +1 -1
- data/test/{testDeponentSecondConjugation.rb → integration/deponent_second_conjugation_test.rb} +1 -1
- data/test/{testDeponentThirdConjugation.rb → integration/deponent_third_conjugation_test.rb} +2 -2
- data/test/{testDeponentThirdIOConjugation.rb → integration/deponent_third_io_conjugation_test.rb} +1 -1
- data/test/{testFirstConjugation.rb → integration/first_conjugation_test.rb} +3 -7
- data/test/{testFreakishVerbs.rb → integration/freakish_vs.rb_test.rb} +4 -4
- data/test/{testIrregularSum.rb → integration/irregular_sum_test.rb} +1 -1
- data/test/{testIrregulars.rb → integration/irregulars_test.rb} +1 -1
- data/test/{testLatinVerb.rb → integration/latin_verb_test.rb} +5 -25
- data/test/{testThirdConjugation.rb → integration/third_conjugation_test.rb} +19 -21
- data/test/unit/latinverb_accessible_reader_test.rb +18 -0
- data/test/unit/principal_parts_extractor_test.rb +33 -0
- metadata +151 -79
- data/lib/latinverb/chart.rb +0 -94
- data/lib/linguistics/latin/verb/classification_types.rb +0 -61
- data/lib/linguistics/latin/verb/constants.rb +0 -201
- data/lib/linguistics/latin/verb/deponent_tense_methods.rb +0 -85
- data/lib/linguistics/latin/verb/imperative_block.rb +0 -118
- data/lib/linguistics/latin/verb/infinitive_block.rb +0 -39
- data/lib/linguistics/latin/verb/infinitives.rb +0 -212
- data/lib/linguistics/latin/verb/irregulars.rb +0 -4393
- data/lib/linguistics/latin/verb/latinverb/data.rb +0 -87
- data/lib/linguistics/latin/verb/latinverb/defective_checker.rb +0 -17
- data/lib/linguistics/latin/verb/latinverb/deponent.rb +0 -159
- data/lib/linguistics/latin/verb/latinverb/display.rb +0 -22
- data/lib/linguistics/latin/verb/latinverb/impersonal.rb +0 -34
- data/lib/linguistics/latin/verb/latinverb/irregular.rb +0 -83
- data/lib/linguistics/latin/verb/latinverb/latin_verb_type_evaluator.rb +0 -32
- data/lib/linguistics/latin/verb/latinverb/latinverb_classifier.rb +0 -100
- data/lib/linguistics/latin/verb/latinverb/latinverb_input_sanitizer.rb +0 -32
- data/lib/linguistics/latin/verb/latinverb/latinverb_pp_extractor.rb +0 -106
- data/lib/linguistics/latin/verb/latinverb/metaprogramming.rb +0 -80
- data/lib/linguistics/latin/verb/latinverb/semideponent.rb +0 -28
- data/lib/linguistics/latin/verb/latinverb/validation.rb +0 -42
- data/lib/linguistics/latin/verb/latinverb/verbvector_description.rb +0 -50
- data/lib/linguistics/latin/verb/participle_block.rb +0 -36
- data/lib/linguistics/latin/verb/participles.rb +0 -202
- data/lib/linguistics/latin/verb/phonographia.rb +0 -109
- data/lib/linguistics/latin/verb/supine.rb +0 -42
- data/lib/linguistics/latin/verb/tense_block.rb +0 -227
- data/lib/linguistics/latin/verb/tense_definitions/first.rb +0 -92
- data/lib/linguistics/latin/verb/tense_definitions/fourth.rb +0 -92
- data/lib/linguistics/latin/verb/tense_definitions/impersonal.rb +0 -25
- data/lib/linguistics/latin/verb/tense_definitions/invariant.rb +0 -613
- data/lib/linguistics/latin/verb/tense_definitions/irregular.rb +0 -82
- data/lib/linguistics/latin/verb/tense_definitions/second.rb +0 -97
- data/lib/linguistics/latin/verb/tense_definitions/third.rb +0 -86
- data/lib/linguistics/latin/verb/tense_definitions/third_io.rb +0 -91
- data/test/testDeserializeInfinitives.rb +0 -36
- /data/test/{testAmbiguousLookups.rb → integration/ambiguous_lookups_test.rb} +0 -0
- /data/test/{testClusterResolution.rb → integration/cluster_resolution_test.rb} +0 -0
- /data/test/{testDataStructures.rb → integration/data_structures_test.rb} +0 -0
- /data/test/{testDefectSemiImp.rb → integration/defect_semi_imp_test.rb} +0 -0
- /data/test/{testFourthConjugation.rb → integration/fourth_conjugation_test.rb} +0 -0
- /data/test/{testImperativeBlock.rb → integration/imperative_block_test.rb} +0 -0
- /data/test/{testMacronRules.rb → integration/macron_rules_test.rb} +0 -0
- /data/test/{testSecondConjugation.rb → integration/second_conjugation_test.rb} +0 -0
- /data/test/{testThirdIOConjugation.rb → integration/third_io_conjugation_test.rb} +0 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class LatinVerbPrincipalPartsExtractor
|
6
|
+
def initialize(input_string, classification)
|
7
|
+
@data_string = input_string
|
8
|
+
@classification = classification
|
9
|
+
end
|
10
|
+
|
11
|
+
def principal_parts
|
12
|
+
@data_string.split(/\s+/)
|
13
|
+
end
|
14
|
+
|
15
|
+
def first_person_singular
|
16
|
+
principal_parts[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
def present_active_infinitive
|
20
|
+
principal_parts[1]
|
21
|
+
end
|
22
|
+
|
23
|
+
def first_person_perfect
|
24
|
+
principal_parts[2]
|
25
|
+
end
|
26
|
+
|
27
|
+
def passive_perfect_participle
|
28
|
+
principal_parts[3]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class LatinverbStemDeriver
|
6
|
+
def initialize(verb)
|
7
|
+
@verb = verb
|
8
|
+
end
|
9
|
+
|
10
|
+
def stem
|
11
|
+
verb_is_regular? ? calculate_stem : calculate_deponent_proxy_stem
|
12
|
+
end
|
13
|
+
|
14
|
+
def participial_stem
|
15
|
+
if present_active_infinitive.to_s =~ /(.*ā)re$/
|
16
|
+
return $1
|
17
|
+
end
|
18
|
+
|
19
|
+
if present_active_infinitive.to_s =~ /(.*ē)re$/
|
20
|
+
return $1
|
21
|
+
end
|
22
|
+
|
23
|
+
if present_active_infinitive.to_s =~ /(.*)ere$/
|
24
|
+
match=$1
|
25
|
+
if first_person_singular =~ /iō/
|
26
|
+
return match + "iē"
|
27
|
+
else
|
28
|
+
return match + "e"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if present_active_infinitive.to_s =~ /(.*)īre$/
|
33
|
+
return $1 + "iē"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def calculate_deponent_proxy_stem
|
40
|
+
DeponentStringDeriver.new(@verb.original_string).proxy_string.split(/\s+/)[1]
|
41
|
+
end
|
42
|
+
|
43
|
+
def verb_is_regular?
|
44
|
+
@verb.classifier.regular?
|
45
|
+
end
|
46
|
+
|
47
|
+
def present_active_infinitive
|
48
|
+
@verb.present_active_infinitive
|
49
|
+
end
|
50
|
+
|
51
|
+
def first_person_singular
|
52
|
+
@verb.first_person_singular
|
53
|
+
end
|
54
|
+
|
55
|
+
def deponent_or_impersonal?
|
56
|
+
@verb.classifier.deponent? or @verb.classifier.semideponent? or @verb.classifier.impersonal?
|
57
|
+
end
|
58
|
+
|
59
|
+
def calculate_stem
|
60
|
+
if present_active_infinitive =~ /āre$/
|
61
|
+
return present_active_infinitive.gsub(/(.*)āre$/,'\\1ā')
|
62
|
+
end
|
63
|
+
if present_active_infinitive =~ /ēre$/
|
64
|
+
return present_active_infinitive.gsub(/(.*)ēre$/,'\\1ē')
|
65
|
+
end
|
66
|
+
if present_active_infinitive =~ /ere$/
|
67
|
+
if first_person_singular =~ /iō$/
|
68
|
+
return present_active_infinitive.gsub(/(.*)ere$/,'\\1')
|
69
|
+
else
|
70
|
+
return present_active_infinitive.gsub(/(.*)ere$/,'\\1')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
if present_active_infinitive =~ /īre$/
|
74
|
+
return present_active_infinitive.gsub(/(.*)īre$/,'\\1')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class LatinVerbTypeEvaluator
|
6
|
+
extend Forwardable
|
7
|
+
# "Type" is key stem associated with the verb versus the
|
8
|
+
# classification. i.e. a verb might be "classified" as "Deponent"
|
9
|
+
# but has a "type" of first conjugation e.g. miror / mirari
|
10
|
+
def_delegators :@verb, :first_person_singular, :present_active_infinitive
|
11
|
+
|
12
|
+
def initialize(verb)
|
13
|
+
@verb = verb
|
14
|
+
end
|
15
|
+
|
16
|
+
def type
|
17
|
+
if present_active_infinitive =~ /āre$/
|
18
|
+
Linguistics::Latin::Verb::VerbTypes::First
|
19
|
+
elsif present_active_infinitive =~ /ēre$/
|
20
|
+
Linguistics::Latin::Verb::VerbTypes::Second
|
21
|
+
elsif present_active_infinitive =~ /ere$/
|
22
|
+
first_person_singular =~ /i.$/ ? Linguistics::Latin::Verb::VerbTypes::ThirdIO : Linguistics::Latin::Verb::VerbTypes::Third
|
23
|
+
elsif present_active_infinitive =~ /.+īre$/
|
24
|
+
Linguistics::Latin::Verb::VerbTypes::Fourth
|
25
|
+
elsif (present_active_infinitive =~ /ī$/ and first_person_singular =~ /r$/)
|
26
|
+
LatinVerb.new(DeponentStringDeriver.new(@verb.original_string).proxy_string).verb_type
|
27
|
+
else
|
28
|
+
Linguistics::Latin::Verb::VerbTypes::Irregular
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class Validator
|
6
|
+
def initialize(verb)
|
7
|
+
@verb = verb
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid?
|
11
|
+
has_original_string? && has_classification? && has_stem?
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def has_original_string?
|
17
|
+
!@verb.original_string.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_classification?
|
21
|
+
!@verb.classification.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_stem?
|
25
|
+
return true if @verb.irregular?
|
26
|
+
!@verb.stem.nil?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require_relative './components/chart_presenter'
|
2
|
+
require_relative './components/infinitivizer'
|
3
|
+
require_relative './components/classifier'
|
4
|
+
require_relative './components/principal_parts_extractor'
|
5
|
+
require_relative './components/type_evaluator'
|
6
|
+
require_relative './components/participler'
|
7
|
+
require_relative './components/validator'
|
8
|
+
require_relative './components/imperatives_handler'
|
9
|
+
require_relative './components/stem_deriver'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class DynamicMethodResolver
|
6
|
+
def initialize(verb, method_name)
|
7
|
+
@verb = verb
|
8
|
+
@method_name = method_name.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def components
|
12
|
+
@method_name.split('_')
|
13
|
+
end
|
14
|
+
|
15
|
+
def tense_method
|
16
|
+
Array(components[0..5]).join('_')
|
17
|
+
end
|
18
|
+
|
19
|
+
def vector_specifier
|
20
|
+
Array(components[6..-1]).join('_')
|
21
|
+
end
|
22
|
+
|
23
|
+
def supported_method?
|
24
|
+
!(tense_method.nil? || vector_specifier.nil?) && @method_name.match(/_/)
|
25
|
+
end
|
26
|
+
|
27
|
+
def apply!
|
28
|
+
if @verb.respond_to?(tense_method.to_sym)
|
29
|
+
tense_block = @verb.send(tense_method.to_sym)
|
30
|
+
return false if tense_block.nil?
|
31
|
+
tense_block.send(vector_specifier.to_sym)
|
32
|
+
else
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class ImperativeBlock
|
5
|
+
class ImperativeRuleFactory
|
6
|
+
MAPPING = {
|
7
|
+
First: ->(stem, plural_present_imperative){ [stem, stem+"te"] },
|
8
|
+
Second: ->(stem, plural_present_imperative){ [stem, stem+"te"] },
|
9
|
+
ThirdIO: ->(stem, plural_present_imperative){ [stem+"e", stem+"ite"] },
|
10
|
+
Third: ->(stem, plural_present_imperative){ [stem+"e", stem+"ite"] },
|
11
|
+
Fourth: ->(stem, plural_present_imperative){ [stem+"ī", stem+"īte"] }
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize(verb)
|
15
|
+
@verb = verb
|
16
|
+
end
|
17
|
+
|
18
|
+
def present_tense_rule
|
19
|
+
MAPPING[type_key] || raise("Could not find mapping for #{type_key}")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def verb_type
|
25
|
+
@verb.verb_type
|
26
|
+
end
|
27
|
+
|
28
|
+
def type_key
|
29
|
+
verb_type.ordinal_name_key
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative './imperative_block/imperative_rule_factory'
|
2
|
+
|
3
|
+
module Linguistics
|
4
|
+
module Latin
|
5
|
+
module Verb
|
6
|
+
class ImperativeBlock
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :@results, :[], :to_a, :length
|
9
|
+
|
10
|
+
include Linguistics::Latin::Phonographia
|
11
|
+
def initialize(stem, plural_present_imperative, verb)
|
12
|
+
@stem = stem
|
13
|
+
@plural_present_imperative = plural_present_imperative
|
14
|
+
@verb = verb
|
15
|
+
|
16
|
+
if @verb.classification == Linguistics::Latin::Verb::Classification::Deponent
|
17
|
+
@results = form_imperative_base_for_deponent
|
18
|
+
add_additional_imperative_forms_for_deponent
|
19
|
+
else
|
20
|
+
@results = form_imperative_base
|
21
|
+
add_additional_imperative_forms
|
22
|
+
end
|
23
|
+
|
24
|
+
@results.map{|v| fix_macrons v}
|
25
|
+
end
|
26
|
+
|
27
|
+
def form_imperative_base_for_deponent
|
28
|
+
[@verb.stem, @verb.active_voice_indicative_mood_present_tense.plural_number_second_person, @verb.active_voice_indicative_mood_present_tense_third_person_singular_number.sub(/tur\z/, 'tor')]
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_additional_imperative_forms_for_deponent
|
32
|
+
end
|
33
|
+
|
34
|
+
def present_tense_singular_number
|
35
|
+
present('singular')
|
36
|
+
end
|
37
|
+
|
38
|
+
def present_tense_plural_number
|
39
|
+
present('plural')
|
40
|
+
end
|
41
|
+
|
42
|
+
def future(qualifier=nil)
|
43
|
+
return @results[2,4] if qualifier.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
def present(qualifier=nil)
|
47
|
+
j = @results[0,2]
|
48
|
+
return j if qualifier.nil?
|
49
|
+
qualifier = qualifier.to_s
|
50
|
+
return j[0] if qualifier =~ /singular/
|
51
|
+
return j[1] if qualifier =~ /plural/
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def add_additional_imperative_forms
|
57
|
+
stem = @stem || @verb.instance_variable_get(:@proxyVerb).stem
|
58
|
+
@results << stem + "tō"
|
59
|
+
@results << stem + "tōte"
|
60
|
+
|
61
|
+
@results << stem + "tō"
|
62
|
+
@results << stem + "ntō"
|
63
|
+
end
|
64
|
+
|
65
|
+
def form_imperative_base
|
66
|
+
ImperativeRuleFactory.new(@verb).present_tense_rule.call(@stem, @plural_present_imperative)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
::AFIRST = new('amō amāre amāvī amatum')
|
6
|
+
::ASECOND = LatinVerb.new('moneō monēre monuī monitum')
|
7
|
+
::ATHIRD = LatinVerb.new('agō agere ēgī actum')
|
8
|
+
::ATHIRDIO = LatinVerb.new('capiō capere cēpī captum')
|
9
|
+
::AFOURTH = LatinVerb.new('audiō audīre audīvī auditum')
|
10
|
+
|
11
|
+
::AFIRST_DEP = LatinVerb.new('mīror mīrārī mīrātum')
|
12
|
+
::ASECOND_DEP = LatinVerb.new('vereor verērī veritum')
|
13
|
+
::ATHIRD_DEP = LatinVerb.new('sequor sequī secūtum')
|
14
|
+
::ATHIRDIO_DEP = LatinVerb.new('patior patī passum')
|
15
|
+
::AFOURTH_DEP = LatinVerb.new('partior partīrī partītum')
|
16
|
+
|
17
|
+
::SUM = LatinVerb.new('sum esse fuī futūrus')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
def to_hash
|
6
|
+
methods.grep(/tense\z/).inject({'original_string' => @original_string}) do |memo, tense_block_identifier|
|
7
|
+
ts = tense_block_identifier.to_sym
|
8
|
+
memo[ts] = self.send(ts)
|
9
|
+
memo
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :to_h, :to_hash
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Linguistics
|
4
|
+
module Latin
|
5
|
+
module Verb
|
6
|
+
class LatinVerb
|
7
|
+
def self.json_create(o)
|
8
|
+
new(o)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_json(*a)
|
12
|
+
json_hash = {'json_class' => self.class.name}
|
13
|
+
|
14
|
+
# In the case that we're working with a regular verb, the only thing
|
15
|
+
# we need to save is the original string, since everything can be
|
16
|
+
# re-derived from it easily.
|
17
|
+
unless self.irregular?
|
18
|
+
# While this single string is sufficient to freeze and revivifty
|
19
|
+
# the verb, it means that the JSON structure is rather vacuous.
|
20
|
+
# Given this, the hash is enriched so that the JSON data is
|
21
|
+
# useful. Nevertheless, in the revivification process, only
|
22
|
+
# 'orig_string' is used.
|
23
|
+
%w{original_string classification stem}.each do |k|
|
24
|
+
json_hash[k] = self.send k.to_sym
|
25
|
+
end
|
26
|
+
json_hash['tense_list' ] = {}
|
27
|
+
methods.grep(/tense\z/).each do |t|
|
28
|
+
json_hash['tense_list'][t.to_s] = self.send t.to_sym
|
29
|
+
end
|
30
|
+
json_hash['irregular'] = irregular?
|
31
|
+
return json_hash.to_json(*a)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def pretty_generate
|
36
|
+
JSON.pretty_generate(self.to_h)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class TenseBlock
|
5
|
+
class VectorResolutionDelegate
|
6
|
+
def initialize(results)
|
7
|
+
@results = results
|
8
|
+
end
|
9
|
+
|
10
|
+
def first_person_singular_number
|
11
|
+
@results[0]
|
12
|
+
end
|
13
|
+
|
14
|
+
def singular_number_first_person
|
15
|
+
@results[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
def second_person_singular_number
|
19
|
+
@results[1]
|
20
|
+
end
|
21
|
+
|
22
|
+
def singular_number_second_person
|
23
|
+
@results[1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def third_person_singular_number
|
27
|
+
@results[2]
|
28
|
+
end
|
29
|
+
|
30
|
+
def third_person_singular_number
|
31
|
+
@results[2]
|
32
|
+
end
|
33
|
+
|
34
|
+
def singular_number_third_person
|
35
|
+
@results[2]
|
36
|
+
end
|
37
|
+
|
38
|
+
def first_person_plural_number
|
39
|
+
@results[3]
|
40
|
+
end
|
41
|
+
|
42
|
+
def plural_number_first_person
|
43
|
+
@results[3]
|
44
|
+
end
|
45
|
+
|
46
|
+
def second_person_plural_number
|
47
|
+
@results[4]
|
48
|
+
end
|
49
|
+
|
50
|
+
def plural_number_second_person
|
51
|
+
@results[4]
|
52
|
+
end
|
53
|
+
|
54
|
+
def third_person_plural_number
|
55
|
+
@results[5]
|
56
|
+
end
|
57
|
+
|
58
|
+
def plural_number_third_person
|
59
|
+
@results[5]
|
60
|
+
end
|
61
|
+
|
62
|
+
def first_person
|
63
|
+
[ @results[0], @results[3] ]
|
64
|
+
end
|
65
|
+
|
66
|
+
def second_person
|
67
|
+
[ @results[1], @results[4] ]
|
68
|
+
end
|
69
|
+
|
70
|
+
def third_person
|
71
|
+
[ @results[2], @results[5] ]
|
72
|
+
end
|
73
|
+
|
74
|
+
def singular_number
|
75
|
+
[ @results[0],
|
76
|
+
@results[1],
|
77
|
+
@results[2] ]
|
78
|
+
end
|
79
|
+
|
80
|
+
def plural_number
|
81
|
+
[ @results[3],
|
82
|
+
@results[4],
|
83
|
+
@results[5] ]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative './tense_block/vector_resolution_delegate'
|
2
|
+
require_relative './tense_block/null_tense_block'
|
3
|
+
|
4
|
+
module Linguistics
|
5
|
+
module Latin
|
6
|
+
module Verb
|
7
|
+
class TenseBlock
|
8
|
+
include Linguistics::Latin::Phonographia
|
9
|
+
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators :@results, :[], :empty?, :length, :to_a
|
12
|
+
def_delegators :@resolver, :first_person_singular_number,
|
13
|
+
:singular_number_first_person, :second_person_singular_number,
|
14
|
+
:singular_number_second_person, :third_person_singular_number,
|
15
|
+
:third_person_singular_number, :singular_number_third_person,
|
16
|
+
:first_person_plural_number, :plural_number_first_person,
|
17
|
+
:second_person_plural_number, :plural_number_second_person,
|
18
|
+
:third_person_plural_number, :plural_number_third_person,
|
19
|
+
:first_person, :second_person, :third_person,
|
20
|
+
:singular_number, :plural_number
|
21
|
+
|
22
|
+
attr_reader :meaning, :results
|
23
|
+
|
24
|
+
def initialize(r, opts={})
|
25
|
+
@results = Array(r).map{ |v| fix_macrons(v) }
|
26
|
+
@meaning = opts[:meaning] || ""
|
27
|
+
@resolver = VectorResolutionDelegate.new(@results)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
to_a.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def wordless?
|
35
|
+
!@results.find{ |r| r =~ /\w/ }
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_json(*a)
|
39
|
+
{
|
40
|
+
'json_class' => self.class.name,
|
41
|
+
'data' => @results.map{|i| i.to_json}
|
42
|
+
}.to_json(*a)
|
43
|
+
end
|
44
|
+
|
45
|
+
def TenseBlock.json_create(o)
|
46
|
+
new(o['data'])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Linguistics
|
2
|
+
module Latin
|
3
|
+
module Verb
|
4
|
+
class LatinVerb
|
5
|
+
class DefectiveChecker
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@verb, :first_person_singular, :present_active_infinitive
|
8
|
+
|
9
|
+
def initialize(verb)
|
10
|
+
@verb = verb
|
11
|
+
end
|
12
|
+
|
13
|
+
def defective?
|
14
|
+
Linguistics::Latin::Verb::PRESENT_ONLY.member?(first_person_singular) ||
|
15
|
+
Linguistics::Latin::Verb::PRESENT_ONLY.member?(present_active_infinitive)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|