loose_tight_dictionary 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/loose_tight_dictionary.rb +14 -3
- data/test/test_loose_tight_dictionary.rb +14 -13
- metadata +5 -5
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/seamusabshere/loose_tight_dictionary"
|
12
12
|
gem.authors = ["Seamus Abshere"]
|
13
13
|
gem.add_development_dependency "shoulda"
|
14
|
-
gem.add_development_dependency "remote_table", ">=0.2.
|
14
|
+
gem.add_development_dependency "remote_table", ">=0.2.19"
|
15
15
|
gem.add_dependency 'activesupport', '>=2.3.4'
|
16
16
|
gem.add_dependency 'fastercsv', '>=1.5.3'
|
17
17
|
gem.add_dependency 'andand', '>=1.3.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -114,7 +114,7 @@ class LooseTightDictionary
|
|
114
114
|
begin
|
115
115
|
right_record = left_to_right left_record
|
116
116
|
ensure
|
117
|
-
tee.andand.puts [ read_left(left_record), read_right(
|
117
|
+
tee.andand.puts [ read_left(left_record), read_right($ltd_0), $ltd_1 ].flatten.to_csv
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -125,7 +125,13 @@ class LooseTightDictionary
|
|
125
125
|
blocking_left = blocking left
|
126
126
|
t_options_left = t_options left
|
127
127
|
history = Hash.new
|
128
|
-
right_record = right_records.select
|
128
|
+
right_record = right_records.select do |right_record|
|
129
|
+
right = read_right right_record
|
130
|
+
blocking_right = blocking right
|
131
|
+
(not blocking_left and not blocking_right) or
|
132
|
+
(blocking_right and blocking_right.match(left)) or
|
133
|
+
(blocking_left and blocking_left.match(right))
|
134
|
+
end.max do |a_record, b_record|
|
129
135
|
a = read_right a_record
|
130
136
|
b = read_right b_record
|
131
137
|
i_options_a = i_options a
|
@@ -176,7 +182,12 @@ class LooseTightDictionary
|
|
176
182
|
z = 1
|
177
183
|
debugger if $ltd_left.andand.match(left) or $ltd_right.andand.match(right)
|
178
184
|
z = 1
|
179
|
-
|
185
|
+
if collision? i_options_left, i_options_right
|
186
|
+
$ltd_0 = nil
|
187
|
+
return
|
188
|
+
else
|
189
|
+
$ltd_0 = right_record
|
190
|
+
end
|
180
191
|
inline_check left_record, right_record
|
181
192
|
right_record
|
182
193
|
end
|
@@ -68,17 +68,6 @@ class TestLooseTightDictionary < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
if ENV['OLD'] == 'true' or ENV['ALL'] == 'true'
|
71
|
-
should "only use identities if they stem from the same regexp" do
|
72
|
-
@identities.push @r_1
|
73
|
-
@identities.push [ '/(cessna)(?:.*?)(citation)/i' ]
|
74
|
-
@identities.push [ '/(cessna)(?:.*?)(\d\d\d)/i' ]
|
75
|
-
x_left = [ 'CESSNA D-333 CITATION V']
|
76
|
-
x_right = [ 'CESSNA D-333' ]
|
77
|
-
@right.push x_right
|
78
|
-
|
79
|
-
assert_equal x_right, ltd.left_to_right(x_left)
|
80
|
-
end
|
81
|
-
|
82
71
|
should "have a false match without blocking" do
|
83
72
|
# @d_left will be our victim
|
84
73
|
@right.push @d_lookalike
|
@@ -96,11 +85,23 @@ class TestLooseTightDictionary < Test::Unit::TestCase
|
|
96
85
|
assert_equal @d_right, ltd.left_to_right(@d_left)
|
97
86
|
end
|
98
87
|
|
99
|
-
should "
|
88
|
+
should "treat blocks as exclusive" do
|
89
|
+
@right = [ @d_left ]
|
100
90
|
@tightenings.push @t_1
|
101
91
|
@blockings.push ['/(bombardier|de ?havilland)/i']
|
92
|
+
|
93
|
+
assert_equal nil, ltd.left_to_right(@d_lookalike)
|
94
|
+
end
|
95
|
+
|
96
|
+
should "only use identities if they stem from the same regexp" do
|
97
|
+
@identities.push @r_1
|
98
|
+
@identities.push [ '/(cessna)(?:.*?)(citation)/i' ]
|
99
|
+
@identities.push [ '/(cessna)(?:.*?)(\d\d\d)/i' ]
|
100
|
+
x_left = [ 'CESSNA D-333 CITATION V']
|
101
|
+
x_right = [ 'CESSNA D-333' ]
|
102
|
+
@right.push x_right
|
102
103
|
|
103
|
-
assert_equal
|
104
|
+
assert_equal x_right, ltd.left_to_right(x_left)
|
104
105
|
end
|
105
106
|
|
106
107
|
should "use the best score from all of the tightenings" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Seamus Abshere
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-29 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -39,8 +39,8 @@ dependencies:
|
|
39
39
|
segments:
|
40
40
|
- 0
|
41
41
|
- 2
|
42
|
-
-
|
43
|
-
version: 0.2.
|
42
|
+
- 19
|
43
|
+
version: 0.2.19
|
44
44
|
type: :development
|
45
45
|
version_requirements: *id002
|
46
46
|
- !ruby/object:Gem::Dependency
|