latinirb 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33a4eb72ec314b4bf5d1675a36249098b3a94b8e
4
+ data.tar.gz: d9211cd70e5f8ed8d06700d3470d12f21db7d2d0
5
+ SHA512:
6
+ metadata.gz: 2a7a7c9863e7990fe8ba045022c475273930fa172bcec99c28d950eb5f5006f0fe742ef95630a30454ac8c004d92af070282d04b2f94ac27fdba97fdfc98337b
7
+ data.tar.gz: eeb287faed0fc71ebefb8a1058db91717e8d050676eee4b5319517233f330a89b1c3413dfb0c4263720504ca795e76071bea06e807a1dc9399102250aeaffb8e
data/Gemfile.lock ADDED
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ latinirb (0.3.1)
5
+ activesupport (>= 4)
6
+ latinverb (~> 0.9.4)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activesupport (4.0.0)
12
+ i18n (~> 0.6, >= 0.6.4)
13
+ minitest (~> 4.2)
14
+ multi_json (~> 1.3)
15
+ thread_safe (~> 0.1)
16
+ tzinfo (~> 0.3.37)
17
+ atomic (1.1.14)
18
+ byebug (2.2.2)
19
+ columnize (~> 0.3.6)
20
+ debugger-linecache (~> 1.2.0)
21
+ columnize (0.3.6)
22
+ debugger-linecache (1.2.0)
23
+ i18n (0.6.5)
24
+ json (1.8.1)
25
+ latinverb (0.9.4)
26
+ activesupport
27
+ linguistics_latin
28
+ macronconversions
29
+ rake
30
+ rdoc
31
+ linguistics_latin (0.0.1)
32
+ macronconversions (0.0.1)
33
+ minitest (4.7.5)
34
+ multi_json (1.8.2)
35
+ rake (10.1.0)
36
+ rdoc (4.0.1)
37
+ json (~> 1.4)
38
+ thread_safe (0.1.3)
39
+ atomic
40
+ tzinfo (0.3.38)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ byebug
47
+ latinirb!
data/README.markdown CHANGED
@@ -4,7 +4,8 @@
4
4
 
5
5
  LatinIRB is an IRB session in which a user can interact with paradigmatic
6
6
  Latin verbs (`@aFirst`, `@aSecond`, `@aThird`, `@aThirdIO`, `@aFourth`) as
7
- calculated heuristically by the LatinVerb library.
7
+ calculated heuristically by the
8
+ [LatinVerb](https://github.com/sgharms/LatinVerb) library.
8
9
 
9
10
  The methods of chief interest will be those that are _vectors_ within the
10
11
  LatinVerb parlance i.e. methods that uniquely identify a specific conjugated
@@ -14,9 +15,9 @@ An primary use case would be:
14
15
 
15
16
  @aFirst.active\_voice\_indicative\_mood\_present\_tense\_first\_person\_singular\_number #=> amō
16
17
 
17
- Upon opening the script, the student may play with verbs offered for
18
+ Upon opening the session, the student may play with verbs offered for
18
19
  exploration. These are the standard paradigmatics verbs presented in
19
- Wheelock:
20
+ Wheelock as well as three core irregular verbs:
20
21
 
21
22
  <table>
22
23
  <tr><th>Varible </th> <th>Parts </th> <th> Meaning</th></tr>
@@ -25,6 +26,9 @@ Wheelock:
25
26
  <tr><td>@aThird </td> <td>agō agere ēgī actum </td> <td> to do / lead / undertake</td></tr>
26
27
  <tr><td>@aThirdIO</td> <td>capiō capere cēpī captum </td> <td> to grab / seize</td></tr>
27
28
  <tr><td>@aFourth </td> <td>audiō audīre audīvī auditum</td> <td> to hear</td></tr>
29
+ <tr><td>@toBe </td> <td>sum esse fuī futūrus</td> <td> to be </td></tr>
30
+ <tr><td>@toCarry </td> <td>ferō ferre tulī lātum</td> <td> to carry </td></tr>
31
+ <tr><td>@toCome </td> <td>eō īre īvī itum</td> <td> to come </td></tr>
28
32
  </table>
29
33
 
30
34
  ## INSTANTIATING
@@ -51,33 +55,30 @@ both understand it.
51
55
 
52
56
  LatinVerb.new %w(amō amāre amāvī amatum)
53
57
 
54
- ## EXECUTING METHODS
55
-
56
- Every verb in latin is a "vector" comprised of the voice / mood / tense /
57
- number / and person
58
-
59
58
  ### CHART VIEW
60
59
 
61
- *Currently Unimplemented: 1 June 2011: Implementation underway*
62
-
63
- To view the chart of a verb, use LatinVerb.chart\_display. This is a basic
60
+ To view the chart of a verb, use LatinVerb.chart. This is a basic
64
61
  chart that will look familiar to students.
65
62
 
63
+ ## EXECUTING METHODS
64
+
65
+ Every verb in latin is a "vector" comprised of the voice / mood / tense /
66
+ number / and person.
67
+
66
68
  ### SINGULAR VECTOR
67
69
 
68
- As such methods are of the form
70
+ As such methods are of the form:
69
71
 
70
- (active|passive)\_voice\_(indicative|subjunctive)\_mood\_(present|imperfect|perfect|pastperfect|futureperfect|etc.)tense\_first\_person\_singular\_number
72
+ (active|passive)\_voice\_(indicative|subjunctive)\_mood\_(present|imperfect|perfect|pastperfect|futureperfect|etc.)tense\_(first|second|third)\_person\_(singular|plural)\_number
71
73
 
72
- This will return a single value. Where the result is ambiguous (e.g. 'number' is not provided) multiple values are returned.
73
- an exhaustive list of options follows below.
74
+ This will return a single value. Where the result is ambiguous (e.g. 'number'
75
+ is not provided) multiple values are returned. an exhaustive list of options
76
+ follows below.
74
77
 
75
78
  ### MULTIPLEX VECTORS
76
79
 
77
- Several convenience methods exist which load multiple tenses at the same time such as "present system" or "perfect system". These
78
- methods load the tenses into the @collections iVar associated with the LatinVerb. This value can be accessed as @collections
79
- is shared per attr\_reader
80
-
80
+ Several convenience methods exist which load multiple vectors at the same time
81
+ such as "present tense." For their invocation, see below
81
82
 
82
83
  ### Comprehensive List of Singular Vectors
83
84
 
@@ -222,19 +223,59 @@ is shared per attr\_reader
222
223
  * LatinVerb.passive\_voice\_subjunctive\_mood\_pastperfect\_tense\_second\_person\_plural\_number
223
224
  * LatinVerb.passive\_voice\_subjunctive\_mood\_pastperfect\_tense\_third\_person\_plural\_number
224
225
 
225
- * LatinVerb.imperatives[0]
226
- * LatinVerb.imperatives[1]
227
-
226
+ * LatinVerb.active\_voice\_imperative\_mood\_future\_tense
227
+ * LatinVerb.active\_voice\_imperative\_mood\_present\_tense
228
+ * LatinVerb.imperatives (_aggregator method_)
229
+
228
230
  * LatinVerb.present\_active\_participle
229
231
  * LatinVerb.future\_active\_participle
230
232
  * LatinVerb.perfect\_passive\_participle
231
233
  * LatinVerb.future\_passive\_participle
232
234
 
233
- * LatinVerb.present\_active\_infinitive
234
- * LatinVerb.perfect\_active\_infinitive
235
+ * LatinVerb.infinitives (_aggregator method_ : returns a keyed hash)
235
236
  * LatinVerb.future\_active\_infinitive
237
+ * LatinVerb.future\_passive\_infinitive
238
+ * LatinVerb.perfect\_active\_infinitive
239
+ * LatinVerb.perfect\_passive\_infinitive
240
+ * LatinVerb.present\_active\_infinitive
236
241
  * LatinVerb.present\_passive\_infinitive
237
- * LatinVerb.perfect\_passive\_infinitive)
242
+
243
+ ### Ambiguous Methods
244
+ A voice, mood, and tense are all required for resolution of answers.
245
+ LatinVerb does not repsect ambiguity in those vectors. It _does_ respect
246
+ ambiguity in the person and number specifiers. Thus, you *may* say:
247
+
248
+
249
+ * LatinVerb.active\_voice\_indicative\_mood\_present\_tense\_first\_person
250
+ * LatinVerb.active\_voice\_indicative\_mood\_present\_tense\_singular\_number
251
+
252
+ This will return an array containing all possible candidates. Thus, for
253
+ each of the items below <em>(first|second|third)_person</em> or
254
+ <em>(singular|plural)_number</em> may be postpended.
255
+
256
+ * LatinVerb.active\_voice\_imperative\_mood\_future\_tense
257
+ * LatinVerb.active\_voice\_imperative\_mood\_present\_tense
258
+ * LatinVerb.active\_voice\_indicative\_mood\_future\_tense
259
+ * LatinVerb.active\_voice\_indicative\_mood\_futureperfect\_tense
260
+ * LatinVerb.active\_voice\_indicative\_mood\_imperfect\_tense
261
+ * LatinVerb.active\_voice\_indicative\_mood\_pastperfect\_tense
262
+ * LatinVerb.active\_voice\_indicative\_mood\_perfect\_tense
263
+ * LatinVerb.active\_voice\_indicative\_mood\_present\_tense
264
+ * LatinVerb.active\_voice\_subjunctive\_mood\_imperfect\_tense
265
+ * LatinVerb.active\_voice\_subjunctive\_mood\_pastperfect\_tense
266
+ * LatinVerb.active\_voice\_subjunctive\_mood\_perfect\_tense
267
+ * LatinVerb.active\_voice\_subjunctive\_mood\_present\_tense
268
+ * LatinVerb.passive\_voice\_indicative\_mood\_future\_tense
269
+ * LatinVerb.passive\_voice\_indicative\_mood\_futureperfect\_tense
270
+ * LatinVerb.passive\_voice\_indicative\_mood\_imperfect\_tense
271
+ * LatinVerb.passive\_voice\_indicative\_mood\_pastperfect\_tense
272
+ * LatinVerb.passive\_voice\_indicative\_mood\_perfect\_tense
273
+ * LatinVerb.passive\_voice\_indicative\_mood\_present\_tense
274
+ * LatinVerb.passive\_voice\_subjunctive\_mood\_imperfect\_tense
275
+ * LatinVerb.passive\_voice\_subjunctive\_mood\_pastperfect\_tense
276
+ * LatinVerb.passive\_voice\_subjunctive\_mood\_perfect\_tense
277
+ * LatinVerb.passive\_voice\_subjunctive\_mood\_present\_tense
278
+
238
279
 
239
280
  ## AUTHOR
240
281
 
data/Rakefile CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'bundler'
2
- require "rake/rdoctask"
2
+ require "rdoc/task"
3
+ require "rake/testtask"
3
4
 
4
5
  Bundler::GemHelper.install_tasks
5
6
 
6
- # Generate documentation
7
- Rake::RDocTask.new do |rd|
8
- rd.rdoc_files.include("lib/**/*.rb")
9
- rd.rdoc_dir = "rdoc"
10
- end
7
+ task :default => :test
8
+
9
+ RDoc::Task.new do |rd|
10
+ rd.rdoc_dir = "rdoc"
11
+ rd.rdoc_files.include("lib/**/*.rb")
12
+ end
11
13
 
12
- #Added to get testing working
13
- require 'rake/testtask'
14
14
  Rake::TestTask.new(:test)
data/bin/latinirb CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Add the gem libraries to the Ruby path
4
- $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
5
-
6
- require 'latinirb'
3
+ require 'active_support/all'
4
+ require 'LatinIRB'
7
5
  Linguistics::Latin::Util::LatinIRB.begin
data/latinirb.gemspec CHANGED
@@ -12,18 +12,13 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Gem designed to explore verbs created by LatinVerb}
13
13
  s.description = %q{This gem takes initial data describing a LatinVerb and allows this is be instantiated into an IRB session. Here the verb can be queried or displayed.}
14
14
 
15
-
16
- s.rubyforge_project = "latinverb"
17
-
18
15
  s.files = `git ls-files`.split("\n")
19
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
18
  s.require_paths = ["lib"]
22
19
 
23
- s.add_runtime_dependency 'latinverb', '>= 0.9.0'
24
- s.add_runtime_dependency 'macronconversions'
25
- s.add_runtime_dependency 'verbvector'
26
- s.add_runtime_dependency 'active_support', '>= 3.0'
27
-
20
+ s.add_development_dependency 'byebug'
28
21
 
22
+ s.add_runtime_dependency 'latinverb', '~> 0.9.5'
23
+ s.add_runtime_dependency 'activesupport', '>= 4'
29
24
  end
data/lib/LatinIRB.rb CHANGED
@@ -3,9 +3,6 @@
3
3
  require 'irb'
4
4
  require 'irb/completion'
5
5
  require 'latinverb'
6
- require 'latinirb/paradigmatic_verbs'
7
- require 'macronconversions'
8
- require 'pp'
9
6
 
10
7
  # Monkey-patch to change the gets behavior. In the gem, the FileInputMethod
11
8
  # class's 'gets' method always prints out what was read. This should be
@@ -37,7 +34,7 @@ module Linguistics
37
34
  # object's options and proceed.
38
35
  #
39
36
  #+++
40
-
37
+
41
38
  IRB.setup(nil)
42
39
  @CONF = IRB.conf
43
40
 
@@ -58,14 +55,14 @@ module Linguistics
58
55
  # Create an irb object that is programmed to (silently, per above)
59
56
  # source a configuration file that ends with a call to 'irb' itself
60
57
  # after defining several instance variables
61
-
58
+
62
59
  irb = IRB::Irb.new(nil, @CONF[:SCRIPT])
63
60
 
64
61
  # Create a LatinIRB prompt
65
62
  @CONF[:PROMPT][:LATINIRB] = {
66
- :PROMPT_I => "LatinIRB > ",
63
+ :PROMPT_I => "LatinIRB > ",
67
64
  :PROMPT_S => "LatinIRB%l> ",
68
- :PROMPT_C => "LatinIRB > ",
65
+ :PROMPT_C => "LatinIRB > ",
69
66
  :PROMPT_N => "LatinIRB ?> ",
70
67
  :RETURN => " => %s \n",
71
68
  :AUTO_INDENT => true
@@ -82,16 +79,23 @@ module Linguistics
82
79
  # LatinVerb, the full complement of vectors should be provided as
83
80
  # complet-able. IF NOT, then the pairing is passed to the standard
84
81
  # CompletionProc.
85
-
82
+
86
83
  Readline.completion_proc = calculate_completion_proc
87
84
 
88
85
  # We have finished the configuration at this point, so now we need
89
86
  # to kick up the REPL after providing preliminary instruction.
90
87
  puts "Beginning a LatinVerb session."
91
88
 
92
- puts "The following verbs have been made available to this session via latirb.rb:"
89
+ puts "The following verbs have been made available to this session:"
90
+
91
+ # Open the file and extract the names of the variables that can be
92
+ # used for autocompletion
93
+ @irb_ivars =
94
+ File::open(irb.context.io.file_name).readlines.grep(/^@/).map do |x|
95
+ x.sub(/(@\w+)\s.*\n/, "\\1")
96
+ end
97
+ @irb_ivars.each{|x| puts " * #{x}\n"}
93
98
 
94
- instance_variables.grep(/[a-z]/).each{|x| puts " * #{x}"}
95
99
 
96
100
  puts "Tab-completion of the conjugation \"vectors\" is supported."
97
101
 
@@ -119,7 +123,7 @@ module Linguistics
119
123
  # based on the regex of "message."
120
124
  #
121
125
  ##
122
-
126
+
123
127
  def self.select_message(receiver, message, candidates)
124
128
  candidates.grep(/^#{message}/).collect do |e|
125
129
  case e
@@ -144,14 +148,16 @@ module Linguistics
144
148
  ##
145
149
 
146
150
  def self.calculate_completion_proc
147
- proc do |input|
151
+ proc do |input|
148
152
  bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
149
153
 
150
154
  input =~ /^([^."].*)\.([^.]*)$/
151
155
  begin
152
156
  receiver = $1
153
157
  message = Regexp.quote($2)
154
- rObj = instance_variable_get(receiver.to_sym)
158
+
159
+ # Pull the object from the binding
160
+ rObj = eval("instance_variable_get(:#{receiver})", bind)
155
161
  rescue Exception
156
162
  end
157
163
 
@@ -159,13 +165,12 @@ module Linguistics
159
165
  IRB::InputCompletor::select_message(receiver, message, rObj.instance_methods.grep(/^#{message}/))
160
166
  elsif input =~ /^@/
161
167
  # This handles instance variables. input is @someInstanceVariable's @aSomeIn<TAB>
162
- self.select_message(input, input, eval("instance_variables", bind).grep(/^@a/))
168
+ self.select_message input, input, eval("instance_variables", bind).grep(/@[at]/)
163
169
  else
164
170
  IRB::InputCompletor::CompletionProc.call input
165
171
  end
166
172
  end
167
173
  end
168
-
169
174
  end
170
175
  end
171
176
  end
@@ -1,9 +1,8 @@
1
- # encoding: UTF-8
2
1
  module Linguistics
3
2
  module Latin
4
3
  module Util
5
4
  class LatinIRB
6
- VERSION = "0.3.1" # :nodoc:
5
+ VERSION = "0.3.3" # :nodoc:
7
6
  end
8
7
  end
9
8
  end
data/lib/latirb.rb CHANGED
@@ -6,6 +6,11 @@
6
6
  @aThirdIO = Linguistics::Latin::Verb::LatinVerb.new %q(capiō capere cēpī captum)
7
7
  @aFourth = Linguistics::Latin::Verb::LatinVerb.new %q(audiō audīre audīvī auditum)
8
8
 
9
+ # Popular Irregulars
10
+ @toBe = Linguistics::Latin::Verb::LatinVerb.new %q(sum esse fuī futūrus)
11
+ @toCarry = Linguistics::Latin::Verb::LatinVerb.new %q(ferō ferre tulī lātum)
12
+ @toCome = Linguistics::Latin::Verb::LatinVerb.new %q(eō īre ivī itum)
13
+
9
14
  # It's handy to have these two methods defined here for simple tests of the
10
15
  # code and demonstrations.
11
16
 
metadata CHANGED
@@ -1,108 +1,97 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: latinirb
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Steven G. Harms
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-06-04 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: latinverb
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.9.0
24
- type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: macronconversions
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
28
21
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: latinverb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.5
35
34
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: verbvector
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '4'
46
48
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: active_support
50
49
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "3.0"
57
- type: :runtime
58
- version_requirements: *id004
59
- description: This gem takes initial data describing a LatinVerb and allows this is be instantiated into an IRB session. Here the verb can be queried or displayed.
60
- email:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '4'
55
+ description: This gem takes initial data describing a LatinVerb and allows this is
56
+ be instantiated into an IRB session. Here the verb can be queried or displayed.
57
+ email:
61
58
  - steven.harms@gmail.com
62
- executables:
59
+ executables:
63
60
  - latinirb
64
61
  extensions: []
65
-
66
62
  extra_rdoc_files: []
67
-
68
- files:
63
+ files:
69
64
  - .gitignore
70
65
  - Gemfile
66
+ - Gemfile.lock
71
67
  - README.markdown
72
68
  - Rakefile
73
69
  - bin/latinirb
74
70
  - latinirb.gemspec
75
- - latinverb.rb
76
71
  - lib/LatinIRB.rb
77
- - lib/latinirb/paradigmatic_verbs.rb
78
72
  - lib/latinirb/version.rb
79
73
  - lib/latirb.rb
80
74
  homepage: http://rubygems.org/gems/latinverb
81
75
  licenses: []
82
-
76
+ metadata: {}
83
77
  post_install_message:
84
78
  rdoc_options: []
85
-
86
- require_paths:
79
+ require_paths:
87
80
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
100
91
  requirements: []
101
-
102
- rubyforge_project: latinverb
103
- rubygems_version: 1.8.5
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.2
104
94
  signing_key:
105
- specification_version: 3
95
+ specification_version: 4
106
96
  summary: Gem designed to explore verbs created by LatinVerb
107
97
  test_files: []
108
-
data/latinverb.rb DELETED
@@ -1,544 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Latin
4
-
5
- =begin rdoc
6
-
7
- == Description
8
-
9
- LatinVerb is a class for turning a given 4-part string of:
10
-
11
- * active voice, present, first person singular: amō, or amo
12
- * present, active infinitive: amāre, or amare
13
- * present, perfect, first person singular: amāvī, or amavi
14
- * perfect passive participle: amatum, or amatus
15
-
16
- Into a fully-exploded, fully conjugated Latin verb ( like you would see in
17
- chart forms on Wikipedia et in locis alteriis.
18
-
19
- These are traditionally given in Wheelock as:
20
- <tt>amō, amāre, amāvī, amatum</tt>
21
-
22
- Philosophically, in this class, we keep attributes and methods which are
23
- used to define the meta-structure of the verb. The specific verb calls
24
- ("Give me the present active participles" or "Give me the present tense
25
- active indicative class") are handled metaprogrammatically and held
26
- in Latin::LatinConjugation.
27
-
28
- =end
29
-
30
-
31
- class LatinVerb < Latin::LatinWord
32
- include Latin::Conjugation
33
- include Latin::Display
34
- =begin
35
-
36
- Scalar, created during initialization
37
- These are iVar's pointing to the “four principal parts” of a Latin
38
- verb.
39
-
40
- =end
41
-
42
- attr_reader :first_pers_singular, :pres_act_inf,
43
- :first_pers_perf, :pass_perf_part, :conjugation
44
-
45
- =begin
46
-
47
- Conjugation state, set by metapgrogrammatically handling the method
48
- call. Latin verbs have voice, mood, tense, number, and person. The
49
- :voice, :mood, etc. iVars will trap this. The default mode
50
- use case is to return all number / person “nodes” in a given
51
- tense. As such, the number and person are not stored here as iVars.
52
-
53
- =end
54
-
55
- attr_reader :voice, :mood, :tense, :number, :person
56
-
57
- =begin
58
-
59
- Here are iVars that are used in calculation of nodes.
60
-
61
- Stem is a place to store the verb stem e.g. amare=>ama, dicere => dic
62
- Vector is the original method that's passed. As mentioned above, we
63
- take a metaprogrammatic approach to handling method calls to the
64
- object. @vector records the method call that is trapped by
65
- method_missing?(id,*opts)
66
-
67
- Participal stem is used as the base for forming participles.
68
-
69
- Response is stored. It is a hash
70
- with only one pair: the name of the collection accessed, and the block
71
- of nodes ( or a single node, if it has been defined in such an
72
- explicit fashion )
73
-
74
- Collections is is where the displayable payload is stored.
75
-
76
- =end
77
-
78
- attr_reader :stem, :participial_stem, :vector, :response,
79
- :collections
80
-
81
- =begin
82
-
83
- Array
84
-
85
- Four_pp is an aray of the four principal parts ( headers on listings)
86
-
87
- =end
88
-
89
- attr_reader :four_pp
90
-
91
- =begin
92
-
93
- ##############################################################################
94
- METHOD DECLARATION
95
- ##############################################################################
96
-
97
- =end
98
-
99
- =begin rdoc
100
-
101
- <b>Arguments</b>: Array containing 4 principal parts
102
-
103
- <b>Attribs Used</b>: N/A
104
-
105
- <b>Attribs Set</b>: @four_pp, @first_pers_singular, @pres_act_inf,
106
- @first_pers_perf, @pass_perf_part, @four_pp,
107
- @voice_mood_matrix, @stem ( via #calculate_stem)
108
-
109
- *Returns*: Instance of LatinVerb
110
-
111
- *Purpose*: A LatinVerb is created by passing an array of the four principal
112
- parts that define a Latin Verb. Typically these are: They are defined in an array:
113
- <tt>amō amāre amāvī amatum</tt>.
114
-
115
- =end
116
-
117
- def initialize(*params)
118
-
119
- # Creates an array of LatinWords for each of the passed-in parameters
120
- # Each principal part is given its own iVar
121
-
122
- @four_pp = params[0].map { |a_principal_part| Latin::LatinWord.new(a_principal_part) }
123
-
124
- if @four_pp.length != 4
125
- deponent_handler if @four_pp[2] =~ /sum$/
126
- end
127
-
128
- irregular_handler(@four_pp[1])
129
-
130
-
131
- @first_pers_singular, @pres_act_inf,
132
- @first_pers_perf, @pass_perf_part = @four_pp
133
-
134
- # Create a top-level matrix that defines active_indicative /
135
- # passive_indicative, etc.
136
- #
137
- # ____________
138
- # | | X | Y |
139
- # | 1 | a | b |
140
- # | 2 | c | d |
141
- # -------------
142
- #
143
- # In this case we have “voice by mood”
144
-
145
- @voice_mood_matrix = TenseBlock.new( {
146
- :boundaries => 'voice by mood',
147
- :voice => %w(Active Passive),
148
- :mood => %w(Indicative Subjunctive),
149
- :tense => nil,
150
- :default_p => lambda {
151
- |x,y| "#{x.downcase}_voice_#{y.downcase}_mood"
152
- }
153
- }
154
- )
155
-
156
- # Given the 4 PP's, we can now derive the stem
157
- @stem = Latin::LatinWord.new(calculate_stem)
158
-
159
- # Set my conjugation
160
- @conjugation = evaluate_conjugation
161
-
162
- # Calculate participal stem
163
- @participial_stem = Latin::LatinWord.new(calculate_participial_stem)
164
-
165
- # Where to store things to-be displayed
166
- @collections = []
167
-
168
-
169
- end
170
-
171
- =begin rdoc
172
-
173
- *Arguments*: Unrecognized method call, optional arguments
174
-
175
- <b>Attribs Used</b>: N/A
176
-
177
- <b>Attribs Set</b>: @vector
178
-
179
- *Returns*: Instance of LatinVerb
180
-
181
- *Purpose*: The method calls to a verb object can vary in over 100 ways, as such, coding that many methods seemed painful. Accordingly, we trap the unknown method call, parse it, and set iVars.
182
-
183
- Having identified the iVars, we are able to call a hash structure
184
- containing lambdas to do the appropriate processing based on the “vector”
185
- of voice, mood, tense, person, etc.
186
-
187
- =end
188
- def method_missing(id, *args)
189
- # We expect that method calls will be made to the object in the form:
190
- # V.active_voice_indicative_mood_present_tense. Instead of having to
191
- # create all these methods, we will look for unknown methods containing
192
- # the pattern _voice_
193
-
194
- if id.to_s =~ /_voice_/
195
-
196
- @vector = id.to_s
197
-
198
- # This assignation needs to be done each call to the metaprog.
199
- # method because of the event that a verb was called for
200
- # a tense vector, and then a node vector. The first instance's
201
- # filling in of @number, @person will cause the second call to do
202
- # the wrong thing
203
-
204
- @number = @person = nil
205
- evaluate_method(id)
206
-
207
- # In the case that the instance has been used before to get
208
- # a specific vector, then we want to clear it out
209
- @collections=[] if not @person.nil? and not @collections.nil?
210
-
211
- generated_method = [@voice,@mood,@tense].join('_').to_sym
212
-
213
- raise("Method #{generated_method.to_} is not responded to!") unless
214
- self.respond_to?(generated_method)
215
-
216
- raise ("FLAMING DETH: pass to handler method returned nothing!") if
217
- self.send(generated_method.to_sym).nil?
218
-
219
-
220
- @collections <<
221
- conjoin_nodes_with_labels(
222
- self.send(generated_method),
223
- TenseBlock.new( {
224
- :boundaries => 'numbers by persons',
225
- :numbers => %w(Singular Plural),
226
- :persons => %w(First Second Third),
227
- :tense => 'present',
228
- }
229
- )
230
- )
231
- else
232
- super(id)
233
- end
234
- end
235
-
236
- def to_s
237
- display!("\n")
238
- end
239
-
240
- def definition_string
241
- return @four_pp.join(', ').to_s
242
- end
243
- =begin
244
-
245
- ##############################################################################
246
- # PRIVATE METHODS BELOW
247
- ##############################################################################
248
-
249
- =end
250
- private
251
-
252
- =begin rdoc
253
-
254
- *Arguments*: None
255
-
256
- *Attribs Used*: @pres_act_inf
257
-
258
- *Attribs Set*: None
259
-
260
- *Returns*: The “stem” of a Latin Verb
261
-
262
- *Purpose*: Based on the present active infinitive, identify the “stem” and set the @stem iVar.
263
- The method also returns the stem value.
264
-
265
- =end
266
-
267
- def calculate_stem
268
- # For efficiency, if the iVar @stem is defined, don't go through this structure
269
-
270
- pres_act_inf = @pres_act_inf.to_s
271
-
272
- if pres_act_inf =~ /āre$/
273
- return pres_act_inf.gsub(/(.*)āre$/,'\\1ā')
274
- end
275
- if pres_act_inf =~ /ēre$/
276
- return pres_act_inf.gsub(/(.*)ēre$/,'\\1ē')
277
- end
278
- if pres_act_inf =~ /ere$/
279
- if @first_pers_singular =~ /io$/
280
- return pres_act_inf.gsub(/(.*)ere$/,'\\1')
281
- else
282
- return pres_act_inf.gsub(/(.*)ere$/,'\\1')
283
- end
284
- end
285
- if pres_act_inf =~ /īre$/
286
- return pres_act_inf.gsub(/(.*)īre$/,'\\1')
287
- end
288
- end
289
-
290
- =begin rdoc
291
-
292
-
293
- *Arguments*: None
294
-
295
- *Attribs Used*: @pres_act_inf
296
-
297
- *Attribs Set*: @conjugation
298
-
299
- *Returns*: The “stem” of a Latin Verb
300
-
301
- *Purpose*: Based on the present, active infinitive, decide on the conjugation. This method requires that the endings be macron-ized in order to differentiate between _ere_ ( 2nd conjugation ) and _ere_ ( 4th conjugation). It returns the value as a String: <tt>1</tt>, <tt>2</tt>, <tt>3</tt>, <tt>4</tt>, or <tt>3IO</tt> (e.g. <i>duco/ducere</i>)
302
-
303
- =end
304
-
305
- def evaluate_conjugation
306
- ending = @pres_act_inf.get_last_three_characters
307
- returnValue = nil
308
-
309
- if ending =~ /āre$/
310
- returnValue = "1"
311
- end
312
-
313
- if ending =~ /ēre$/
314
- returnValue = "2"
315
- end
316
-
317
- if ending =~ /ere$/
318
- if @first_pers_singular.get_last_three_characters =~ /iō$/
319
- returnValue = "3IO"
320
- else
321
- returnValue = "3"
322
- end
323
- end
324
-
325
- if ending =~ /īre$/
326
- returnValue = "4"
327
- end
328
-
329
- return returnValue
330
- end
331
-
332
- =begin rdoc
333
-
334
- Calculate the participial stem, used in forming participles.
335
-
336
- =end
337
-
338
- def calculate_participial_stem
339
- raise("@pres_act_inf was nil!") if
340
- @pres_act_inf.nil? or @first_pers_singular.nil?
341
-
342
- if @pres_act_inf.to_s =~ /(.*ā)re$/
343
- return $1
344
- end
345
-
346
- if @pres_act_inf.to_s =~ /(.*ē)re$/
347
- return $1
348
- end
349
-
350
- if @pres_act_inf.to_s =~ /(.*)ere$/
351
- match=$1
352
- if @first_pers_singular =~ /iō/
353
- return match + "iē"
354
- else
355
- return match + "e"
356
- end
357
- end
358
-
359
- if @pres_act_inf.to_s =~ /(.*)īre$/
360
- return $1 + "iē"
361
- end
362
- end
363
-
364
-
365
- =begin
366
-
367
- This is used to print out a full vector's nodes. The value
368
- of @vector is used as a title. The nodes that were produced
369
- by means of the lambda are then printed out.
370
-
371
- =end
372
-
373
- def conjoin_nodes_with_labels(nodes,labels)
374
- raise "conjoin_nodes failed to receieve a node or label set" if
375
- nodes.nil? or labels.nil?
376
- paired_node_array=[]
377
-
378
- 0.upto(labels.length-1) do |i|
379
- paired_node_array.push(Latin::LatinNode.new(labels.matrix[i],
380
- nodes[i], {:displayable => 'valuesonly'}) )
381
- end
382
-
383
- tense_label = @vector.capitalize!.split(/_/).join(' ')
384
-
385
- full_tense = Latin::LatinTense.new(tense_label, paired_node_array)
386
-
387
- if @person.nil? and @number.nil? # For handling ...present_tense
388
- return full_tense
389
- elsif @number.nil? and not @person.nil? # number not defined; person yes
390
-
391
- # Find the methods that match the parameter that we were given
392
- matching_methods =
393
- full_tense.verb_methods.map {|x| x if x =~ /#{@person}/}.compact!
394
-
395
- # Call those methods and store the result to an array
396
- ambiguous_results =
397
- matching_methods.map{|aMethod| full_tense.send(aMethod.to_sym)}
398
-
399
- # Return it
400
- return ambiguous_results.join(", ")
401
- elsif not @number.nil? and @person.nil?
402
- # This guy is really just the inverse of the above.
403
-
404
- # Find the methods that match the parameter that we were given
405
- matching_methods =
406
- full_tense.verb_methods.map {|x| x if x =~ /#{@number}/}.compact!
407
-
408
- # Call those methods and store the result to an array
409
- ambiguous_results =
410
- matching_methods.map{|aMethod| full_tense.send(aMethod.to_sym)}
411
-
412
- # Return it
413
- return ambiguous_results.join(", ")
414
-
415
- elsif not @number.nil? and not @person.nil? # fully specified node
416
- locate_string = [@number,'number',@person,'person',].join('_')
417
- return full_tense.send(locate_string.to_sym)
418
- end
419
-
420
- end
421
-
422
- # This method is used internally to evaluate a method call that looks like
423
- # a request for a conjugation. The first descriptor pair is chopped off
424
- # from the given 'name' and the rest is held. The given is sent through
425
- # is recognized? where, if valid, an iVar is set.
426
- #
427
- # e.g. active_voice performs @voice=active
428
- #
429
- # Failure to successfully classify raises an exception
430
- #
431
- # If there is anything left in 'rest', then the function is recursively
432
- # called with 'rest'.
433
- #
434
-
435
- def evaluate_method(name)
436
- command = name.to_s.match(/(\w+?_){2}/).to_s
437
- rest = name.to_s[command.to_s.length..name.to_s.length]
438
-
439
- # If you're at the last term, command does not get loaded
440
- # but rest stays the same.
441
- if command !~ /\w/ and name == rest
442
- command = rest
443
- rest = nil
444
- end
445
-
446
- # We've reached the end
447
- return if command !~ /\w/ and rest !~ /\w/
448
-
449
- # Recurse
450
- evaluate_method(rest) if is_recognized?(command)
451
-
452
- end
453
-
454
- # Given a string of the form "active_voice" ( or a "value/term" pair )
455
- # test its validity by Object.send(term.to_sym, value).
456
-
457
- def is_recognized?(datum)
458
- value, term = datum.split(/_/)
459
- term = "calculate_" + term
460
- send(term.to_sym, value)
461
-
462
- # Return true, because the 'send' call did not throw an exception
463
- return true
464
- end
465
-
466
- # Used to set the voice iVar OR raise an exception
467
- def calculate_voice(param)
468
- if param =~ /^(active|passive)$/i
469
- @voice = param
470
- return
471
- end
472
- raise "Unknown voice: #{param.to_s}, called."
473
- end
474
-
475
- # Used to set the voice iVar OR raise an exception
476
- def calculate_mood(param)
477
- param.gsub!(/\W/, '')
478
- if param =~ /(indicative|subjunctive)/i
479
- @mood = param.downcase
480
- return
481
- end
482
- raise "Unknown mood: #{param.to_s}, called"
483
- end
484
-
485
- # Used to set the voice iVar OR raise an exception
486
- def calculate_tense(param)
487
- param.downcase!
488
- if @mood == "indicative"
489
- # All the legitimate moods in the indicative
490
- if param == "present" or
491
- param == "imperfect" or
492
- param == "future" or
493
- param == "perfect" or
494
- param == "pluperfect" or
495
- param == "pastperfect" or
496
- param == "futureperfect"
497
- @tense = param
498
- end
499
- elsif @mood == "subjunctive"
500
- # All the legitimate moods in the subjunctive
501
- if param == "present" or
502
- param == "imperfect" or
503
- param == "perfect" or
504
- param == "pluperfect" or
505
- param == "pastperfect"
506
- @tense = param
507
- end
508
- else
509
- raise "Tense [#{param}] was found to be invalid."
510
- end
511
- end
512
-
513
- def calculate_person(param)
514
- @person = param.downcase
515
- end
516
-
517
- def calculate_number(param)
518
- @number = param.downcase
519
- end
520
-
521
- def deponent_handler
522
- raise "Sorry, we do not handle (semi-) deponent verbs at this time. It's on the TODO list, thought!"
523
- end
524
-
525
- def irregular_handler(test_infinitive)
526
- if %w(esse nōlle).find{|irregular| test_infinitive.to_s == irregular}
527
- raise "Sorry, we do not handle irregular verbs at this time. It's on the TODO list, thought!"
528
- end
529
- end
530
- end # ends the class
531
-
532
- =begin rdoc
533
-
534
- == Dependencies
535
-
536
- None
537
-
538
- == Author
539
-
540
- Steven G. Harms, http://www.stevengharms.com
541
-
542
- =end
543
- end
544
-
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'macronconversions'
4
-
5
- module Linguistics
6
- module Latin
7
- module Util
8
- class LatinIRB
9
- @aFirst = Linguistics::Latin::Verb::LatinVerb.new Text::Latex::Util::Macronconversions.convert('am\={o} am\={a}re am\={a}v\={\i} amatum', 'mc')
10
- @aSecond = Linguistics::Latin::Verb::LatinVerb.new %q(moneō monēre monvī monitum)
11
- @aThird = Linguistics::Latin::Verb::LatinVerb.new %q(agō agere ēgī actum)
12
- @aThirdIO = Linguistics::Latin::Verb::LatinVerb.new %q(capiō capere cēpī captum)
13
- @aFourth = Linguistics::Latin::Verb::LatinVerb.new %q(audiō audīre audīvī auditum)
14
- end
15
- end
16
- end
17
- end