ofac 1.3.2 → 2.0.0
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.
- checksums.yaml +7 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/History.txt +7 -0
- data/README.rdoc +4 -4
- data/VERSION.yml +3 -3
- data/lib/ofac/models/ofac.rb +7 -25
- data/lib/ofac/models/ofac_sdn.rb +20 -0
- data/ofac.gemspec +6 -12
- data/rdoc/CreateOfacSdns.html +19 -10
- data/rdoc/Ofac.html +47 -44
- data/rdoc/OfacMatch.html +27 -18
- data/rdoc/OfacMigration.html +11 -8
- data/rdoc/OfacMigration/Generators.html +11 -8
- data/rdoc/OfacMigration/Generators/BuildGenerator.html +19 -10
- data/rdoc/OfacSdn.html +76 -8
- data/rdoc/OfacSdnLoader.html +23 -17
- data/rdoc/README_rdoc.html +62 -40
- data/rdoc/String.html +20 -11
- data/rdoc/created.rid +6 -6
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/index.html +11 -9
- data/rdoc/js/darkfish.js +9 -7
- data/rdoc/js/search_index.js +1 -1
- data/rdoc/rdoc.css +52 -0
- data/rdoc/table_of_contents.html +19 -17
- data/test/ofac_test.rb +35 -26
- metadata +22 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0894103e3439ab8efd1043daef9c2dde6670efcb
|
4
|
+
data.tar.gz: 22605149296182337b8275708b3c9389f43ed266
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 093fd778fffe2ba91f7ad8a7eead62b7286777997bd2b369eef5327fb3ffebd47651d423ffc1f21f33d20f38695dfae0cefc481e5c27af8dfc8c8594d8dc4513
|
7
|
+
data.tar.gz: 04fcb9b6383e5e12f5d8bd7d8329375f7fe7b4664e5ea3a76bafeaa67f2af94353362b558bd680b71fbe05ae279596e0162aabde77af6630a003e150c868f6ac
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ofac
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -106,7 +106,7 @@ Acceptable hash keys and their weighting in score calculation:
|
|
106
106
|
|
107
107
|
== INSTALL:
|
108
108
|
|
109
|
-
==== Rails 2.0
|
109
|
+
==== Rails 2.0 - use version 1.3.2 or earlier
|
110
110
|
|
111
111
|
* To install the gem:
|
112
112
|
sudo gem install kevintyll-ofac
|
@@ -120,13 +120,13 @@ Acceptable hash keys and their weighting in score calculation:
|
|
120
120
|
* The OFAC data is not updated with any regularity, but you can sign up for email notifications when the data changes at
|
121
121
|
http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml.
|
122
122
|
|
123
|
-
==== Rails 3.0
|
123
|
+
==== Rails 3.0 & 4.0
|
124
124
|
|
125
125
|
* To create the necessary db migration, from the command line, run:
|
126
126
|
rails generate ofac_migration:build
|
127
127
|
* To add the gem to your Rails project:
|
128
128
|
===== Add the gem to your Gemfile:
|
129
|
-
gem "ofac", "~>
|
129
|
+
gem "ofac", "~> 2.0.0"
|
130
130
|
===== Run the Bundler install command
|
131
131
|
bundle install
|
132
132
|
* To load your table with the current OFAC data, from the command line, run:
|
@@ -137,4 +137,4 @@ Acceptable hash keys and their weighting in score calculation:
|
|
137
137
|
|
138
138
|
== Copyright
|
139
139
|
|
140
|
-
Copyright (c) 2009 Kevin Tyll. See LICENSE for details.
|
140
|
+
Copyright (c) 2009-2013 Kevin Tyll. See LICENSE for details.
|
data/VERSION.yml
CHANGED
data/lib/ofac/models/ofac.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Ofac
|
2
2
|
|
3
|
-
|
3
|
+
|
4
4
|
# Accepts a hash with the identity's demographic information
|
5
5
|
#
|
6
6
|
# Ofac.new({:name => 'Oscar Hernandez', :city => 'Clearwater', :address => '123 somewhere ln'})
|
@@ -92,27 +92,15 @@ class Ofac
|
|
92
92
|
#first get a list from the database of possible matches by name
|
93
93
|
#this query is pretty liberal, we just want to get a list of possible
|
94
94
|
#matches from the database that we can run through our ruby matching algorithm
|
95
|
-
|
95
|
+
hit = false
|
96
96
|
name_array = process_name
|
97
97
|
|
98
98
|
name_array.delete_if{|n| n.strip.size < 2}
|
99
99
|
unless name_array.empty?
|
100
|
-
|
101
|
-
sql_alt_name_partial = name_array.collect {|partial_name| ["lower(alternate_identity_name) like ?", "%#{partial_name.downcase}%"]}
|
102
|
-
|
103
|
-
name_conditions = sql_name_partial.transpose
|
104
|
-
name_values = name_conditions.second
|
105
|
-
name_conditions = [name_conditions.first.join(' and ')]
|
106
|
-
alt_name_conditions = sql_alt_name_partial.transpose
|
107
|
-
alt_name_values = alt_name_conditions.second
|
108
|
-
alt_name_conditions = [alt_name_conditions.first.join(' and ')]
|
109
|
-
conditions = ["(#{name_conditions}) or (#{alt_name_conditions})"] + name_values + alt_name_values
|
110
|
-
|
111
|
-
possible_sdns = OfacSdn.find_all_by_sdn_type('individual',:select => 'name, alternate_identity_name, address, city', :conditions => conditions)
|
112
|
-
|
100
|
+
hit = OfacSdn.possible_sdns(name_array).exists?
|
113
101
|
end
|
114
102
|
end
|
115
|
-
|
103
|
+
hit
|
116
104
|
end
|
117
105
|
|
118
106
|
# Returns an array of hashes of records in the OFAC data that found partial matches with that record's score.
|
@@ -134,7 +122,7 @@ class Ofac
|
|
134
122
|
|
135
123
|
def calculate_score
|
136
124
|
unless @identity[:name].to_s.blank?
|
137
|
-
|
125
|
+
|
138
126
|
#first get a list from the database of possible matches by name
|
139
127
|
#this query is pretty liberal, we just want to get a list of possible
|
140
128
|
#matches from the database that we can run through our ruby matching algorithm
|
@@ -143,15 +131,9 @@ class Ofac
|
|
143
131
|
|
144
132
|
name_array.delete_if{|n| n.strip.size < 2}
|
145
133
|
unless name_array.empty?
|
146
|
-
|
147
|
-
sql_alt_name_partial = name_array.collect {|partial_name| ["lower(alternate_identity_name) like ?", "%#{partial_name.downcase}%"]}
|
148
|
-
conditions = sql_name_partial + sql_alt_name_partial
|
149
|
-
conditions = conditions.transpose
|
150
|
-
conditions = [conditions.first.join(' or ')] + conditions.second
|
151
|
-
|
152
|
-
possible_sdns = OfacSdn.find_all_by_sdn_type('individual',:select => 'name, alternate_identity_name, address, city', :conditions => conditions)
|
134
|
+
possible_sdns = OfacSdn.possible_sdns(name_array, use_ors = true)
|
153
135
|
possible_sdns = possible_sdns.collect {|sdn|{:name => "#{sdn['name']}|#{sdn['alternate_identity_name']}", :city => sdn['city'], :address => sdn['address']}}
|
154
|
-
|
136
|
+
|
155
137
|
match = OfacMatch.new({:name => {:weight => 60, :token => "#{name_array.join(', ')}"},
|
156
138
|
:address => {:weight => 10, :token => @identity[:address]},
|
157
139
|
:city => {:weight => 30, :token => @identity[:city]}})
|
data/lib/ofac/models/ofac_sdn.rb
CHANGED
@@ -2,4 +2,24 @@ require 'active_record'
|
|
2
2
|
|
3
3
|
class OfacSdn < ActiveRecord::Base
|
4
4
|
|
5
|
+
def self.possible_sdns(name_array, use_ors = false)
|
6
|
+
name_conditions = []
|
7
|
+
alt_name_conditions = []
|
8
|
+
values = []
|
9
|
+
name_array.each do |partial_name|
|
10
|
+
name_conditions << '(lower(name) like ?)'
|
11
|
+
alt_name_conditions << '(lower(alternate_identity_name) like ?)'
|
12
|
+
values << "%#{partial_name.downcase}%"
|
13
|
+
end
|
14
|
+
if use_ors
|
15
|
+
conditions = (name_conditions + alt_name_conditions).join(' or ')
|
16
|
+
else
|
17
|
+
name_conditions = name_conditions.join(' and ')
|
18
|
+
alt_name_conditions = alt_name_conditions.join(' and ')
|
19
|
+
conditions = "(#{name_conditions}) or (#{alt_name_conditions})"
|
20
|
+
end
|
21
|
+
# we need the values in there twice, once for the names and once for the alt_names
|
22
|
+
OfacSdn.select(:name, :alternate_identity_name, :address, :city).where(sdn_type: 'individual').where(conditions, *(values * 2))
|
23
|
+
end
|
24
|
+
|
5
25
|
end
|
data/ofac.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ofac"
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kevin Tyll"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2014-01-07"
|
13
13
|
s.description = "Attempts to find a hit on the Office of Foreign Assets Control's Specially Designated Nationals list."
|
14
14
|
s.email = "kevintyll@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
+
".ruby-gemset",
|
22
|
+
".ruby-version",
|
21
23
|
"History.txt",
|
22
24
|
"LICENSE",
|
23
25
|
"PostInstall.txt",
|
@@ -67,6 +69,7 @@ Gem::Specification.new do |s|
|
|
67
69
|
"rdoc/fr_file_index.html",
|
68
70
|
"rdoc/fr_method_index.html",
|
69
71
|
"rdoc/images/add.png",
|
72
|
+
"rdoc/images/arrow_up.png",
|
70
73
|
"rdoc/images/brick.png",
|
71
74
|
"rdoc/images/brick_link.png",
|
72
75
|
"rdoc/images/bug.png",
|
@@ -120,16 +123,7 @@ Gem::Specification.new do |s|
|
|
120
123
|
s.homepage = "http://github.com/kevintyll/ofac"
|
121
124
|
s.post_install_message = "For more information on ofac, see http://kevintyll.github.com/ofac/\n\n* To create the necessary db migration, from the command line, run:\n script/generate ofac_migration\n* Require the gem in your environment.rb file in the Rails::Initializer block:\n config.gem 'kevintyll-ofac', :lib => 'ofac'\n* To load your table with the current OFAC data, from the command line, run:\n rake ofac:update_data\n\n * The OFAC data is not updated with any regularity, but you can sign up for email notifications when the data changes at\n http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml."
|
122
125
|
s.require_paths = ["lib"]
|
123
|
-
s.rubygems_version = "
|
126
|
+
s.rubygems_version = "2.0.3"
|
124
127
|
s.summary = "Attempts to find a hit on the Office of Foreign Assets Control's Specially Designated Nationals list."
|
125
|
-
|
126
|
-
if s.respond_to? :specification_version then
|
127
|
-
s.specification_version = 3
|
128
|
-
|
129
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
130
|
-
else
|
131
|
-
end
|
132
|
-
else
|
133
|
-
end
|
134
128
|
end
|
135
129
|
|
data/rdoc/CreateOfacSdns.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
6
|
|
7
|
-
<title>class CreateOfacSdns - ofac
|
7
|
+
<title>class CreateOfacSdns - ofac 2.0.0</title>
|
8
8
|
|
9
9
|
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
10
|
|
@@ -43,6 +43,8 @@
|
|
43
43
|
</nav>
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
|
46
48
|
<div id="file-metadata">
|
47
49
|
<nav id="file-list-section" class="section">
|
48
50
|
<h3 class="section-header">Defined In</h3>
|
@@ -64,15 +66,16 @@
|
|
64
66
|
</nav>
|
65
67
|
|
66
68
|
|
69
|
+
|
67
70
|
<!-- Method Quickref -->
|
68
71
|
<nav id="method-list-section" class="section">
|
69
72
|
<h3 class="section-header">Methods</h3>
|
70
73
|
|
71
74
|
<ul class="link-list">
|
72
75
|
|
73
|
-
<li><a href="#method-c-down">::down</a>
|
76
|
+
<li ><a href="#method-c-down">::down</a>
|
74
77
|
|
75
|
-
<li><a href="#method-c-up">::up</a>
|
78
|
+
<li ><a href="#method-c-up">::up</a>
|
76
79
|
|
77
80
|
</ul>
|
78
81
|
</nav>
|
@@ -95,18 +98,18 @@
|
|
95
98
|
|
96
99
|
<ul class="link-list">
|
97
100
|
|
98
|
-
<li><a href="./OfacMigration.html">OfacMigration</a>
|
99
|
-
|
100
|
-
<li><a href="./OfacMigration/Generators.html">OfacMigration::Generators</a>
|
101
|
-
|
102
|
-
<li><a href="./OfacMigration/Generators/BuildGenerator.html">OfacMigration::Generators::BuildGenerator</a>
|
103
|
-
|
104
101
|
<li><a href="./CreateOfacSdns.html">CreateOfacSdns</a>
|
105
102
|
|
106
103
|
<li><a href="./Ofac.html">Ofac</a>
|
107
104
|
|
108
105
|
<li><a href="./OfacMatch.html">OfacMatch</a>
|
109
106
|
|
107
|
+
<li><a href="./OfacMigration.html">OfacMigration</a>
|
108
|
+
|
109
|
+
<li><a href="./OfacMigration/Generators.html">OfacMigration::Generators</a>
|
110
|
+
|
111
|
+
<li><a href="./OfacMigration/Generators/BuildGenerator.html">OfacMigration::Generators::BuildGenerator</a>
|
112
|
+
|
110
113
|
<li><a href="./OfacSdn.html">OfacSdn</a>
|
111
114
|
|
112
115
|
<li><a href="./OfacSdnLoader.html">OfacSdnLoader</a>
|
@@ -149,7 +152,9 @@
|
|
149
152
|
<div class="method-heading">
|
150
153
|
<span class="method-name">down</span><span
|
151
154
|
class="method-args">()</span>
|
155
|
+
|
152
156
|
<span class="method-click-advice">click to toggle source</span>
|
157
|
+
|
153
158
|
</div>
|
154
159
|
|
155
160
|
|
@@ -157,6 +162,7 @@
|
|
157
162
|
|
158
163
|
|
159
164
|
|
165
|
+
|
160
166
|
|
161
167
|
|
162
168
|
<div class="method-source-code" id="down-source">
|
@@ -179,7 +185,9 @@
|
|
179
185
|
<div class="method-heading">
|
180
186
|
<span class="method-name">up</span><span
|
181
187
|
class="method-args">()</span>
|
188
|
+
|
182
189
|
<span class="method-click-advice">click to toggle source</span>
|
190
|
+
|
183
191
|
</div>
|
184
192
|
|
185
193
|
|
@@ -187,6 +195,7 @@
|
|
187
195
|
|
188
196
|
|
189
197
|
|
198
|
+
|
190
199
|
|
191
200
|
|
192
201
|
<div class="method-source-code" id="up-source">
|
@@ -234,7 +243,7 @@
|
|
234
243
|
|
235
244
|
<footer id="validator-badges">
|
236
245
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
237
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
246
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
238
247
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
239
248
|
</footer>
|
240
249
|
|
data/rdoc/Ofac.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
6
|
|
7
|
-
<title>class Ofac - ofac
|
7
|
+
<title>class Ofac - ofac 2.0.0</title>
|
8
8
|
|
9
9
|
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
10
|
|
@@ -43,6 +43,8 @@
|
|
43
43
|
</nav>
|
44
44
|
|
45
45
|
|
46
|
+
|
47
|
+
|
46
48
|
<div id="file-metadata">
|
47
49
|
<nav id="file-list-section" class="section">
|
48
50
|
<h3 class="section-header">Defined In</h3>
|
@@ -64,19 +66,20 @@
|
|
64
66
|
</nav>
|
65
67
|
|
66
68
|
|
69
|
+
|
67
70
|
<!-- Method Quickref -->
|
68
71
|
<nav id="method-list-section" class="section">
|
69
72
|
<h3 class="section-header">Methods</h3>
|
70
73
|
|
71
74
|
<ul class="link-list">
|
72
75
|
|
73
|
-
<li><a href="#method-c-new">::new</a>
|
76
|
+
<li ><a href="#method-c-new">::new</a>
|
74
77
|
|
75
|
-
<li><a href="#method-i-db_hit-3F">#db_hit?</a>
|
78
|
+
<li ><a href="#method-i-db_hit-3F">#db_hit?</a>
|
76
79
|
|
77
|
-
<li><a href="#method-i-possible_hits">#possible_hits</a>
|
80
|
+
<li ><a href="#method-i-possible_hits">#possible_hits</a>
|
78
81
|
|
79
|
-
<li><a href="#method-i-score">#score</a>
|
82
|
+
<li ><a href="#method-i-score">#score</a>
|
80
83
|
|
81
84
|
</ul>
|
82
85
|
</nav>
|
@@ -99,18 +102,18 @@
|
|
99
102
|
|
100
103
|
<ul class="link-list">
|
101
104
|
|
102
|
-
<li><a href="./OfacMigration.html">OfacMigration</a>
|
103
|
-
|
104
|
-
<li><a href="./OfacMigration/Generators.html">OfacMigration::Generators</a>
|
105
|
-
|
106
|
-
<li><a href="./OfacMigration/Generators/BuildGenerator.html">OfacMigration::Generators::BuildGenerator</a>
|
107
|
-
|
108
105
|
<li><a href="./CreateOfacSdns.html">CreateOfacSdns</a>
|
109
106
|
|
110
107
|
<li><a href="./Ofac.html">Ofac</a>
|
111
108
|
|
112
109
|
<li><a href="./OfacMatch.html">OfacMatch</a>
|
113
110
|
|
111
|
+
<li><a href="./OfacMigration.html">OfacMigration</a>
|
112
|
+
|
113
|
+
<li><a href="./OfacMigration/Generators.html">OfacMigration::Generators</a>
|
114
|
+
|
115
|
+
<li><a href="./OfacMigration/Generators/BuildGenerator.html">OfacMigration::Generators::BuildGenerator</a>
|
116
|
+
|
114
117
|
<li><a href="./OfacSdn.html">OfacSdn</a>
|
115
118
|
|
116
119
|
<li><a href="./OfacSdnLoader.html">OfacSdnLoader</a>
|
@@ -153,15 +156,17 @@
|
|
153
156
|
<div class="method-heading">
|
154
157
|
<span class="method-name">new</span><span
|
155
158
|
class="method-args">(identity)</span>
|
159
|
+
|
156
160
|
<span class="method-click-advice">click to toggle source</span>
|
161
|
+
|
157
162
|
</div>
|
158
163
|
|
159
164
|
|
160
165
|
<div class="method-description">
|
161
166
|
|
162
|
-
<p>Accepts a hash with the identity
|
167
|
+
<p>Accepts a hash with the identity's demographic information</p>
|
163
168
|
|
164
|
-
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>({:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> <span class="ruby-string"
|
169
|
+
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>({:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Oscar Hernandez'</span>, :<span class="ruby-identifier">city</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Clearwater'</span>, :<span class="ruby-identifier">address</span> =<span class="ruby-operator">></span> <span class="ruby-string">'123 somewhere ln'</span>})
|
165
170
|
</pre>
|
166
171
|
|
167
172
|
<p><code>:name</code> is required to get a score. If <code>:name</code> is
|
@@ -169,12 +174,12 @@ missing, an error will not be thrown, but a score of 0 will be returned.</p>
|
|
169
174
|
|
170
175
|
<p>You can pass a string in for the full name:</p>
|
171
176
|
|
172
|
-
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> <span class="ruby-string"
|
177
|
+
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Victor De La Garza'</span>)
|
173
178
|
</pre>
|
174
179
|
|
175
180
|
<p>Or you can specify the last and first names</p>
|
176
181
|
|
177
|
-
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> {:<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">></span> <span class="ruby-string"
|
182
|
+
<pre class="ruby"><span class="ruby-constant">Ofac</span>.<span class="ruby-identifier">new</span>(:<span class="ruby-identifier">name</span> =<span class="ruby-operator">></span> {:<span class="ruby-identifier">first_name</span> =<span class="ruby-operator">></span> <span class="ruby-string">'Victor'</span>, :<span class="ruby-identifier">last_name</span> =<span class="ruby-operator">></span> <span class="ruby-string">'De La Garza'</span>})
|
178
183
|
</pre>
|
179
184
|
|
180
185
|
<p>The first method will build a larger list of names for ruby to parse
|
@@ -196,6 +201,7 @@ business, or marine vessel</p>
|
|
196
201
|
<p><code>:city</code> (weighting = 30%)</p>
|
197
202
|
</li></ul>
|
198
203
|
|
204
|
+
|
199
205
|
|
200
206
|
|
201
207
|
<div class="method-source-code" id="new-source">
|
@@ -224,7 +230,9 @@ business, or marine vessel</p>
|
|
224
230
|
<div class="method-heading">
|
225
231
|
<span class="method-name">db_hit?</span><span
|
226
232
|
class="method-args">()</span>
|
233
|
+
|
227
234
|
<span class="method-click-advice">click to toggle source</span>
|
235
|
+
|
228
236
|
</div>
|
229
237
|
|
230
238
|
|
@@ -232,6 +240,7 @@ business, or marine vessel</p>
|
|
232
240
|
|
233
241
|
|
234
242
|
|
243
|
+
|
235
244
|
|
236
245
|
|
237
246
|
<div class="method-source-code" id="db_hit-3F-source">
|
@@ -242,27 +251,15 @@ business, or marine vessel</p>
|
|
242
251
|
<span class="ruby-comment">#first get a list from the database of possible matches by name</span>
|
243
252
|
<span class="ruby-comment">#this query is pretty liberal, we just want to get a list of possible</span>
|
244
253
|
<span class="ruby-comment">#matches from the database that we can run through our ruby matching algorithm</span>
|
245
|
-
<span class="ruby-identifier">
|
254
|
+
<span class="ruby-identifier">hit</span> = <span class="ruby-keyword">false</span>
|
246
255
|
<span class="ruby-identifier">name_array</span> = <span class="ruby-identifier">process_name</span>
|
247
256
|
|
248
257
|
<span class="ruby-identifier">name_array</span>.<span class="ruby-identifier">delete_if</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator"><</span> <span class="ruby-value">2</span>}
|
249
258
|
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">name_array</span>.<span class="ruby-identifier">empty?</span>
|
250
|
-
<span class="ruby-identifier">
|
251
|
-
<span class="ruby-identifier">sql_alt_name_partial</span> = <span class="ruby-identifier">name_array</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">partial_name</span><span class="ruby-operator">|</span> [<span class="ruby-string">"alternate_identity_name like ?"</span>, <span class="ruby-node">"%#{partial_name}%"</span>]}
|
252
|
-
|
253
|
-
<span class="ruby-identifier">name_conditions</span> = <span class="ruby-identifier">sql_name_partial</span>.<span class="ruby-identifier">transpose</span>
|
254
|
-
<span class="ruby-identifier">name_values</span> = <span class="ruby-identifier">name_conditions</span>.<span class="ruby-identifier">second</span>
|
255
|
-
<span class="ruby-identifier">name_conditions</span> = [<span class="ruby-identifier">name_conditions</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">' and '</span>)]
|
256
|
-
<span class="ruby-identifier">alt_name_conditions</span> = <span class="ruby-identifier">sql_alt_name_partial</span>.<span class="ruby-identifier">transpose</span>
|
257
|
-
<span class="ruby-identifier">alt_name_values</span> = <span class="ruby-identifier">alt_name_conditions</span>.<span class="ruby-identifier">second</span>
|
258
|
-
<span class="ruby-identifier">alt_name_conditions</span> = [<span class="ruby-identifier">alt_name_conditions</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">' and '</span>)]
|
259
|
-
<span class="ruby-identifier">conditions</span> = [<span class="ruby-node">"(#{name_conditions}) or (#{alt_name_conditions})"</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">name_values</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">alt_name_values</span>
|
260
|
-
|
261
|
-
<span class="ruby-identifier">possible_sdns</span> = <span class="ruby-constant">OfacSdn</span>.<span class="ruby-identifier">find_all_by_sdn_type</span>(<span class="ruby-string">'individual'</span>,<span class="ruby-value">:select</span> =<span class="ruby-operator">></span> <span class="ruby-string">'name, alternate_identity_name, address, city'</span>, <span class="ruby-value">:conditions</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">conditions</span>)
|
262
|
-
|
259
|
+
<span class="ruby-identifier">hit</span> = <span class="ruby-constant">OfacSdn</span>.<span class="ruby-identifier">possible_sdns</span>(<span class="ruby-identifier">name_array</span>).<span class="ruby-identifier">exists?</span>
|
263
260
|
<span class="ruby-keyword">end</span>
|
264
261
|
<span class="ruby-keyword">end</span>
|
265
|
-
<span class="ruby-
|
262
|
+
<span class="ruby-identifier">hit</span>
|
266
263
|
<span class="ruby-keyword">end</span></pre>
|
267
264
|
</div><!-- db_hit-3F-source -->
|
268
265
|
|
@@ -279,15 +276,17 @@ business, or marine vessel</p>
|
|
279
276
|
<div class="method-heading">
|
280
277
|
<span class="method-name">possible_hits</span><span
|
281
278
|
class="method-args">()</span>
|
279
|
+
|
282
280
|
<span class="method-click-advice">click to toggle source</span>
|
281
|
+
|
283
282
|
</div>
|
284
283
|
|
285
284
|
|
286
285
|
<div class="method-description">
|
287
286
|
|
288
|
-
<pre class="ruby"><span class="ruby-constant">Returns</span> <span class="ruby-identifier">an</span> <span class="ruby-identifier">array</span> <span class="ruby-identifier">of</span> <span class="ruby-identifier">hashes</span> <span class="ruby-identifier">of</span> <span class="ruby-identifier">records</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-constant">OFAC</span> <span class="ruby-identifier">data</span> <span class="ruby-identifier">that</span> <span class="ruby-identifier">found</span> <span class="ruby-identifier">partial</span> <span class="ruby-identifier">matches</span> <span class="ruby-identifier">with</span> <span class="ruby-identifier">that</span> <span class="ruby-identifier">record</span><span class="ruby-string"
|
287
|
+
<pre class="ruby"><span class="ruby-constant">Returns</span> <span class="ruby-identifier">an</span> <span class="ruby-identifier">array</span> <span class="ruby-identifier">of</span> <span class="ruby-identifier">hashes</span> <span class="ruby-identifier">of</span> <span class="ruby-identifier">records</span> <span class="ruby-keyword">in</span> <span class="ruby-identifier">the</span> <span class="ruby-constant">OFAC</span> <span class="ruby-identifier">data</span> <span class="ruby-identifier">that</span> <span class="ruby-identifier">found</span> <span class="ruby-identifier">partial</span> <span class="ruby-identifier">matches</span> <span class="ruby-identifier">with</span> <span class="ruby-identifier">that</span> <span class="ruby-identifier">record</span><span class="ruby-string">'s score.
|
289
288
|
|
290
|
-
Ofac.new({:name =>
|
289
|
+
Ofac.new({:name => '</span><span class="ruby-constant">Oscar</span> <span class="ruby-constant">Hernandez</span><span class="ruby-string">', :city => '</span><span class="ruby-constant">Clearwater</span><span class="ruby-string">', :address => '</span><span class="ruby-value">123</span> <span class="ruby-identifier">somewhere</span> <span class="ruby-identifier">ln</span><span class="ruby-string">'}).possible_hits
|
291
290
|
</span></pre>
|
292
291
|
|
293
292
|
<p>returns</p>
|
@@ -295,10 +294,11 @@ business, or marine vessel</p>
|
|
295
294
|
<pre class="ruby">[{:<span class="ruby-identifier">address=</span><span class="ruby-operator">></span><span class="ruby-string">"123 Somewhere Ln"</span>, :<span class="ruby-identifier">score=</span><span class="ruby-operator">></span><span class="ruby-value">100</span>, :<span class="ruby-identifier">name=</span><span class="ruby-operator">></span><span class="ruby-string">"HERNANDEZ, Oscar|GUAMATUR, S.A."</span>, :<span class="ruby-identifier">city=</span><span class="ruby-operator">></span><span class="ruby-string">"Clearwater"</span>}, {:<span class="ruby-identifier">address=</span><span class="ruby-operator">></span><span class="ruby-string">"123 Somewhere Ln"</span>, :<span class="ruby-identifier">score=</span><span class="ruby-operator">></span><span class="ruby-value">100</span>, :<span class="ruby-identifier">name=</span><span class="ruby-operator">></span><span class="ruby-string">"HERNANDEZ, Oscar|Alternate Name"</span>, :<span class="ruby-identifier">city=</span><span class="ruby-operator">></span><span class="ruby-string">"Clearwater"</span>}]
|
296
295
|
</pre>
|
297
296
|
|
297
|
+
|
298
298
|
|
299
299
|
|
300
300
|
<div class="method-source-code" id="possible_hits-source">
|
301
|
-
<pre><span class="ruby-comment"># File lib/ofac/models/ofac.rb, line
|
301
|
+
<pre><span class="ruby-comment"># File lib/ofac/models/ofac.rb, line 112</span>
|
302
302
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">possible_hits</span>
|
303
303
|
<span class="ruby-ivar">@possible_hits</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">retrieve_possible_hits</span>
|
304
304
|
<span class="ruby-keyword">end</span></pre>
|
@@ -317,7 +317,9 @@ business, or marine vessel</p>
|
|
317
317
|
<div class="method-heading">
|
318
318
|
<span class="method-name">score</span><span
|
319
319
|
class="method-args">()</span>
|
320
|
+
|
320
321
|
<span class="method-click-advice">click to toggle source</span>
|
322
|
+
|
321
323
|
</div>
|
322
324
|
|
323
325
|
|
@@ -330,14 +332,14 @@ data on the SDN (Specially Designated Nationals) list.</p>
|
|
330
332
|
matched. So if only name is matched, then the max score is the weight for
|
331
333
|
<code>:name</code> which is 60</p>
|
332
334
|
|
333
|
-
<p>It
|
334
|
-
score. If there is not a match on the element as it is passed in, then
|
335
|
+
<p>It's possible to get partial matches, which will add partial weight to
|
336
|
+
the score. If there is not a match on the element as it is passed in, then
|
335
337
|
each word element gets broken down and matches are tried on each partial
|
336
338
|
element. The weighting is distrubuted equally for each partial that is
|
337
339
|
matched.</p>
|
338
340
|
|
339
341
|
<p>If exact matches are not made, then a sounds like match is attempted. Any
|
340
|
-
match made by sounds like is given 75% of it
|
342
|
+
match made by sounds like is given 75% of it's weight to the score.</p>
|
341
343
|
|
342
344
|
<p>Example:</p>
|
343
345
|
|
@@ -374,13 +376,13 @@ and since Tyll was a sounds like match, it will add 30 * .75. So the
|
|
374
376
|
|
375
377
|
<p>If data is in the database for city and or address, and you pass data in
|
376
378
|
for these elements, the score will be reduced by 10% of the weight if there
|
377
|
-
is no match or sounds like match. So if you get a match on name,
|
378
|
-
already got a score of 60. So if you don
|
379
|
-
if you do, but there is no city or address info in the
|
380
|
-
final score will be 60. But if you do pass in a city,
|
381
|
-
city in the Database is New York, then we will deduct
|
382
|
-
* .1) = 3 from the score since 30 is the weight for
|
383
|
-
the final score will be 57.</p>
|
379
|
+
is no match or sounds like match. So if you get a match on name,
|
380
|
+
you've already got a score of 60. So if you don't pass in an
|
381
|
+
address or city, or if you do, but there is no city or address info in the
|
382
|
+
database, then your final score will be 60. But if you do pass in a city,
|
383
|
+
say Tampa, and the city in the Database is New York, then we will deduct
|
384
|
+
10% of the weight (30 * .1) = 3 from the score since 30 is the weight for
|
385
|
+
<code>:city</code>. So the final score will be 57.</p>
|
384
386
|
|
385
387
|
<p>If were searching for New York, and the database had New Deli, then there
|
386
388
|
would be a match on New, but not on Deli. Since there were 2 elements in
|
@@ -399,6 +401,7 @@ to the score if there is first a match on <code>:name</code>.</p>
|
|
399
401
|
|
400
402
|
<p>We consider a score of 60 to be reasonable as a hit.</p>
|
401
403
|
|
404
|
+
|
402
405
|
|
403
406
|
|
404
407
|
<div class="method-source-code" id="score-source">
|
@@ -425,7 +428,7 @@ to the score if there is first a match on <code>:name</code>.</p>
|
|
425
428
|
|
426
429
|
<footer id="validator-badges">
|
427
430
|
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
428
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a>
|
431
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
429
432
|
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
430
433
|
</footer>
|
431
434
|
|