Comments (4)
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.
@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.
@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.
@wyrfel Thank You. I'll give this a try.
from name-parser.
Related Issues (20)
- Issue with parsing Vietnamese names HOT 6
- Last, First, Suffix pattern is not parsed properly HOT 4
- Issue with initials before and after firstname HOT 3
- Overriding or appending to arrays (such as salutations) HOT 5
- Lastname is one of the recognised prefixes HOT 3
- Support multi-word salutations (like Air Commodore) HOT 4
- Parsing double last name failed HOT 2
- Packagist out of sync HOT 1
- Prefixes do not get recognized HOT 1
- Multibyte special character messes up initials HOT 1
- Output in vCard (RFC6350) matching form HOT 2
- Additional Salutations HOT 6
- Surname Prefix
- Capitalized names have strange behavior HOT 3
- The letter after the apostrophe is being capitalized
- Lastname Prefix not recognised if no first name
- UTF-8 encoding issue
- Is this still maintained? HOT 5
- Support Spanish-language names
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from name-parser.