Giter Club home page Giter Club logo

Comments (4)

wyrfel avatar wyrfel commented on May 26, 2024

Hi @VinceG . Interesting. Yes, in it's current form the name parser expects the title up-front. The assumption is that if it's in the end, it would be separated by a comma. Do you have actual cases where the title is entered in the end without comma-separation? Theoretically (or rather from the mappers perspective) this should be possible to fix, but in the overall parse order scheme it could complicate things quite a bit as some of the mappers have to make assumptions about positioning.

from name-parser.

VinceG avatar VinceG commented on May 26, 2024

@wyrfel Thank You for the quick reply and fix.

This seems to fix the issue where the last word matches a salutation in the first case. However this does not seem to fix the other issues

Here are our test cases

/** @test */
    public function it_can_parse_saluation_at_end()
    {
        $parsed = (new NameParser)->parse('PAUL M LEWIS MR');
        
        $this->assertEquals('Paul', $parsed->getFirstName());
        $this->assertEquals('Lewis', $parsed->getLastName());
    }

    /** @test */
    public function it_can_parse_saluation_lastname()
    {
        $parsed = (new NameParser)->parse('SUJAN MASTER');

        $this->assertEquals('Sujan', $parsed->getFirstName());
        $this->assertEquals('Master', $parsed->getLastName());
    }

    /** @test */
    public function it_can_parse_saluation_lastname_with_middlename()
    {
        $parsed = (new NameParser)->parse('JAMES J MA');
        
        $this->assertEquals('James', $parsed->getFirstName());
        $this->assertEquals('Ma', $parsed->getLastName());
    }

the first one passes the second and third fail. It's worth noting that "PAUL M LEWIS MR" the MR at the end is not the salutation but rather part of his last name the way they write it.

1) Tests\Unit\ExampleTest::it_can_parse_saluation_lastname
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Sujan'
+''

/Users/vincentgabriel/Sites/fhalicenses/tests/Unit/ExampleTest.php:33

2) Tests\Unit\ExampleTest::it_can_parse_saluation_lastname_with_middlename
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Ma'
+''
TheIconic\NameParser\Name Object
(
    [parts:protected] => Array
        (
            [0] => TheIconic\NameParser\Part\Lastname Object
                (
                    [value:protected] => SUJAN
                )

            [1] => TheIconic\NameParser\Part\Salutation Object
                (
                    [normalized:protected] => Mr.
                    [value:protected] => MASTER
                )

        )

)

TheIconic\NameParser\Name Object
(
    [parts:protected] => Array
        (
            [0] => TheIconic\NameParser\Part\Firstname Object
                (
                    [value:protected] => JAMES
                )

            [1] => TheIconic\NameParser\Part\Initial Object
                (
                    [value:protected] => J
                )

            [2] => TheIconic\NameParser\Part\Suffix Object
                (
                    [normalized:protected] => MA
                    [value:protected] => MA
                )

        )

)

"SUJAN MASTER"
"JAMES J MA"
"PETER K MA"

The above all fail since the last name is considered a salutation even though it's actually the last name. I am not entirely sure how to properly fix this without having breaking changes. One solution that came to mind is checking the number of parts, if we have 2 parts that is should be considered as first and lastname but then it might cause problems when the name has any other combination of two words such as salutation firstname or middle last name etc..

Thanks again for the help.

from name-parser.

wyrfel avatar wyrfel commented on May 26, 2024

@VinceG All these cases should now be working in version 1.2.6.
I had misunderstood the issue originally, thank you for the clarifications.
I hope this solves the problem more generally for you.
Please see #16 for details.

from name-parser.

VinceG avatar VinceG commented on May 26, 2024

@wyrfel Thank You. I'll give this a try.

from name-parser.

Related Issues (20)

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.