-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First Name is a Known Title #21
Comments
That's doable: public void FirstNameIsTitle()
{
// Default behavior
var parsed_title = new HumanName("Junior Smith");
Assert.AreEqual(parsed_title.Title, "Junior");
Assert.AreEqual(parsed_title.First, "");
Assert.AreEqual(parsed_title.Last, "Smith");
// A single prefix should be treated as a first name when no first exists
var parsed_first = new HumanName("Junior Smith", Prefer.FirstOverTitle);
Assert.AreEqual(parsed_first.Title, "");
Assert.AreEqual(parsed_first.First, "Junior");
Assert.AreEqual(parsed_first.Last, "Smith");
} This would be opt-in functionality, as with the |
Sheikh is quite a common first name in some quarters. Mr Sheikh Akhtar Hussain A disbarred barrister in the UK apparently... Mr Sheikh Ahmad a plastic surgeon in Devon. |
Is your desired result for this input, then, Additionally, this is a bit different than the example in #20 because you do have a title on input; it's just grouping two potential titles ("Mr" & "Sheikh") and thinking that the remaining values are first and last, respectively. In my mind, the current behavior is reasonable (which is not to say that it's correct). Simply adding in a new preference flag for this particular input doesn't work the same. |
Apologies, I was just giving name examples of the use of a Title as a Name. For the Data that name would appear as: Sheikh Hussain Currently that would become: Title: Sheikh Where the desired result (where no existing first name) would be: First: Sheikh I have edited this because I realised I used the middle name as last. Would be interesting to know the outcome if the input is: Sheikh Akhtar Hussain |
Current version on my computer with the proposed flag will parse "Sheikh Akhtar Hussain" as Title First Last regardless of the use of However, public void FirstNameIsTitle2()
{
const string input = "Sheikh Hussain";
// Default behavior
var parsed_title = new HumanName(input);
Assert.AreEqual(parsed_title.Title, "Sheikh");
Assert.AreEqual(parsed_title.First, "");
Assert.AreEqual(parsed_title.Middle, "");
Assert.AreEqual(parsed_title.Last, "Hussain");
// A single prefix should be treated as a first name when no first exists
var parsed_first = new HumanName(input, Prefer.FirstOverTitle);
Assert.AreEqual(parsed_first.Title, "");
Assert.AreEqual(parsed_first.First, "Sheikh");
Assert.AreEqual(parsed_first.Middle, "");
Assert.AreEqual(parsed_first.Last, "Hussain");
} |
The Titles as First does cause a problem where there is a middle name. Programmatically it is difficult because Is Sheikh Akhtar Hussain a Sheikh called Akhtar Hussain or Sheikh Hussain with a middle name - is not a question you can answer programmatically. To be honest, it is not even a question that can be answered by a human being unless you have knowledge of the individual. I think the FirstOverTitle is a good fix for most edge cases - as you can see in my code, I separate out everything for Text To Columns in Excel - and it is then very easy to see the Titles - and skip through them - and if you spot an oddity to dip in and fix it if you need to. This parser reduces a task that takes literally hours to something that can be done in minutes. So thanks for putting it out there! |
I commented on issue #20 - but my issue was slightly different.
Within the list is "Junior" - which in my data at least is also a first name.
I saw the fix you made with the enum Prefer, I wondered whether you were considering the same for the Title? So we could have a Prefer.FirstOverTitle?
It is actually an easy fix on user end, so I wouldn't feel any urgency, just be nice to set a flag for it.
Nice tool btw very good and I have tried a few of these and written a couple myself - variation is just a killer with names.
The text was updated successfully, but these errors were encountered: