kevintyll-ofac 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -1
- data/VERSION.yml +1 -1
- data/generators/ofac_migration/templates/migration.rb +1 -0
- data/lib/ofac/models/ofac.rb +17 -23
- data/test/test_helper.rb +1 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -11,4 +11,11 @@
|
|
11
11
|
== 1.1.0 2009-05-12
|
12
12
|
|
13
13
|
* 1 minor enhancement:
|
14
|
-
* Modified the match alogorithm to reduct the score if there is not an address or city match if the data is in the database.
|
14
|
+
* Modified the match alogorithm to reduct the score if there is not an address or city match if the data is in the database.
|
15
|
+
|
16
|
+
== 1.1.1 2009-05-13
|
17
|
+
|
18
|
+
* 2 minor changes:
|
19
|
+
* Changed the sql in the initial search to do a like instead of a soundex. For short names, the soundex returned almost the entire table
|
20
|
+
making the process take too long.
|
21
|
+
* Also changed the sql to only return individuals, also for the sake of performance.
|
data/VERSION.yml
CHANGED
data/lib/ofac/models/ofac.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'activerecord'
|
2
|
-
require 'active_record/connection_adapters/mysql_adapter'
|
3
|
-
|
4
1
|
class Ofac
|
5
2
|
|
6
3
|
|
@@ -99,29 +96,26 @@ class Ofac
|
|
99
96
|
|
100
97
|
def calculate_score
|
101
98
|
unless @identity[:name].to_s == ''
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
#http://jgeewax.wordpress.com/2006/07/21/efficient-sounds-like-searches-in-mysql/
|
113
|
-
possible_sdns = OfacSdn.connection.select_all("select concat(name,'|', alternate_identity_name) name, address, city
|
99
|
+
|
100
|
+
#first get a list from the database of possible matches by name
|
101
|
+
#this query is pretty liberal, we just want to get a list of possible
|
102
|
+
#matches from the database that we can run through our ruby matching algorithm
|
103
|
+
partial_name = @identity[:name].gsub(/\W/,'|')
|
104
|
+
name_array = partial_name.split('|')
|
105
|
+
name_array.delete('')
|
106
|
+
sql_name_partial = name_array.collect {|partial_name| "name like '%#{partial_name}%'"}.join(' or ')
|
107
|
+
sql_alt_name_partial = name_array.collect {|partial_name| "alternate_identity_name like '%#{partial_name}%'"}.join(' or ')
|
108
|
+
possible_sdns = OfacSdn.connection.select_all("select name, alternate_identity_name, address, city
|
114
109
|
from ofac_sdns
|
115
110
|
where name is not null
|
116
|
-
and
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
111
|
+
and sdn_type = 'individual'
|
112
|
+
and #{sql_name_partial}
|
113
|
+
or #{sql_alt_name_partial}")
|
114
|
+
possible_sdns = possible_sdns.collect {|sdn|{:name => "#{sdn['name']}|#{sdn['alternate_identity_name']}", :city => sdn['city'], :address => sdn['address']}}
|
115
|
+
|
122
116
|
match = OfacMatch.new({:name => {:weight => 60, :token => "#{@identity[:name]}"},
|
123
|
-
|
124
|
-
|
117
|
+
:address => {:weight => 10, :token => @identity[:address]},
|
118
|
+
:city => {:weight => 30, :token => @identity[:city]}})
|
125
119
|
|
126
120
|
score = match.score(possible_sdns)
|
127
121
|
@possible_hits = match.possible_hits
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kevintyll-ofac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Tyll
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|