Skip to content
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

Open
Kaotic3 opened this issue Jan 17, 2022 · 6 comments
Open

First Name is a Known Title #21

Kaotic3 opened this issue Jan 17, 2022 · 6 comments

Comments

@Kaotic3
Copy link

Kaotic3 commented Jan 17, 2022

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.

if (testName.Title != "" && testName.First == "")
    {
        sb.Append("" + "þ" + testName.Title + "þ" + testName.Middle + "þ" + testName.Last + "þ" + testName.Suffix + Environment.NewLine);
    }
    else
    {
        sb.Append(testName.Title + "þ" + testName.First + "þ" + testName.Middle + "þ" + testName.Last + "þ" + testName.Suffix + Environment.NewLine);
    }

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.

@aeshirey
Copy link
Owner

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 FirstOverPrefix. Do you have any other examples that I could include to verify functionality?

@Kaotic3
Copy link
Author

Kaotic3 commented Jan 17, 2022

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.

@aeshirey
Copy link
Owner

Is your desired result for this input, then, title=Mr, first=Sheikh, middle=Akhtar, last=Hussain? My proposed change currently drops 'Akhtar' into the first name field, so the post-processing to move 'Sheikh' to first doesn't quite work.

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.

@Kaotic3
Copy link
Author

Kaotic3 commented Jan 17, 2022

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
Last: Hussain

Where the desired result (where no existing first name) would be:

First: Sheikh
Last: Hussain

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

@aeshirey
Copy link
Owner

Current version on my computer with the proposed flag will parse "Sheikh Akhtar Hussain" as Title First Last regardless of the use of FirstOverTitle.

However, Sheikh Hussain will by default (current published version) parse as Title Last, but with Prefer.FirstOverTitle will flip this to be First Last:

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");
}

@Kaotic3
Copy link
Author

Kaotic3 commented Jan 17, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants