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
@@ -8,7 +8,7 @@ module Linguistics
8
8
 
9
9
  VerbTypes
10
10
 
11
- == DESCRIPTION
11
+ == DESCRIPTION
12
12
 
13
13
  A VerbType is a parent, _conceptually abstract_ class for tracking
14
14
  classifications of verbs. At the present time it is an empty class. It is
@@ -21,7 +21,19 @@ module Linguistics
21
21
  VerbTypes, therefore, is the module containing these VerbTypes.
22
22
 
23
23
  =end
24
- module VerbTypes
24
+
25
+ module Classification
26
+ class ClassificationType; end
27
+ class Semideponent < ClassificationType; end
28
+ class Deponent < ClassificationType; end
29
+ class Irregular < ClassificationType; end
30
+ class Impersonal < ClassificationType; end
31
+ class Defective < ClassificationType; end
32
+ class Regular < ClassificationType; end
33
+ class PresentOnly < ClassificationType; end
34
+
35
+ end
36
+ module VerbTypes
25
37
  ##
26
38
  #--
27
39
  # == DESCRIPTION
@@ -32,25 +44,15 @@ module Linguistics
32
44
  ##
33
45
  class VerbType # :nodoc:
34
46
  end
35
- class First < VerbType # :nodoc:
36
- end
37
- class Second < VerbType # :nodoc:
38
- end
39
- class Third < VerbType # :nodoc:
40
- end
41
- class ThirdIO < VerbType # :nodoc:
42
- end
43
- class Fourth < VerbType # :nodoc:
44
- end
45
- class Irregular < VerbType # :nodoc:
47
+ class First < VerbType # :nodoc:
46
48
  end
47
- class Deponent < VerbType # :nodoc:
49
+ class Second < VerbType # :nodoc:
48
50
  end
49
- class Defective < VerbType # :nodoc:
51
+ class Third < VerbType # :nodoc:
50
52
  end
51
- class Impersonal < VerbType # :nodoc:
53
+ class ThirdIO < VerbType # :nodoc:
52
54
  end
53
- class Semideponent < VerbType # :nodoc:
55
+ class Fourth < VerbType # :nodoc:
54
56
  end
55
57
  end
56
58
  end
@@ -3,7 +3,7 @@ module Linguistics
3
3
  module Latin
4
4
  module Verb
5
5
  class LatinVerb
6
- # :stopdoc:
6
+ # :stopdoc:
7
7
  # active_present_endings: ("ap_"-prefixed)
8
8
  AP_FIRST_AND_SECOND_CONJUG_PERS_ENDINGS = %w(s t mus tis nt)
9
9
  AP_THIRD_CONJUG_PERS_ENDINGS = %w(ō is it imus itis unt)
@@ -19,33 +19,33 @@ module Linguistics
19
19
 
20
20
  # active_perfect_present: ("aperf"-prefixed)
21
21
  APERF_ENDINGS = %w(istī it imus istis ērunt)
22
- APERF_PAST_ENDINGS = PLUPERF_ENDINGS =
22
+ APERF_PAST_ENDINGS = PLUPERF_ENDINGS =
23
23
  %w(eram erās erat erāmus erātis erant)
24
24
  APERF_FUTURE_ENDINGS = %w(erō eris erit erimus eritis erint)
25
25
 
26
26
  # passive endings
27
- PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG =
27
+ PASSIVE_ENDINGS_FIRST_AND_SECOND_CONJG =
28
28
  %w(r ris tur mur minī ntur)
29
- PASSIVE_ENDINGS_OTHER =
29
+ PASSIVE_ENDINGS_OTHER =
30
30
  %w(r eris itur imur iminī untur)
31
31
 
32
- PASS_PERF_PRESENT_ENDINGS = %w(sum es est sumus estis sunt)
32
+ PASS_PERF_PRESENT_ENDINGS = %w(sum es est sumus estis sunt)
33
33
  PASS_PERF_PAST_ENDINGS = %w(eram erās erat erāmus erātis erant)
34
34
  PASS_PERF_FUTURE_ENDINGS = %w(erō eris erit erimus eritis erint)
35
35
 
36
- PASS_PERF_SUBJ_ENDINGS = %w(sim sis sit simus sitis sint)
37
- PASS_PLUPERF_PAST_ENDINGS = %w(essem essēs esset essēmus essētis essent)
38
-
36
+ PASS_PERF_SUBJUNCTIVE_ENDINGS = %w(sim sis sit simus sitis sint)
37
+ PASS_PLUPERF_PAST_ENDINGS = %w(essem essēs esset essēmus essētis essent)
38
+
39
39
  # subjunctive tools
40
40
  # hash for getting a verb's subjunctive stem
41
41
  # based off the W[e] F[ea]r [A] L[ia]r mnemonic
42
- ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS = {
43
- :First => lambda { |x| return x + "ē" },
42
+ ACTIVE_PRESENT_SUBJUNCTIVE_ENDINGS = {
43
+ :First => lambda { |x| return x + "ē" },
44
44
  :Second => lambda { |x| return x + "eā" },
45
- :Third => lambda { |x| return x + "ā" },
45
+ :Third => lambda { |x| return x + "ā" },
46
46
  :Fourth => lambda { |x| return x + "iā" },
47
47
  :ThirdIO => lambda { |x| return x + "iā" }
48
- }
48
+ }
49
49
 
50
50
  # Listing of all defective verbs
51
51
  # See A&G Sec. 205
@@ -192,8 +192,8 @@ module Linguistics
192
192
  :passive_voice_subjunctive_mood_imperfect_tense => "Subjunctive uses apply: commands, contrary to fact wishes, etc." ,
193
193
  :passive_voice_subjunctive_mood_pastperfect_tense => "Subjunctive uses apply: commands, contrary to fact wishes, etc." ,
194
194
  :passive_voice_subjunctive_mood_perfect_tense => "Subjunctive uses apply: commands, contrary to fact wishes, etc." ,
195
- :passive_voice_subjunctive_mood_present_tense => "Subjunctive uses apply: commands, contrary to fact wishes, etc."
196
- }
195
+ :passive_voice_subjunctive_mood_present_tense => "Subjunctive uses apply: commands, contrary to fact wishes, etc."
196
+ }
197
197
  # :startdoc:
198
198
  end
199
199
  end
@@ -1,13 +1,6 @@
1
- # encoding: UTF-8
2
-
3
- require 'linguistics/latin/verb/phonographia'
4
- require 'linguistics/latin/verb/latinverb/auxiliary_classes'
5
- require 'linguistics/latin/verb/deponent_tense_methods'
6
- require 'yaml'
7
-
8
- module Linguistics
9
- module Latin
10
- module Verb
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
11
4
  ##
12
5
  #
13
6
  # Applies mutations to the method calls for semi-deponents.
@@ -53,22 +46,18 @@ module Linguistics
53
46
  return @proxyVerb.send :passive_voice_indicative_mood_futureperfect_tense
54
47
  end
55
48
 
56
- # These should return nothing
57
49
  def passive_voice_indicative_mood_perfect_tense
58
- return TenseBlock.new ['', '', '', '', '', '']
50
+ return TenseBlock.null_tense_block
59
51
  end
60
52
 
61
53
  def passive_voice_indicative_mood_pastperfect_tense
62
- return TenseBlock.new ['', '', '', '', '', '']
63
- #return @proxyVerb.send :passive_voice_indicative_mood_pastperfect_tense
54
+ return TenseBlock.null_tense_block
64
55
  end
65
56
  def passive_voice_indicative_mood_futureperfect_tense
66
- return TenseBlock.new ['', '', '', '', '', '']
67
- #return @proxyVerb.send :passive_voice_indicative_mood_futureperfect_tense
57
+ return TenseBlock.null_tense_block
68
58
  end
69
59
 
70
60
  # Subjunctives: 2 active, 2 passive
71
-
72
61
  def active_voice_subjunctive_mood_present_tense
73
62
  return @proxyVerb.send :active_voice_subjunctive_mood_present_tense
74
63
  end
@@ -84,12 +73,10 @@ module Linguistics
84
73
  return @proxyVerb.send :passive_voice_subjunctive_mood_pastperfect_tense
85
74
  end
86
75
  def passive_voice_subjunctive_mood_perfect_tense
87
- return TenseBlock.new ['', '', '', '', '', '']
88
- #return @proxyVerb.send :passive_voice_subjunctive_mood_perfect_tense
76
+ return TenseBlock.null_tense_block
89
77
  end
90
78
  def passive_voice_subjunctive_mood_pastperfect_tense
91
- return TenseBlock.new ['', '', '', '', '', '']
92
- #return @proxyVerb.send :passive_voice_subjunctive_mood_pastperfect_tense
79
+ return TenseBlock.null_tense_block
93
80
  end
94
81
  end
95
82
  end
@@ -0,0 +1,118 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'linguistics/latin/verb/phonographia'
4
+ require 'yaml'
5
+
6
+ module Linguistics
7
+ module Latin
8
+ module Verb
9
+ class ImperativeBlock
10
+ def initialize(stem,ppi)
11
+ # In case we get an Array, for JSON revivification
12
+ if stem.class == Array
13
+ @results = stem
14
+ end
15
+
16
+ r = case
17
+ when ppi =~ /āre$/
18
+ [stem, stem+"te"]
19
+ when ppi =~ /ēre$/
20
+ [stem, stem+"te"]
21
+ when ppi =~ /ere$/
22
+ [stem+"e", stem+"ite"]
23
+ when ppi =~ /īre$/
24
+ [stem+"ī", stem+"īte"]
25
+ end
26
+
27
+ r << stem + "tō"
28
+ r << stem + "tōte"
29
+
30
+ r << stem + "tō"
31
+ r << stem + "ntō"
32
+
33
+ @results = r.map{|v| Linguistics::Latin::Phonographia.fix_macrons v}
34
+ end
35
+
36
+ def to_s
37
+ return @results
38
+ end
39
+
40
+ ##
41
+ #
42
+ # Required for serialization
43
+ #
44
+ ##
45
+ def to_json(*a)
46
+ {
47
+ 'json_class' => self.class.name,
48
+ 'data' => @results.map{|i| i.to_json}
49
+ }.to_json(*a)
50
+ end
51
+
52
+ ##
53
+ #
54
+ # Required for deserialization
55
+ #
56
+ ##
57
+ def self.json_create(o)
58
+ new(o['data'])
59
+ end
60
+
61
+ ##
62
+ #
63
+ # Provides Array-like interface to the collection of results.
64
+ #
65
+ ##
66
+ def [](arg)
67
+ @results[arg]
68
+ end
69
+
70
+ ##
71
+ #
72
+ # To Array, useful in serialization
73
+ #
74
+ ##
75
+ def to_a
76
+ return @results
77
+ end
78
+
79
+ ##
80
+ #
81
+ # Add array compatibility support
82
+ #
83
+ ##
84
+ def length; return @results.length; end
85
+
86
+ ##
87
+ #
88
+ # Returns the two, second person imperatives
89
+ #
90
+ ##
91
+ def present(qualifier=nil)
92
+ j=@results[0,2]
93
+ return j if qualifier.nil?
94
+ qualifier = qualifier.to_s
95
+ return j[0] if qualifier =~ /singular/
96
+ return j[1] if qualifier =~ /plural/
97
+ end
98
+
99
+ ##
100
+ #
101
+ # Returns the four, second and third person future imperatives
102
+ #
103
+ ##
104
+ def future(qualifier=nil)
105
+ return @results[2,4] if qualifier.nil?
106
+ end
107
+
108
+ def method_missing(sym,*args)
109
+ if (sym =~ /^(present|future)_tense_(.*)/)
110
+ self.send($1.to_sym, $2)
111
+ else
112
+ super
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,39 @@
1
+ module Linguistics
2
+ module Latin
3
+ module Verb
4
+ ##
5
+ #
6
+ # The InfinitiveBlock holds the infinitives associated with a given
7
+ # verb. The known infinitives are the following:
8
+ #
9
+ ##
10
+ class InfinitiveBlock
11
+ attr_reader :infinitive_methods
12
+ def initialize(s)
13
+ if s.is_a? Hash
14
+ @infinitive_methods = s.keys
15
+ end
16
+
17
+ @infinitive_methods.each do |k|
18
+ v=s[k]
19
+ singleton_class.class_eval do
20
+ define_method k.to_sym do
21
+ return v
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ ##
28
+ #
29
+ # Required for deserialization
30
+ #
31
+ ##
32
+ def self.json_create(o)
33
+ new(o['data'])
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+