verbvector 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +12 -7
- data/lib/verbvector.rb +58 -65
- data/lib/verbvector/version.rb +1 -1
- data/test/test_generator.rb +17 -17
- data/test/test_passed_block.rb +82 -0
- metadata +23 -31
data/Rakefile
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
|
+
require 'rdoc/task'
|
|
3
|
+
|
|
2
4
|
Bundler::GemHelper.install_tasks
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
require 'rake/testtask'
|
|
6
|
-
Rake::TestTask.new(:test)
|
|
6
|
+
task :default => :test
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
RDoc::Task.new do | rd |
|
|
9
|
+
rd.rdoc_dir = "rdoc"
|
|
10
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'rake/testtask'
|
|
14
|
+
Rake::TestTask.new do |t|
|
|
15
|
+
t.ruby_opts = [ '-rminitest/pride' ]
|
|
16
|
+
t.verbose = true
|
|
12
17
|
end
|
data/lib/verbvector.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
2
|
-
require
|
|
3
|
-
require 'pp'
|
|
2
|
+
require 'verbvector'
|
|
4
3
|
|
|
5
4
|
# Generalized module for handling lingustics processing
|
|
6
5
|
module Linguistics
|
|
@@ -14,13 +13,9 @@ module Linguistics
|
|
|
14
13
|
# given type of verb (French, Latin, Spanish). I'm not trying to be
|
|
15
14
|
# obscure, but I'm trying to be very generalizable.
|
|
16
15
|
class VerbvectorGenerator
|
|
17
|
-
attr_reader :language, :aspect_list, :vector_list, :cluster_methods,
|
|
16
|
+
attr_reader :language, :aspect_list, :vector_list, :cluster_methods,
|
|
18
17
|
:respondable_methods
|
|
19
|
-
|
|
20
|
-
# Class methods go here
|
|
21
|
-
class << self
|
|
22
|
-
end
|
|
23
|
-
|
|
18
|
+
|
|
24
19
|
# Initialization
|
|
25
20
|
#
|
|
26
21
|
# Takes the descriptive block of the tense structure in a DSL format
|
|
@@ -30,7 +25,7 @@ module Linguistics
|
|
|
30
25
|
@respondable_methods = []
|
|
31
26
|
@cluster_methods = {}
|
|
32
27
|
@language = ""
|
|
33
|
-
|
|
28
|
+
|
|
34
29
|
# Let's remember the difference between instance_ and class_eval.
|
|
35
30
|
#
|
|
36
31
|
# "class_eval sets things up as if you were in the body of a class
|
|
@@ -39,26 +34,26 @@ module Linguistics
|
|
|
39
34
|
# "instance_eval on a class acts as if you were working inside the
|
|
40
35
|
# singleton class of self. Therefore, any methods you define will
|
|
41
36
|
# become class methods." - prog ruby 1.9 v3, prag programmers p.388
|
|
42
|
-
#
|
|
37
|
+
#
|
|
43
38
|
# As such, instance_eval here is about to apply this eval to the
|
|
44
39
|
# eigenclass. That means any instance of this class will have this
|
|
45
40
|
# method.
|
|
46
|
-
instance_eval
|
|
47
|
-
|
|
41
|
+
instance_eval(&b)
|
|
42
|
+
|
|
48
43
|
@aspect_list.sort!
|
|
49
44
|
end
|
|
50
|
-
|
|
45
|
+
|
|
51
46
|
# Vectors are specified at their most atomic
|
|
52
47
|
# Sometimes it is handy to return all the values that match
|
|
53
48
|
# "up to" a given aspect and then uniq'ify them
|
|
54
49
|
|
|
55
|
-
def match_vector_upto_aspect(s)
|
|
56
|
-
@vector_list.compact.sort.grep(/#{s}/).map{ |x|
|
|
50
|
+
def match_vector_upto_aspect(s)
|
|
51
|
+
@vector_list.compact.sort.grep(/#{s}/).map{ |x|
|
|
57
52
|
x.sub(/(^.*#{s}).*/,%q(\1))
|
|
58
|
-
}.uniq
|
|
53
|
+
}.uniq
|
|
59
54
|
end
|
|
60
|
-
|
|
61
|
-
# Creates the anonymous module based on the contents of @vector_list.
|
|
55
|
+
|
|
56
|
+
# Creates the anonymous module based on the contents of @vector_list.
|
|
62
57
|
# The method names in this module are just stubs _except_ those that
|
|
63
58
|
# are loaded into the @cluster_methods hash. By generating all the
|
|
64
59
|
# method names we allow +responds_to?+ to work as expected.
|
|
@@ -72,13 +67,13 @@ module Linguistics
|
|
|
72
67
|
Module.new do
|
|
73
68
|
# This defines instance methods on the Module
|
|
74
69
|
# m.instance_methods #=> [:say_foo, :say_bar, :say_bat]
|
|
75
|
-
|
|
70
|
+
|
|
76
71
|
# Note, you can't use @someArray in the iteration because
|
|
77
72
|
# self has changed to this anonymous module. Since a block
|
|
78
|
-
# is a binding, it has the local context (including 'v')
|
|
79
|
-
# bundled up with it -- despte self having changed!
|
|
73
|
+
# is a binding, it has the local context (including 'v')
|
|
74
|
+
# bundled up with it -- despte self having changed!
|
|
80
75
|
# Therefore, the following works.
|
|
81
|
-
|
|
76
|
+
|
|
82
77
|
# Define a method for each name in vector_list.
|
|
83
78
|
raise("Language was not defined." ) if l.nil?
|
|
84
79
|
|
|
@@ -86,8 +81,8 @@ module Linguistics
|
|
|
86
81
|
r << "#{m}"
|
|
87
82
|
define_method "#{l.downcase}_#{m}".to_sym do
|
|
88
83
|
end
|
|
89
|
-
end
|
|
90
|
-
|
|
84
|
+
end
|
|
85
|
+
|
|
91
86
|
# Write something to spit out the vectors as well.
|
|
92
87
|
define_method :vector_list do
|
|
93
88
|
return v
|
|
@@ -98,24 +93,24 @@ module Linguistics
|
|
|
98
93
|
end
|
|
99
94
|
|
|
100
95
|
# Spit out the clustered methods
|
|
101
|
-
c.each_pair do |k,
|
|
96
|
+
c.each_pair do |k,val|
|
|
102
97
|
define_method k do
|
|
103
|
-
|
|
104
|
-
end
|
|
98
|
+
val.call
|
|
99
|
+
end
|
|
105
100
|
end
|
|
106
101
|
|
|
107
|
-
end
|
|
102
|
+
end
|
|
108
103
|
end
|
|
109
|
-
|
|
104
|
+
|
|
110
105
|
# Language takes a symbol for +l+ the language whose verb we seek to
|
|
111
106
|
# model. It then takes a block for the sub-specification of the verbs
|
|
112
107
|
# of that language.
|
|
113
|
-
def language(*l,&b)
|
|
108
|
+
def language(*l,&b)
|
|
114
109
|
return @language if (l[0].nil? and not @language.nil?)
|
|
115
110
|
@language = l[0]
|
|
116
|
-
instance_eval
|
|
111
|
+
instance_eval(&b)
|
|
117
112
|
end
|
|
118
|
-
|
|
113
|
+
|
|
119
114
|
# Method generates tense vectors based on aspects that are assumed to
|
|
120
115
|
# apply to all possible vectors. These would be seen as the most
|
|
121
116
|
# general aspects possible For example, while only *some* vectors are
|
|
@@ -124,32 +119,32 @@ module Linguistics
|
|
|
124
119
|
def all_vectors(position,&b)
|
|
125
120
|
# Make sure there is a block given
|
|
126
121
|
return unless (block_given? or yield.first)
|
|
127
|
-
|
|
122
|
+
|
|
128
123
|
# Sentinel condition for stopping recursive call
|
|
129
124
|
return @vector_list unless yield.first
|
|
130
125
|
|
|
131
126
|
# Provided that there was a block, collect the DSL hash into
|
|
132
127
|
# specifications
|
|
133
128
|
specifications = yield
|
|
134
|
-
|
|
129
|
+
|
|
135
130
|
# Extract the first k/v
|
|
136
131
|
specification = specifications.first
|
|
137
132
|
|
|
138
133
|
# Based on the key for each row, take that content and postpend
|
|
139
134
|
# it.to_s to the ending of each value held in the hash element value
|
|
140
135
|
expanded_specification = combinatorialize(specification)
|
|
141
|
-
|
|
136
|
+
|
|
142
137
|
# Remove the expanded value from the specifications hash
|
|
143
|
-
specifications.delete(specification[0])
|
|
144
|
-
|
|
138
|
+
specifications.delete(specification[0])
|
|
139
|
+
|
|
145
140
|
# Keep a record of aspects we have seen
|
|
146
141
|
@aspect_list.push specification[0]
|
|
147
142
|
@aspect_list.uniq!
|
|
148
|
-
|
|
143
|
+
|
|
149
144
|
# If it's the first go round put the first set of values in. In
|
|
150
145
|
# general these should be the leftmost and theremfore most general
|
|
151
|
-
if @vector_list.empty?
|
|
152
|
-
@vector_list = expanded_specification
|
|
146
|
+
if @vector_list.empty?
|
|
147
|
+
@vector_list = expanded_specification
|
|
153
148
|
else
|
|
154
149
|
# If there's already a definition in the tens list, for each of
|
|
155
150
|
# the _existing_ values add the array of strings seen in
|
|
@@ -163,49 +158,49 @@ module Linguistics
|
|
|
163
158
|
end
|
|
164
159
|
@vector_list = temp
|
|
165
160
|
end
|
|
166
|
-
|
|
161
|
+
|
|
167
162
|
# Recursive call, sentnel contition is at the top of the method
|
|
168
163
|
all_vectors(position) do
|
|
169
164
|
specifications
|
|
170
165
|
end
|
|
171
|
-
|
|
172
|
-
instance_eval
|
|
166
|
+
|
|
167
|
+
instance_eval(&b)
|
|
173
168
|
end
|
|
174
|
-
|
|
169
|
+
|
|
175
170
|
# Method appends vector definitions _if_ the +condition+ (a RegEx) is satisfied
|
|
176
171
|
def vectors_that(condition,&b)
|
|
177
172
|
matching_stems = @vector_list.grep condition
|
|
178
173
|
temp = []
|
|
179
|
-
|
|
174
|
+
|
|
180
175
|
specifications = yield
|
|
181
|
-
|
|
176
|
+
|
|
182
177
|
# Extract the first k/v
|
|
183
178
|
specification = specifications.first
|
|
184
179
|
|
|
185
180
|
# Based on the key for each row, take that content and postpend
|
|
186
181
|
# it.to_s to the ending of each value held in the hash element value
|
|
187
182
|
expanded_specification = combinatorialize(specification)
|
|
188
|
-
|
|
183
|
+
|
|
189
184
|
# Remove the expanded value from the specifications hash
|
|
190
|
-
specifications.delete(specification[0])
|
|
185
|
+
specifications.delete(specification[0])
|
|
191
186
|
|
|
192
187
|
# Keep a record of aspects we have seen
|
|
193
188
|
@aspect_list.push specification[0]
|
|
194
189
|
@aspect_list.uniq!
|
|
195
|
-
|
|
190
|
+
|
|
196
191
|
# So we grepped the desired stems and stored them in matching_stems
|
|
197
192
|
# First we delete those stems (becasue we're going to further specify) them
|
|
198
|
-
matching_stems.each do |x|
|
|
193
|
+
matching_stems.each do |x|
|
|
199
194
|
@vector_list.delete x
|
|
200
195
|
expanded_specification.each do |u|
|
|
201
196
|
temp.push x+"_#{u}"
|
|
202
197
|
end
|
|
203
198
|
end
|
|
204
|
-
|
|
199
|
+
|
|
205
200
|
# Combine the original list with the freshly expanded list
|
|
206
201
|
@vector_list = (@vector_list + temp).sort
|
|
207
202
|
end
|
|
208
|
-
|
|
203
|
+
|
|
209
204
|
# Languages are not entirely rational, while something _ought_ exist
|
|
210
205
|
# by the rules of rational combination, some times they simply _don't_
|
|
211
206
|
# exist. That's what this method is for.
|
|
@@ -215,11 +210,11 @@ module Linguistics
|
|
|
215
210
|
# _block_ :: used to add
|
|
216
211
|
def exception(action, id, &b)
|
|
217
212
|
if action == :remove
|
|
218
|
-
@vector_list.delete_if {|x| x =~ /#{id.to_s}/ }
|
|
213
|
+
@vector_list.delete_if {|x| x =~ /#{id.to_s}/ }
|
|
219
214
|
elsif action == :add
|
|
220
215
|
end
|
|
221
216
|
end
|
|
222
|
-
|
|
217
|
+
|
|
223
218
|
# Method to take a hash key where the key is an _aspect_ and the value
|
|
224
219
|
# is an array of specifications valid for that _aspect_.
|
|
225
220
|
def combinatorialize(h)
|
|
@@ -229,7 +224,7 @@ module Linguistics
|
|
|
229
224
|
end
|
|
230
225
|
results
|
|
231
226
|
end
|
|
232
|
-
|
|
227
|
+
|
|
233
228
|
# Method to allow "clusters" of simiar vectors to be identified (see:
|
|
234
229
|
# +match_upto+) based on the 0th string match. These clusters can be
|
|
235
230
|
# called by the method namd provided as the 2nd argument (0-index)
|
|
@@ -246,21 +241,21 @@ module Linguistics
|
|
|
246
241
|
# needs
|
|
247
242
|
#
|
|
248
243
|
# *Example:* <tt>cluster_on /active_voice.*third/, "as method", :active_thirds</tt>
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
# This means you want to collect several method names that match the Regexp and make them identifiable by a call to the
|
|
252
|
-
# method +active_thirds+
|
|
244
|
+
#
|
|
245
|
+
#
|
|
246
|
+
# This means you want to collect several method names that match the Regexp and make them identifiable by a call to the
|
|
247
|
+
# method +active_thirds+
|
|
253
248
|
#
|
|
254
249
|
# Alternatively, you might want to use a String or Symbol (making use of match_upto).
|
|
255
250
|
#
|
|
256
251
|
# *Example:* <tt>cluster_on :tense, "as method", :tense_list</tt>
|
|
257
|
-
#
|
|
252
|
+
#
|
|
258
253
|
# +match+ :: The String or Regex match_upto will use for matching
|
|
259
254
|
# +junk+ :: Syntactic sugar, a string that makes the DSL look sensible
|
|
260
|
-
# +method_name+ :: The method in the anonymous module that returns the matched method names. See +create_module+
|
|
255
|
+
# +method_name+ :: The method in the anonymous module that returns the matched method names. See +create_module+
|
|
261
256
|
def cluster_on(match, junk, method_name)
|
|
262
257
|
|
|
263
|
-
clustered_matches =
|
|
258
|
+
clustered_matches =
|
|
264
259
|
if match.class == Regexp
|
|
265
260
|
@vector_list.grep match
|
|
266
261
|
elsif match.class.to_s =~ /^(String|Symbol)/
|
|
@@ -273,7 +268,7 @@ module Linguistics
|
|
|
273
268
|
|
|
274
269
|
unless clustered_matches.nil?
|
|
275
270
|
# No, this should not be done:
|
|
276
|
-
# ...and add them to the @vector_list.
|
|
271
|
+
# ...and add them to the @vector_list.
|
|
277
272
|
# @vector_list += clustered_matches
|
|
278
273
|
# Clustered methods need to be defined, for real, somewhere. We
|
|
279
274
|
# should not claim to respond to them here, but rather let the
|
|
@@ -286,9 +281,7 @@ module Linguistics
|
|
|
286
281
|
clustered_matches
|
|
287
282
|
end
|
|
288
283
|
end
|
|
289
|
-
|
|
290
284
|
end
|
|
291
|
-
|
|
292
285
|
end
|
|
293
286
|
end
|
|
294
287
|
end
|
data/lib/verbvector/version.rb
CHANGED
data/test/test_generator.rb
CHANGED
|
@@ -5,7 +5,7 @@ require "verbvector"
|
|
|
5
5
|
|
|
6
6
|
class TestVerbVector < Test::Unit::TestCase
|
|
7
7
|
def setup
|
|
8
|
-
@vv =
|
|
8
|
+
@vv =
|
|
9
9
|
Linguistics::Verbs::Verbvector::VerbvectorGenerator.new do
|
|
10
10
|
language :Latin do
|
|
11
11
|
all_vectors :start_with do
|
|
@@ -14,19 +14,19 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
14
14
|
:mood => %w(indicative subjunctive imperative)
|
|
15
15
|
}
|
|
16
16
|
end
|
|
17
|
-
vectors_that /.*_indicative_mood/ do
|
|
17
|
+
vectors_that( /.*_indicative_mood/ ) do
|
|
18
18
|
{
|
|
19
19
|
:tense => %w(present imperfect future
|
|
20
20
|
perfect pastperfect futureperfect)
|
|
21
21
|
}
|
|
22
22
|
end
|
|
23
|
-
vectors_that /.*_subjunctive_mood/ do
|
|
23
|
+
vectors_that( /.*_subjunctive_mood/ ) do
|
|
24
24
|
{
|
|
25
|
-
:tense => %w(present imperfect
|
|
25
|
+
:tense => %w(present imperfect
|
|
26
26
|
perfect pastperfect)
|
|
27
27
|
}
|
|
28
28
|
end
|
|
29
|
-
vectors_that /.*_imperative_mood/ do
|
|
29
|
+
vectors_that( /.*_imperative_mood/ ) do
|
|
30
30
|
{
|
|
31
31
|
:tense => %w(present)
|
|
32
32
|
}
|
|
@@ -46,7 +46,7 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
46
46
|
def test_basics
|
|
47
47
|
v = Linguistics::Verbs::Verbvector::VerbvectorGenerator.new do
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
assert_not_nil(v)
|
|
51
51
|
assert_equal(:Latin, @vv.language)
|
|
52
52
|
end
|
|
@@ -56,9 +56,9 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
56
56
|
assert_equal 5, @vv.match_vector_upto_aspect("mood").length
|
|
57
57
|
assert_equal 21, @vv.match_vector_upto_aspect("tense").length
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
def test_tense_resolution
|
|
61
|
-
tense_list = Array.new(File.open(File.join(File.dirname(__FILE__), *%w[fixtures tense_list])).read.split /\s/)
|
|
61
|
+
tense_list = Array.new(File.open(File.join(File.dirname(__FILE__), *%w[fixtures tense_list])).read.split( /\s/ ))
|
|
62
62
|
tense_list.sort!
|
|
63
63
|
|
|
64
64
|
tc = Class.new
|
|
@@ -68,7 +68,7 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def test_clustering_with_regex
|
|
71
|
-
t =
|
|
71
|
+
t =
|
|
72
72
|
Linguistics::Verbs::Verbvector::VerbvectorGenerator.new do
|
|
73
73
|
language :Latin do
|
|
74
74
|
all_vectors :start_with do
|
|
@@ -77,19 +77,19 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
77
77
|
:mood => %w(indicative subjunctive imperative)
|
|
78
78
|
}
|
|
79
79
|
end
|
|
80
|
-
vectors_that /.*_indicative_mood/ do
|
|
80
|
+
vectors_that( /.*_indicative_mood/ ) do
|
|
81
81
|
{
|
|
82
82
|
:tense => %w(present imperfect future
|
|
83
83
|
perfect pastperfect futureperfect)
|
|
84
84
|
}
|
|
85
85
|
end
|
|
86
|
-
vectors_that /.*_subjunctive_mood/ do
|
|
86
|
+
vectors_that( /.*_subjunctive_mood/ ) do
|
|
87
87
|
{
|
|
88
|
-
:tense => %w(present imperfect
|
|
88
|
+
:tense => %w(present imperfect
|
|
89
89
|
perfect pastperfect)
|
|
90
90
|
}
|
|
91
91
|
end
|
|
92
|
-
vectors_that /.*_imperative_mood/ do
|
|
92
|
+
vectors_that( /.*_imperative_mood/ ) do
|
|
93
93
|
{
|
|
94
94
|
:tense => %w(present)
|
|
95
95
|
}
|
|
@@ -101,7 +101,7 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
101
101
|
}
|
|
102
102
|
end
|
|
103
103
|
exception :remove, :passive_voice_imperative_mood_present_tense
|
|
104
|
-
cluster_on /active_voice.*third/, "as method", :active_thirds
|
|
104
|
+
cluster_on( /active_voice.*third/, "as method", :active_thirds )
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
tc = Class.new
|
|
@@ -109,13 +109,13 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
109
109
|
assert_respond_to(tc, :active_thirds)
|
|
110
110
|
assert_equal(22, tc.active_thirds.length)
|
|
111
111
|
end
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
def test_extension
|
|
114
114
|
tc = Class.new
|
|
115
115
|
tc.extend @vv.method_extension_module
|
|
116
116
|
assert_respond_to(tc, :latin_active_voice_indicative_mood_imperfect_tense_singular_number_third_person)
|
|
117
117
|
end
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
def test_clustering
|
|
120
120
|
assert_respond_to(@vv, :vectors_that)
|
|
121
121
|
assert_respond_to(@vv, :cluster_on)
|
|
@@ -128,7 +128,7 @@ class TestVerbVector < Test::Unit::TestCase
|
|
|
128
128
|
|
|
129
129
|
cms=@vv.cluster_methods[:tense_list].call
|
|
130
130
|
cms.each do |m|
|
|
131
|
-
|
|
131
|
+
assert not(tc.respond_to? m.to_sym)
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require "test/unit"
|
|
2
|
+
|
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
|
4
|
+
require "verbvector"
|
|
5
|
+
|
|
6
|
+
class TestProcBasedDefinition < Test::Unit::TestCase
|
|
7
|
+
def setup
|
|
8
|
+
@dsl_proc = Proc.new do
|
|
9
|
+
language :Latin do
|
|
10
|
+
all_vectors :start_with do
|
|
11
|
+
{
|
|
12
|
+
:voice => %w(active passive),
|
|
13
|
+
:mood => %w(indicative subjunctive imperative)
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
vectors_that( /.*_indicative_mood/ ) do
|
|
17
|
+
{
|
|
18
|
+
:tense => %w(present imperfect future
|
|
19
|
+
perfect pastperfect futureperfect)
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
vectors_that( /.*_subjunctive_mood/ ) do
|
|
23
|
+
{
|
|
24
|
+
:tense => %w(present imperfect
|
|
25
|
+
perfect pastperfect)
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
vectors_that( /.*_imperative_mood/ ) do
|
|
29
|
+
{
|
|
30
|
+
:tense => %w(present)
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
all_vectors :end_with do
|
|
34
|
+
{
|
|
35
|
+
:number => %w(singular plural),
|
|
36
|
+
:person => %w(first second third)
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
exception :remove, :passive_voice_imperative_mood_present_tense
|
|
40
|
+
cluster_on :tense, "as method", :tense_list
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
@vv = Linguistics::Verbs::Verbvector::VerbvectorGenerator.new(&@dsl_proc)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_basics
|
|
47
|
+
v = Linguistics::Verbs::Verbvector::VerbvectorGenerator.new do
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
assert_not_nil(v)
|
|
51
|
+
assert_equal(:Latin, @vv.language)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_vector_matcher
|
|
55
|
+
assert_equal 2, @vv.match_vector_upto_aspect("voice").length
|
|
56
|
+
assert_equal 5, @vv.match_vector_upto_aspect("mood").length
|
|
57
|
+
assert_equal 21, @vv.match_vector_upto_aspect("tense").length
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_extension
|
|
61
|
+
tc = Class.new
|
|
62
|
+
tc.extend @vv.method_extension_module
|
|
63
|
+
assert_respond_to(tc, :latin_active_voice_indicative_mood_imperfect_tense_singular_number_third_person)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_clustering
|
|
67
|
+
assert_respond_to(@vv, :vectors_that)
|
|
68
|
+
assert_respond_to(@vv, :cluster_on)
|
|
69
|
+
|
|
70
|
+
tc = Class.new
|
|
71
|
+
tc.extend @vv.method_extension_module
|
|
72
|
+
|
|
73
|
+
# Make sure that each cluster method is /not/ defined. We want these to
|
|
74
|
+
# be defined "for real," not as a proxy.
|
|
75
|
+
|
|
76
|
+
cms=@vv.cluster_methods[:tense_list].call
|
|
77
|
+
cms.each do |m|
|
|
78
|
+
assert not(tc.respond_to? m.to_sym)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
metadata
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: verbvector
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
4
5
|
prerelease:
|
|
5
|
-
version: 0.0.1
|
|
6
6
|
platform: ruby
|
|
7
|
-
authors:
|
|
7
|
+
authors:
|
|
8
8
|
- Steven G. Harms
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
date: 2011-06-02 00:00:00 Z
|
|
12
|
+
date: 2012-10-20 00:00:00.000000000 Z
|
|
14
13
|
dependencies: []
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
email:
|
|
14
|
+
description: Use a DSL to describe the verb tense framework of a language and have
|
|
15
|
+
it generate methods corresponding to each unique vector.
|
|
16
|
+
email:
|
|
18
17
|
- github@sgharms.oib.com
|
|
19
18
|
executables: []
|
|
20
|
-
|
|
21
19
|
extensions: []
|
|
22
|
-
|
|
23
20
|
extra_rdoc_files: []
|
|
24
|
-
|
|
25
|
-
files:
|
|
21
|
+
files:
|
|
26
22
|
- .gitignore
|
|
27
23
|
- Gemfile
|
|
28
24
|
- README.textile
|
|
@@ -31,34 +27,30 @@ files:
|
|
|
31
27
|
- lib/verbvector/version.rb
|
|
32
28
|
- test/fixtures/tense_list
|
|
33
29
|
- test/test_generator.rb
|
|
30
|
+
- test/test_passed_block.rb
|
|
34
31
|
- verbvector.gemspec
|
|
35
32
|
homepage: http://rubygems.org/gems/verbvector
|
|
36
33
|
licenses: []
|
|
37
|
-
|
|
38
34
|
post_install_message:
|
|
39
35
|
rdoc_options: []
|
|
40
|
-
|
|
41
|
-
require_paths:
|
|
36
|
+
require_paths:
|
|
42
37
|
- lib
|
|
43
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
39
|
none: false
|
|
45
|
-
requirements:
|
|
46
|
-
- -
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version:
|
|
49
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ! '>='
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
45
|
none: false
|
|
51
|
-
requirements:
|
|
52
|
-
- -
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
46
|
+
requirements:
|
|
47
|
+
- - ! '>='
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
55
50
|
requirements: []
|
|
56
|
-
|
|
57
51
|
rubyforge_project: verbvector
|
|
58
|
-
rubygems_version: 1.8.
|
|
52
|
+
rubygems_version: 1.8.23
|
|
59
53
|
signing_key:
|
|
60
54
|
specification_version: 3
|
|
61
55
|
summary: Generates the verb tense "vectors" based on a DSL description syntax.
|
|
62
|
-
test_files:
|
|
63
|
-
- test/fixtures/tense_list
|
|
64
|
-
- test/test_generator.rb
|
|
56
|
+
test_files: []
|