ofac 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,207 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: String</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">String</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/ofac/ruby_string_extensions_rb.html">
59
+ lib/ofac/ruby_string_extensions.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000003">ofac_soundex</a>&nbsp;&nbsp;
90
+ <a href="#M000004">ofac_sounds_like</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+ <div id="constants-list">
103
+ <h3 class="section-bar">Constants</h3>
104
+
105
+ <div class="name-list">
106
+ <table summary="Constants">
107
+ <tr class="top-aligned-row context-row">
108
+ <td class="context-item-name">Ofac_SoundexChars</td>
109
+ <td>=</td>
110
+ <td class="context-item-value">'BPFVCSKGJQXZDTLMNR'</td>
111
+ </tr>
112
+ <tr class="top-aligned-row context-row">
113
+ <td class="context-item-name">Ofac_SoundexNums</td>
114
+ <td>=</td>
115
+ <td class="context-item-value">'111122222222334556'</td>
116
+ </tr>
117
+ <tr class="top-aligned-row context-row">
118
+ <td class="context-item-name">Ofac_SoundexCharsEx</td>
119
+ <td>=</td>
120
+ <td class="context-item-value">'^' + Ofac_SoundexChars</td>
121
+ </tr>
122
+ <tr class="top-aligned-row context-row">
123
+ <td class="context-item-name">Ofac_SoundexCharsDel</td>
124
+ <td>=</td>
125
+ <td class="context-item-value">'^A-Z'</td>
126
+ </tr>
127
+ </table>
128
+ </div>
129
+ </div>
130
+
131
+
132
+
133
+
134
+
135
+
136
+ <!-- if method_list -->
137
+ <div id="methods">
138
+ <h3 class="section-bar">Public Instance methods</h3>
139
+
140
+ <div id="method-M000003" class="method-detail">
141
+ <a name="M000003"></a>
142
+
143
+ <div class="method-heading">
144
+ <a href="#M000003" class="method-signature">
145
+ <span class="method-name">ofac_soundex</span><span class="method-args">(census = true)</span>
146
+ </a>
147
+ </div>
148
+
149
+ <div class="method-description">
150
+ <p>
151
+ desc: <a
152
+ href="http://en.wikipedia.org/wiki/Soundex">en.wikipedia.org/wiki/Soundex</a>
153
+ </p>
154
+ <p><a class="source-toggle" href="#"
155
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
156
+ <div class="method-source-code" id="M000003-source">
157
+ <pre>
158
+ <span class="ruby-comment cmt"># File lib/ofac/ruby_string_extensions.rb, line 9</span>
159
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ofac_soundex</span>(<span class="ruby-identifier">census</span> = <span class="ruby-keyword kw">true</span>)
160
+ <span class="ruby-identifier">str</span> = <span class="ruby-identifier">upcase</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-constant">Ofac_SoundexCharsDel</span>).<span class="ruby-identifier">squeeze</span>
161
+
162
+ <span class="ruby-identifier">str</span>[<span class="ruby-value">0</span> <span class="ruby-operator">..</span> <span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">str</span>[<span class="ruby-value">1</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>].
163
+ <span class="ruby-identifier">delete</span>(<span class="ruby-constant">Ofac_SoundexCharsEx</span>).
164
+ <span class="ruby-identifier">tr</span>(<span class="ruby-constant">Ofac_SoundexChars</span>, <span class="ruby-constant">Ofac_SoundexNums</span>)[<span class="ruby-value">0</span> <span class="ruby-operator">..</span> (<span class="ruby-identifier">census</span> <span class="ruby-value">? </span><span class="ruby-value">2</span> <span class="ruby-operator">:</span> <span class="ruby-value">-1</span>)].
165
+ <span class="ruby-identifier">ljust</span>(<span class="ruby-value">3</span>, <span class="ruby-value str">'0'</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-value str">''</span>
166
+ <span class="ruby-keyword kw">end</span>
167
+ </pre>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <div id="method-M000004" class="method-detail">
173
+ <a name="M000004"></a>
174
+
175
+ <div class="method-heading">
176
+ <a href="#M000004" class="method-signature">
177
+ <span class="method-name">ofac_sounds_like</span><span class="method-args">(other, census = true)</span>
178
+ </a>
179
+ </div>
180
+
181
+ <div class="method-description">
182
+ <p><a class="source-toggle" href="#"
183
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
184
+ <div class="method-source-code" id="M000004-source">
185
+ <pre>
186
+ <span class="ruby-comment cmt"># File lib/ofac/ruby_string_extensions.rb, line 18</span>
187
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ofac_sounds_like</span>(<span class="ruby-identifier">other</span>, <span class="ruby-identifier">census</span> = <span class="ruby-keyword kw">true</span>)
188
+ <span class="ruby-identifier">ofac_soundex</span>(<span class="ruby-identifier">census</span>) <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">ofac_soundex</span>(<span class="ruby-identifier">census</span>)
189
+ <span class="ruby-keyword kw">end</span>
190
+ </pre>
191
+ </div>
192
+ </div>
193
+ </div>
194
+
195
+
196
+ </div>
197
+
198
+
199
+ </div>
200
+
201
+
202
+ <div id="validator-badges">
203
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
204
+ </div>
205
+
206
+ </body>
207
+ </html>
@@ -0,0 +1 @@
1
+ Tue, 21 Dec 2010 12:36:28 -0500
@@ -0,0 +1,317 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README.rdoc</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README.rdoc</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README.rdoc
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue May 12 11:20:38 -0400 2009</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>ofac</h1>
73
+ <ul>
74
+ <li><a href="http://kevintyll.github.com/ofac">kevintyll.github.com/ofac</a>
75
+
76
+ </li>
77
+ <li><a href="http://www.drexel-labs.com">www.drexel-labs.com</a>
78
+
79
+ </li>
80
+ <li><a
81
+ href="http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml">www.treas.gov/offices/enforcement/ofac/sdn/index.shtml</a>
82
+
83
+ </li>
84
+ </ul>
85
+ <h2>DESCRIPTION:</h2>
86
+ <p>
87
+ ofac is a ruby gem that tries to find a match of a person&#8216;s name and
88
+ address against the Office of Foreign Assets Control&#8216;s Specially
89
+ Designated Nationals list...the so called terrorist watch list.
90
+ </p>
91
+ <p>
92
+ This gem, like the ssn_validator gem, started as a need for the company I
93
+ work for, Clarity Services Inc. We decided once again to create a gem out
94
+ of it and share it with the community. Much thanks goes to the management
95
+ at Clarity Services Inc. for allowing this code to be open sourced. Thanks
96
+ also to Larry Berland at Clarity Services Inc. The matching logic in the
97
+ ofac_match.rb file was derived from his work.
98
+ </p>
99
+ <h2>FEATURES:</h2>
100
+ <p>
101
+ Creates a score, 1 - 100, based on how well the name, address and city
102
+ match the data on the SDN list. Since we have to match on strings, the
103
+ likely hood of an exact match are virtually nil. So we&#8216;ve created an
104
+ algorithm that creates a score. The better the match, the higher the score.
105
+ A score of 100 would be a perfect match.
106
+ </p>
107
+ <p>
108
+ The score is calculated by adding up the weightings of each part that is
109
+ matched. So if only name is matched, then the max score is the weight for
110
+ <tt>:name</tt> which is 60
111
+ </p>
112
+ <p>
113
+ It&#8216;s possible to get partial matches, which will add partial weight
114
+ to the score. If there is not a match on the element as it is passed in,
115
+ then each word element gets broken down and matches are tried on each
116
+ partial element. The weighting is distrubuted equally for each partial that
117
+ is matched.
118
+ </p>
119
+ <p>
120
+ If exact matches are not made, then a sounds like match is attempted. Any
121
+ match made by sounds like is given 75% of it&#8216;s weight to the score.
122
+ Example:
123
+ </p>
124
+ <p>
125
+ If you are trying to match the name Kevin Tyll and there is a record for
126
+ Smith, Kevin in the database, then we will try to match both Kevin and Tyll
127
+ separately, with each element Smith and Kevin. Since only Kevin will find a
128
+ match, and there were 2 elements in the searched name, the score will be
129
+ added by half the weighting for <tt>:name</tt>. So since the weight for
130
+ <tt>:name</tt> is 60, then we will add 30 to the score.
131
+ </p>
132
+ <p>
133
+ If you are trying to match the name Kevin Gregory Tyll and there is a
134
+ record for Tyll, Kevin in the database, then we will try to match Kevin and
135
+ Gregory and Tyll separately, with each element Tyll and Kevin. Since both
136
+ Kevin and Tyll will find a match, and there were 3 elements in the searched
137
+ name, the score will be added by 2/3 the weighting for <tt>:name</tt>. So
138
+ since the weight for <tt>:name</tt> is 60, then we will add 40 to the
139
+ score.
140
+ </p>
141
+ <p>
142
+ If you are trying to match the name Kevin Tyll and there is a record for
143
+ Kevin Gregory Tyll in the database, then we will try to match Kevin and
144
+ Tyll separately, with each element Tyll and Kevin and Gregory. Since both
145
+ Kevin and Tyll will find a match, and there were 2 elements in the searched
146
+ name, the score will be added by 2/2 the weighting for <tt>:name</tt>. So
147
+ since the weight for <tt>:name</tt> is 60, then we will add 60 to the
148
+ score.
149
+ </p>
150
+ <p>
151
+ If you are trying to match the name Kevin Tyll, and there is a record for
152
+ Teel, Kevin in the database, then an exact match will be found for Kevin,
153
+ and a sounds like match will be made for Tyll. Since there were 2 elements
154
+ in the searched name, and the weight for <tt>:name</tt> is 60, then each
155
+ element is worth 30. Since Kevin was an exact match, it will add 30, and
156
+ since Tyll was a sounds like match, it will add 30 * .75. So the
157
+ <tt>:name</tt> portion of the search will be worth 53.
158
+ </p>
159
+ <p>
160
+ If data is in the database for city and or address, and you pass data in
161
+ for these elements, the score will be reduced by 10% of the weight if there
162
+ is no match or sounds like match. So if you get a match on name,
163
+ you&#8216;ve already got a score of 60. So if you don&#8216;t pass in an
164
+ address or city, or if you do, but there is no city or address info in the
165
+ database, then your final score will be 60. But if you do pass in a city,
166
+ say Tampa, and the city in the Database is New York, then we will deduct
167
+ 10% of the weight (30 * .1) = 3 from the score since 30 is the weight for
168
+ <tt>:city</tt>. So the final score will be 57.
169
+ </p>
170
+ <p>
171
+ If were searching for New York, and the database had New Deli, then there
172
+ would be a match on New, but not on Deli. Since there were 2 elements in
173
+ the searched city, each hit is worth 15. So the match on New would add 15,
174
+ but the non-match on York would subtract (15 * .1) = 1.5 from the score. So
175
+ the score would be (60 + 15 - 1.5) = 74, due to rounding.
176
+ </p>
177
+ <p>
178
+ Only <tt>:city</tt> and <tt>:address</tt> subtract from the score, No match
179
+ on name simply returns 0.
180
+ </p>
181
+ <p>
182
+ Matches for name are made for both the name and any aliases in the OFAC
183
+ database.
184
+ </p>
185
+ <p>
186
+ Matches for <tt>:city</tt> and <tt>:address</tt> will only be added to the
187
+ score if there is first a match on <tt>:name</tt>.
188
+ </p>
189
+ <p>
190
+ We consider a score of 60 to be reasonable as a hit.
191
+ </p>
192
+ <h2>SYNOPSIS:</h2>
193
+ <p>
194
+ Accepts a hash with the identity&#8216;s demographic information
195
+ </p>
196
+ <pre>
197
+ Ofac.new({:name =&gt; 'Oscar Hernandez', :city =&gt; 'Clearwater', :address =&gt; '123 somewhere ln'})
198
+ </pre>
199
+ <p>
200
+ <tt>:name</tt> is required to get a score. If <tt>:name</tt> is missing, an
201
+ error will not be thrown, but a score of 0 will be returned.
202
+ </p>
203
+ <p>
204
+ The more information provided, the higher the score could be. A score of
205
+ 100 would mean all fields were passed in, and all fields were 100% matches.
206
+ If only the name is passed in without an address, it will be impossible to
207
+ get a score of 100, even if the name matches perfectly.
208
+ </p>
209
+ <p>
210
+ Acceptable hash keys and their weighting in score calculation:
211
+ </p>
212
+ <ul>
213
+ <li><tt>:name</tt> (weighting = 60%) (required) This can be a person, business,
214
+ or marine vessel
215
+
216
+ </li>
217
+ <li><tt>:address</tt> (weighting = 10%)
218
+
219
+ </li>
220
+ <li><tt>:city</tt> (weighting = 30%)
221
+
222
+ </li>
223
+ <li>Instantiate the object with the identity&#8216;s name, street address, and
224
+ city.
225
+
226
+ <pre>
227
+ ofac = Ofac.new(:name =&gt; 'Kevin Tyll', :city =&gt; 'Clearwater', :address =&gt; '123 Somewhere Ln.')
228
+ </pre>
229
+ </li>
230
+ <li>Then get the score
231
+
232
+ <pre>
233
+ ofac.score =&gt; return the score 1 - 100
234
+ </pre>
235
+ </li>
236
+ <li>You can also get the list of all the partial matches with the score of each
237
+ record.
238
+
239
+ <pre>
240
+ ofac.possible_hits =&gt; returns an array of hashes.
241
+ </pre>
242
+ </li>
243
+ </ul>
244
+ <h2>REQUIREMENTS:</h2>
245
+ <ul>
246
+ <li>Rails 2.0.0 or greater
247
+
248
+ </li>
249
+ </ul>
250
+ <h2>INSTALL:</h2>
251
+ <ul>
252
+ <li>To install the gem:
253
+
254
+ <pre>
255
+ sudo gem install kevintyll-ofac
256
+ </pre>
257
+ </li>
258
+ <li>To create the necessary db migration, from the command line, run:
259
+
260
+ <pre>
261
+ script/generate ofac_migration
262
+ </pre>
263
+ </li>
264
+ <li>Require the gem in your environment.rb file in the Rails::Initializer
265
+ block:
266
+
267
+ <pre>
268
+ config.gem 'kevintyll-ofac', :lib =&gt; 'ofac'
269
+ </pre>
270
+ </li>
271
+ <li>To load your table with the current OFAC data, from the command line, run:
272
+
273
+ <pre>
274
+ rake ofac:update_data
275
+
276
+ * The OFAC data is not updated with any regularity, but you can sign up for email notifications when the data changes at
277
+ http://www.treas.gov/offices/enforcement/ofac/sdn/index.shtml.
278
+ </pre>
279
+ </li>
280
+ </ul>
281
+ <h2>Copyright</h2>
282
+ <p>
283
+ Copyright (c) 2009 Kevin Tyll. See LICENSE for details.
284
+ </p>
285
+
286
+ </div>
287
+
288
+
289
+ </div>
290
+
291
+
292
+ </div>
293
+
294
+
295
+ <!-- if includes -->
296
+
297
+ <div id="section">
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+ <!-- if method_list -->
307
+
308
+
309
+ </div>
310
+
311
+
312
+ <div id="validator-badges">
313
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
314
+ </div>
315
+
316
+ </body>
317
+ </html>