GithubHelp home page GithubHelp logo

Comments (6)

aeshirey avatar aeshirey commented on June 4, 2024

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?

from nameparsersharp.

Kaotic3 avatar Kaotic3 commented on June 4, 2024

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.

from nameparsersharp.

aeshirey avatar aeshirey commented on June 4, 2024

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.

from nameparsersharp.

Kaotic3 avatar Kaotic3 commented on June 4, 2024

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

from nameparsersharp.

aeshirey avatar aeshirey commented on June 4, 2024

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

from nameparsersharp.

Kaotic3 avatar Kaotic3 commented on June 4, 2024

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!

from nameparsersharp.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.