spec/lib/namor_spec.rb in namor-0.2.1 vs spec/lib/namor_spec.rb in namor-0.3.0
- old
+ new
@@ -3,11 +3,11 @@
require "spec_helper"
describe "name extract" do
before(:all) do
@namor = Namor::Namor.new
- @namor.config(:suppress => ['MD', 'dds'])
+ @namor.config(:suppress => ['MD', 'dds', 'M\.D\.'])
end
it "should handle 2-part names without commas" do
@namor.extract("john smith").should == ['JOHN', nil, 'SMITH', 'SMITH,JOHN']
end
@@ -34,14 +34,16 @@
it "should drop spaces in last name (only when input has a comma)" do
@namor.extract("Smith Jones, Mary").should == ['MARY', nil, 'SMITHJONES', 'SMITHJONES,MARY']
end
- it "should drop dashes & apostrophes" do
+ it "should drop dashes, apostrophes, ampersands" do
@namor.extract("Mary Smith-Jones").should == ['MARY', nil, 'SMITHJONES', 'SMITHJONES,MARY']
@namor.extract("Mary S. O'Keefe").should == ['MARY', 'S', 'OKEEFE', 'OKEEFE,MARY S']
@namor.extract("Jean-Michel Claude").should == ['JEANMICHEL', nil, 'CLAUDE', 'CLAUDE,JEANMICHEL']
+ @namor.extract("Smith, Bob & Sue").should == ['BOB', 'SUE', 'SMITH', 'SMITH,BOB SUE']
+ @namor.extract("Research & Development").should == ['RESEARCH', nil, 'DEVELOPMENT', 'DEVELOPMENT,RESEARCH']
end
it "should concatenate extract name pieces" do
@namor.extract("rajesh kumar vishnu garuda").should == ['RAJESH', nil, 'KUMARVISHNUGARUDA', 'KUMARVISHNUGARUDA,RAJESH']
@namor.extract("Kumar, Rajesh Vishnu Garuda").should == ['RAJESH', 'VISHNUGARUDA', 'KUMAR', 'KUMAR,RAJESH VISHNUGARUDA']
@@ -51,10 +53,11 @@
@namor.extract("Smith Jr, Edward M").should == ['EDWARD', 'M', 'SMITH', 'SMITH,EDWARD M']
end
it "should excise terms from optional suppression list" do
@namor.extract("Smith Jr, Edward M MD DDS").should == ['EDWARD', 'M', 'SMITH', 'SMITH,EDWARD M']
+ @namor.extract("Smith Jr, Edward M M.D.").should == ['EDWARD', 'M', 'SMITH', 'SMITH,EDWARD M']
@namor.extract("Smith Jr, Edward III MD PHD").should == ['EDWARD', 'PHD', 'SMITH', 'SMITH,EDWARD PHD']
end
it "should handle pathological cases" do
@namor.extract(", Mary Smith").should == ['MARY', 'SMITH', nil, 'MARY SMITH']
@@ -122,7 +125,10 @@
@namor.scrub("ZZJOHN SMITH").should == 'JOHN SMITH'
end
it "should allow case-specific word suppression" do
@namor.scrub("Amazing Magician", :suppress => ['magician', nil, 'conjuror']).should == 'AMAZING'
+ @namor.scrub("Jones, Susan Select Transcriptionist", :suppress => ['transcriptionist']).should == 'JONES, SUSAN SELECT'
+ @namor.scrub("Jones, Susan Select Transcriptionist", :suppress => ['select transcriptionist']).should == 'JONES, SUSAN'
+ @namor.scrub("Jones, Susan Select Transcriptionist", :suppress => ['transcriptionist', 'select transcriptionist']).should == 'JONES, SUSAN'
end
end