Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Name Parsing 2

Status
Not open for further replies.

EBOUGHEY

Programmer
Aug 20, 2002
143
US
I am trying to come up with some type of program that will parse multiple names to separate fields. The main issue is that there is no set format. Will I have to design some type of lookup table or do you think that CASE statements that evaluate the name field and perform the action will work? For instance, it removes companies first (lookup table we already have, looks for several formats and counts how many words each has, then processes?... (Below is a sample of the data)

"GRINDE, JAMES C; GRINDE, LINDA"
"GRINDE JAMES C & LINDA"
"Willis Corroon & Assoc."
"J. P. & R. B. Jordan III"
"Cecil & Frances Viverette Jr."
"Katherine M. & Jo Karen Lowman"
"Mr & Mrs Keith W. McLaurin"
"Don & Sara Casper"
"Morris & Venus Hendrix Jr."
"Donald & Jodi Lindsey III"
"Mary Ann & Robert McCoy Jr."
"Dr & Mrs Michael S. Patrick"
"Matthew Steven & Autumn Bullock Williams"
"Mr. & Mrs. David & Lu Thompson"
"Mr. & Mrs. Gary R. McNeill"
"W. Michael & Jill Scarbrough"
"John Douglas & Ann Lowe Vodicka"
 
Here's some object oriented code using Outlook's contact item to facilitate name parsing:
Code:
**********************************************
*
*	Sample code using clsOutlookNameParser
*
**********************************************
CLEAR

LOCAL loNameParser
loNameParser = CREATEOBJECT("clsOutlookNameParser")

loNameParser.FullName = "Dr. William T. Van Essen Sr."
? "Title: " + loNameParser.Title
? "First Name: " + loNameParser.FirstName
? "Middle Name: " + loNameParser.MiddleName
? "Last Name: " + loNameParser.LastName
? "Suffix Name: " + loNameParser.Suffix
? "Last Comma First: " + loNameParser.LastNameAndFirstName
? "Initials: " + loNameParser.Initials
?

loNameParser.FullName = "Mrs. Bellenton, Susan Elizabeth"
? "Title: " + loNameParser.Title
? "First Name: " + loNameParser.FirstName
? "Middle Name: " + loNameParser.MiddleName
? "Last Name: " + loNameParser.LastName
? "Suffix Name: " + loNameParser.Suffix
? "Last Comma First: " + loNameParser.LastNameAndFirstName
? "Initials: " + loNameParser.Initials
?

**********************************************
DEFINE CLASS clsOutlookNameParser as custom
**********************************************

	FullName = ""
	Title = ""
	FirstName = ""
	LastName = ""
	MiddleName = ""
	Suffix = ""
	LastNameAndFirstName = ""
	Initials = ""
	OutlookApp = NULL
	ContactItem = NULL
	
	PROCEDURE init
		this.OutlookApp = CreateObject("Outlook.Application")
		this.ContactItem = this.OutlookApp.CreateItem(2) && 2 = Contact Item
	ENDPROC
	
	PROCEDURE FullName_Assign
		LPARAMETERS m.vNewVal
		this.ContactItem.FullName = m.vNewVal
	ENDPROC
	
	PROCEDURE FullName_Access
		RETURN this.ContactItem.FullName
	ENDPROC
	
	PROCEDURE Title_Access
		RETURN this.ContactItem.Title
	ENDPROC
	
	PROCEDURE FirstName_Access
		RETURN this.ContactItem.FirstName
	ENDPROC
	
	PROCEDURE MiddleName_Access
		RETURN this.ContactItem.MiddleName
	ENDPROC
	
	PROCEDURE LastName_Access
		RETURN this.ContactItem.LastName
	ENDPROC
	
	PROCEDURE Suffix_Access
		RETURN this.ContactItem.Suffix
	ENDPROC

	PROCEDURE LastNameAndFirstName_Access
		RETURN this.ContactItem.LastNameAndFirstName
	ENDPROC

	PROCEDURE Initials_Access
		RETURN this.ContactItem.Initials
	ENDPROC
	
	PROCEDURE Destroy
		this.ContactItem.Close(1) && 1 = Discard
		this.OutlookApp.Quit()
		this.ContactItem = NULL
		this.OutlookApp = NULL
	ENDPROC
	
ENDDEFINE && clsOutlookNameParser

boyd.gif

 
Here's the next version of this that includes address parsing as well. (In the interest of showing other sources for this kind of thing, I found the following with a google search )
Code:
**********************************************
*
*	Sample code using clsOutlookParser
*
**********************************************
CLEAR

LOCAL loParser
loParser = CREATEOBJECT("clsOutlookParser")

loParser.FullName = "Dr. William T. Van Essen Sr."
loParser.Address = "315 SW 3rd Street" + CHR(13) + "Pipestone, MN 56164"
? "Title: " + loParser.Title
? "First Name: " + loParser.FirstName
? "Middle Name: " + loParser.MiddleName
? "Last Name: " + loParser.LastName
? "Suffix Name: " + loParser.Suffix
? "Last Comma First: " + loParser.LastNameAndFirstName
? "Initials: " + loParser.Initials
? "Street: " + loParser.Street
? "PostOfficeBox: " + loParser.PostOfficeBox
? "City: " + loParser.City
? "State: " + loParser.State
? "PostalCode: " + loParser.PostalCode
? "Country: " + loParser.Country
?

loParser.FullName = "Mrs. Bellenton, Susan Elizabeth"
loParser.Address = "315 SW 3rd Street" + CHR(13) + "Pipestone, MN 56164"
? "Title: " + loParser.Title
? "First Name: " + loParser.FirstName
? "Middle Name: " + loParser.MiddleName
? "Last Name: " + loParser.LastName
? "Suffix Name: " + loParser.Suffix
? "Last Comma First: " + loParser.LastNameAndFirstName
? "Initials: " + loParser.Initials
? "Street: " + loParser.Street
? "City: " + loParser.City
? "State: " + loParser.State
? "PostalCode: " + loParser.PostalCode
? "Country: " + loParser.Country
?

**********************************************
DEFINE CLASS clsOutlookParser as custom
**********************************************

	FullName = ""
	Title = ""
	FirstName = ""
	LastName = ""
	MiddleName = ""
	Suffix = ""
	LastNameAndFirstName = ""
	Initials = ""
	Address = ""
	Street = ""
	PostOfficeBox = ""
	City = ""
	State = ""
	PostalCode = ""
	Country = ""
	OutlookApp = NULL
	ContactItem = NULL
		
	PROCEDURE init
		this.OutlookApp = CreateObject("Outlook.Application")
		this.ContactItem = this.OutlookApp.CreateItem(2) && 2 = Contact Item
	ENDPROC
	
	PROCEDURE FullName_Assign
		LPARAMETERS m.vNewVal
		this.ContactItem.FullName = m.vNewVal
	ENDPROC
	
	PROCEDURE FullName_Access
		RETURN this.ContactItem.FullName
	ENDPROC
	
	PROCEDURE Title_Access
		RETURN this.ContactItem.Title
	ENDPROC
	
	PROCEDURE FirstName_Access
		RETURN this.ContactItem.FirstName
	ENDPROC
	
	PROCEDURE MiddleName_Access
		RETURN this.ContactItem.MiddleName
	ENDPROC
	
	PROCEDURE LastName_Access
		RETURN this.ContactItem.LastName
	ENDPROC
	
	PROCEDURE Suffix_Access
		RETURN this.ContactItem.Suffix
	ENDPROC

	PROCEDURE LastNameAndFirstName_Access
		RETURN this.ContactItem.LastNameAndFirstName
	ENDPROC

	PROCEDURE Initials_Access
		RETURN this.ContactItem.Initials
	ENDPROC

	PROCEDURE Address_Assign
		LPARAMETERS m.vNewVal
		this.ContactItem.OtherAddress = m.vNewVal
	ENDPROC
	
	PROCEDURE Address_Access
		RETURN this.ContactItem.OtherAddress
	ENDPROC

	PROCEDURE Street_Access
		RETURN this.ContactItem.OtherAddressStreet
	ENDPROC

	PROCEDURE City_Access
		RETURN this.ContactItem.OtherAddressCity
	ENDPROC

	PROCEDURE State_Access
		RETURN this.ContactItem.OtherAddressState
	ENDPROC

	PROCEDURE PostalCode_Access
		RETURN this.ContactItem.OtherAddressPostalCode
	ENDPROC

	PROCEDURE Country_Access
		RETURN this.ContactItem.OtherAddressCountry
	ENDPROC
	
	PROCEDURE Destroy
		this.ContactItem.Close(1) && 1 = Discard
		this.OutlookApp.Quit()
		this.ContactItem = NULL
		this.OutlookApp = NULL
	ENDPROC
	
ENDDEFINE && clsOutlookParser

boyd.gif

 
FYI.... I've been in Direct Mail for 15 years now working with data manipulation and parsing. To this day I haven't found any software that can handle name parsing better than another.

If I had to choose though, it would be Personator by Peoplesmith. Out of all the testing I've done on data, this software is the most robust and accurate.

IMO, Parseware wasn't near as effective in it's name parsing routine.

Just an observation.
 
I have also been in direct mail.. for some time.. over 30 years. EBOUGHEY is right, no better product exists than personator, I use it all the time with the best results of any program I have tried. Its worth paying for if you are working with large or multiple files. The only time I find a need to write code for parsing if is I am importing improperly formatted data.

Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top