matching 0.14.1
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/.document +5 -0
- data/.rspec +2 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +60 -0
- data/README.md +319 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/lib/matching.rb +11 -0
- data/lib/matching/active_relation_store.rb +30 -0
- data/lib/matching/array_store.rb +23 -0
- data/lib/matching/attribute_pair.rb +17 -0
- data/lib/matching/deduplicator.rb +133 -0
- data/lib/matching/hash_index.rb +25 -0
- data/lib/matching/match.rb +14 -0
- data/lib/matching/matcher.rb +266 -0
- data/lib/matching/redis_index.rb +26 -0
- data/lib/matching/similarity.rb +78 -0
- data/matching.gemspec +71 -0
- data/spec/db/database.yml +5 -0
- data/spec/integration/bank_rec_spec.rb +50 -0
- data/spec/lib/ar_spec.rb +182 -0
- data/spec/lib/deduplicator_spec.rb +221 -0
- data/spec/lib/matcher_spec.rb +297 -0
- data/spec/lib/redis_spec.rb +105 -0
- data/spec/lib/similarity_spec.rb +88 -0
- data/spec/samples/agent_recs.csv +2024 -0
- data/spec/spec_helper.rb +70 -0
- metadata +109 -0
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__), '../lib/matching.rb')
|
|
4
|
+
|
|
5
|
+
module MatcherSpecHelper
|
|
6
|
+
|
|
7
|
+
REDIS_TEST_DB = 8
|
|
8
|
+
|
|
9
|
+
class Transaction
|
|
10
|
+
attr_accessor :id, :esn, :mid, :date
|
|
11
|
+
|
|
12
|
+
def initialize(opts)
|
|
13
|
+
opts.each do |key,value|
|
|
14
|
+
instance_variable_set "@#{key}", value
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Creates arrays of Transaction objects
|
|
20
|
+
def create_test_data
|
|
21
|
+
@left_a = Transaction.new(:esn => "11111111111", :mid => "7275551111", :date => Date.new(2010,6,1))
|
|
22
|
+
@left_b = Transaction.new(:esn => "22222222222", :mid => "8135554444", :date => Date.new(2010,6,1))
|
|
23
|
+
@left_c = Transaction.new(:esn => "33333333333", :mid => "7275551111", :date => Date.new(2010,6,15))
|
|
24
|
+
@lefts = [@left_a, @left_b, @left_c]
|
|
25
|
+
|
|
26
|
+
@right_a = Transaction.new(:esn => "11111111111", :mid => "2015559999", :date => Date.new(2010,6,1))
|
|
27
|
+
@right_b = Transaction.new(:esn => "11111111111", :mid => "7275551111", :date => Date.new(2010,6,1))
|
|
28
|
+
@right_c = Transaction.new(:esn => "22222222222", :mid => "8135554444", :date => Date.new(2010,6,2))
|
|
29
|
+
@right_d = Transaction.new(:esn => "44444444444", :mid => "7275551111", :date => Date.new(2010,6,14))
|
|
30
|
+
@rights = [@right_a, @right_b, @right_c, @right_d]
|
|
31
|
+
|
|
32
|
+
#Match chart esn mid txn_date
|
|
33
|
+
#--------------------------------------------------------------
|
|
34
|
+
#left_a right_b X X X
|
|
35
|
+
#left_a right_a X X
|
|
36
|
+
#left_b right_c X X
|
|
37
|
+
#left_c right_d X (delta 1)
|
|
38
|
+
#
|
|
39
|
+
#right_a the same as right_b except for mid
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def define_mid_matcher(m)
|
|
43
|
+
m.define { join :mid, :mid, 1.0 }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def define_esn_matcher(m)
|
|
47
|
+
m.define { join :esn, :esn, 1.0 }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def define_mid_esn_matcher(m)
|
|
51
|
+
define_mid_matcher(m)
|
|
52
|
+
m.define { join :esn, :esn, 1.0 }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def define_mid_esn_date_matcher(m)
|
|
56
|
+
define_mid_esn_matcher(m)
|
|
57
|
+
m.define { compare :date, :date, 0.5, :fuzzy => true }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Matcher using arrays for the data store
|
|
61
|
+
def create_array_matcher(opts={})
|
|
62
|
+
|
|
63
|
+
create_test_data
|
|
64
|
+
@matcher = Matcher.new(:left_store => ArrayStore.new(@lefts),
|
|
65
|
+
:right_store => ArrayStore.new(@rights),
|
|
66
|
+
:redis_db => (opts[:use_redis] ? REDIS_TEST_DB : -1)
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: matching
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.14.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Barry Ezell
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-02-09 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: text
|
|
16
|
+
requirement: &70255814031080 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70255814031080
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: bundler
|
|
27
|
+
requirement: &70255814030120 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *70255814030120
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: jeweler
|
|
38
|
+
requirement: &70255814029040 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ! '>='
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
type: :development
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *70255814029040
|
|
47
|
+
description: ''
|
|
48
|
+
email: barrye@gmail.com
|
|
49
|
+
executables: []
|
|
50
|
+
extensions: []
|
|
51
|
+
extra_rdoc_files:
|
|
52
|
+
- README.md
|
|
53
|
+
files:
|
|
54
|
+
- .document
|
|
55
|
+
- .rspec
|
|
56
|
+
- Gemfile
|
|
57
|
+
- Gemfile.lock
|
|
58
|
+
- README.md
|
|
59
|
+
- Rakefile
|
|
60
|
+
- VERSION
|
|
61
|
+
- lib/matching.rb
|
|
62
|
+
- lib/matching/active_relation_store.rb
|
|
63
|
+
- lib/matching/array_store.rb
|
|
64
|
+
- lib/matching/attribute_pair.rb
|
|
65
|
+
- lib/matching/deduplicator.rb
|
|
66
|
+
- lib/matching/hash_index.rb
|
|
67
|
+
- lib/matching/match.rb
|
|
68
|
+
- lib/matching/matcher.rb
|
|
69
|
+
- lib/matching/redis_index.rb
|
|
70
|
+
- lib/matching/similarity.rb
|
|
71
|
+
- matching.gemspec
|
|
72
|
+
- spec/db/database.yml
|
|
73
|
+
- spec/integration/bank_rec_spec.rb
|
|
74
|
+
- spec/lib/ar_spec.rb
|
|
75
|
+
- spec/lib/deduplicator_spec.rb
|
|
76
|
+
- spec/lib/matcher_spec.rb
|
|
77
|
+
- spec/lib/redis_spec.rb
|
|
78
|
+
- spec/lib/similarity_spec.rb
|
|
79
|
+
- spec/samples/agent_recs.csv
|
|
80
|
+
- spec/spec_helper.rb
|
|
81
|
+
homepage: http://github.com/btedev/matching
|
|
82
|
+
licenses:
|
|
83
|
+
- MIT license
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
segments:
|
|
95
|
+
- 0
|
|
96
|
+
hash: 2498948497427676242
|
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
|
+
none: false
|
|
99
|
+
requirements:
|
|
100
|
+
- - ! '>='
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
requirements: []
|
|
104
|
+
rubyforge_project:
|
|
105
|
+
rubygems_version: 1.8.7
|
|
106
|
+
signing_key:
|
|
107
|
+
specification_version: 3
|
|
108
|
+
summary: Dataset matching engine
|
|
109
|
+
test_files: []
|