namor 0.3.1 → 0.4.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.
- data/lib/namor/namor.rb +3 -3
- data/lib/namor/version.rb +1 -1
- data/spec/lib/namor_spec.rb +19 -0
- metadata +3 -3
data/lib/namor/namor.rb
CHANGED
@@ -17,13 +17,13 @@ class Namor::Namor
|
|
17
17
|
# * squeeze whitespace & trim spaces from ends
|
18
18
|
def scrub(name, opts = {})
|
19
19
|
suppression_list = @config[:suppress] || []
|
20
|
-
suppression_re = Regexp.new('\
|
20
|
+
suppression_re = Regexp.new('(\s|^)' + (suppression_list + (opts[:suppress]||[])).compact.map(&:upcase).join('|') + '(\s|\.|$)')
|
21
21
|
|
22
22
|
name && name.upcase.gsub(/^[ZX]{2,}/, '').gsub(suppression_re, '').gsub(/\b(JR|SR|II|III|IV)\b/i, '').gsub(/\([^\(]*\)/, '').gsub(/\./, ' ').gsub(/[_'\&]/, '').gsub(/,\s*$/, '').gsub(/ +/, ' ').strip
|
23
23
|
end
|
24
24
|
|
25
|
-
def fullscrub(name)
|
26
|
-
final_cleaning(scrub(name))
|
25
|
+
def fullscrub(name, opts = {})
|
26
|
+
final_cleaning(scrub(name, opts))
|
27
27
|
end
|
28
28
|
|
29
29
|
def demaiden(lastname)
|
data/lib/namor/version.rb
CHANGED
data/spec/lib/namor_spec.rb
CHANGED
@@ -136,3 +136,22 @@ describe "name componentization" do
|
|
136
136
|
@namor.scrub("Jones, Susan Select Transcriptionist", :suppress => ['transcriptionist', 'select transcriptionist']).should == 'JONES, SUSAN'
|
137
137
|
end
|
138
138
|
end
|
139
|
+
|
140
|
+
describe "title suppression" do
|
141
|
+
before(:all) do
|
142
|
+
@namor = Namor::Namor.new
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should only suppress isolated terms" do
|
146
|
+
@namor.scrub("Smith, Mary RN", :suppress => ['RN']).should == 'SMITH, MARY'
|
147
|
+
@namor.scrub("Smith, Marnie", :suppress => ['RN']).should == 'SMITH, MARNIE'
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should scrub words with periods" do
|
151
|
+
@namor.scrub("Smith, Mary M.D.", :suppress => ['M.D.']).should == 'SMITH, MARY'
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should scrub individual name components of punctuation and titles" do
|
155
|
+
@namor.fullscrub('Foxworthy-Smythe, ESQ.', :suppress => ['esq']).should == 'FOXWORTHYSMYTHE'
|
156
|
+
end
|
157
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash:
|
111
|
+
hash: -2390200260815377507
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
segments:
|
119
119
|
- 0
|
120
|
-
hash:
|
120
|
+
hash: -2390200260815377507
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
123
|
rubygems_version: 1.8.24
|