[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need name extraction function?

Posted on 2007-11-16
6
Medium Priority
?
255 Views
Last Modified: 2013-11-07
I need some functions that will take a person's full name as a string, and attempt to extract the various piecces of it, i.e.:

GetFirstName(), GetNamePrefix(), GetMiddleName(), GetNameSuffix()

What I would pass in would be something like:
John Doe
Dr. Alvin Chipmunk Ph.D.
Miss Mary Kate O'Reily
Mr. Alberto Juan De Laurentis

I was hoping that there might be some functions out there already to handle this so I wouldn't have to re-invent the wheel? I'll take code in either C# or VB.NET, or whatever really, as long as it can be converted to .NET of some sort.
0
Comment
Question by:toddhd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20300189
Is is not as easy. Consider this case:
Juan Marcelo Menotti
How you will know if Marcelo is the Middle Name or it is the second first name?
A dictionary will be useless.

You can try to attack the problem by a different side. Store the name components separately:


class PersonName
{
    string Prefix;
    string FirstName;
    string MidName;
    string LastName;
    string Suffix;
 
    public string GetFirstName() { return FirstName; }
    public string GetMiddleName() { return MidName; }
    public string GetLastName() { return LastName; } 
    // etcetera
 
    public override string ToString()
   {
         StringBuilder sb = new StringBuilder();
         if (!string.IsNullOrEmpty(Prefix))
               sb.Append(Prefix+" ");
         if (!string.IsNullOrEmpty(FirstName))
               sb.Append(FirstName+" ");
         if (!string.IsNullOrEmpty(MidName))
               sb.Append(MidName+" ");
         // etcetera
    }
}

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20300195
sorry, ToString method should end with:

    return sb.ToString();
}
0
 
LVL 8

Author Comment

by:toddhd
ID: 20300480
jaime,
I agree with you approach completely, but I just dont have that luxury :)
I have a client (a bank no less) that has some very old data in a database where the names have been entered as one long string, and well - you guessed it, they want to get the data back out.
I am working on my own function, and made up a list of prefixes I know of to check against. Postfixes are tougher as they are practically limitless, and some have periods (Ph.D., Sr. D.D.S) and some don't (such as roman numerals). At some point, I just have to make an educated guess.

The first/last name thing is an issue with non-American names, and middle names can get out of hand sometimes as well, since there can be multiple ones.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:JimBrandley
ID: 20300581
I would start with a split on blanks. You can deduce some of the structure by knowing the number of elements in the name.
string fullName = "Dr. Ralph Waldo Emerson III Esq., PhD, MD";
string[] elements = fullName.Split(' ');

Jim
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 20300645
toddhd,
I have been there.
A possible approach is to make a semi-automated migration, one-by-one. Create a migration application where you suggest an interpretation and let user to choose a name structure, some UI with radio buttons  like (using Jim's example):

Full Name: Dr. Ralph Waldo Emerson III Esq., PhD, MD
 
Please correct name structure, if needed:
Dr.      (x) Prefix, ( ) First, ( ) Middle, ( ) Last, ( ) Postfix 
Ralph    ( ) Prefix, (x) First, ( ) Middle, ( ) Last, ( ) Postfix 
Waldo    ( ) Prefix, ( ) First, (x) Middle, ( ) Last, ( ) Postfix
Emerson  ( ) Prefix, ( ) First, (x) Middle, ( ) Last, ( ) Postfix 
III      ( ) Prefix, ( ) First, ( ) Middle, (x) Last, ( ) Postfix
Esq.     ( ) Prefix, ( ) First, ( ) Middle, ( ) Last, (x) Postfix
PhD      ( ) Prefix, ( ) First, ( ) Middle, ( ) Last, (x) Postfix
MD       ( ) Prefix, ( ) First, ( ) Middle, ( ) Last, (x) Postfix

Open in new window

0
 
LVL 8

Author Closing Comment

by:toddhd
ID: 31409605
jaime, I'm just going to award you the points. While it's not an exact answer, it at least tells me that I'm on the right track with what I'm doing, and that no pre-written methiod exists to do this. I'll have to post my code somewhere once I'm done so other people can use it i nthe future :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question