Code behind my website at jasonpriem.org
jasonpriem / humannameparser.php Goto Github PK
View Code? Open in Web Editor NEWReturns the parts (leading initial, first, middle, last, suffix) of a name from a string.
License: MIT License
Returns the parts (leading initial, first, middle, last, suffix) of a name from a string.
License: MIT License
Code behind my website at jasonpriem.org
wow, this would be great to have available in R.
Parser.php, lines 147 & 156. I believe “$this->nameStr” should be “$this->name”.
As-is, it throws a fatal error:
“Call to a member function getStr() on a non-object”
via http://jasonpriem.com/human-name-parse/comment-page-1/#comment-16645
Hi,
your test case does not include common writings like
Чайковский В. Н.
Чайковский ВН
which are used without colon in russian language.
Maybe you should explicitely warn that certain asian languages write names without colon in the opposite order to English which is hard to detect. Similarly, the German naming tradition has no strict order so the categories first name and middle name do not apply. In that tradition there exist only given names and an arbitrary nonempty subset of them was marked as calling names (comparible to the first name in USA or Russia) the others are treated like middle names in the USA, while they are freely chosen by the parents.
Hi, after reading about R and Node ports, and needing to use similar library in Java, here's my take on a Java port of HumanNameParser.php
https://github.com/tupilabs/HumanNameParser.java
I tried to keep the design, code, if/else's, and even tests (used testNames.txt too in the tests).
The code is ready to be deployed to Maven Central repository if there is no objection. I've added the copyright, kept the license and tried to let it clear that the code is a port of the original PHP library.
Thank you!
Google contacts has EXCELLENT name parsing for all languages.
https://www.google.com/contacts/#contacts
To illustrate: it knows that 诸葛亮 is last name 诸葛 and first name 亮, but it also knows that 柏夫人 is last name 柏 first name 夫人. This is done without language hinting, and it even recognizes the difference between Chinese and Japanese names, which could even use the same characters.
Although your library does not support it today, I request to add these and other examples to the test suite. The will fail, but it will demonstrate the scope and limits of this library.
Please parse out professional titles like MD, CFA, RN, CFP, PA...
And military suffix
Hi,
So I tried using your library to parse customer names coming in from an online ordering system.
Some names tend to just be one word, like "Henry". Your library throws an exception and halts execution if I try to get a last name from cases where there is only a single word. Why not just return ""? Or maybe an option for how strict it should be when returning name parts?
Like
level 1, halt for all missing pieces
level 2, just return empty string for missing pieces with no errors
Could this library be added to Packagist?
https://packagist.org/
thanks!
david barratt
This is good little parser, but trying it with php 7 I found that the Title and Suffix expressions no longer work as expected. The space between them and the name was not being detected in the pattern so names like "Frank Tester" were becoming "ank Tester"
Here's the update to those patterns. I will try to come back later and do a proper pull request, but for now, here's the update needed in Parse.php
$nicknamesRegex
= "/ ('|\"|\(\"*'*)(.+?)('|\"|\"*'*\)) /"; // names that starts or end w/ an apostrophe break this
- $titleRegex = "/^($titles)/";
- $suffixRegex = "/,* *($suffixes)$/";
+ $titleRegex = "/^($titles)\s+/";
+ $suffixRegex = "/\,?\s+($suffixes)$/";
$lastRegex = "/(?!^)\b([^ ]+ y |$prefixes)*[^ ]+$/";
$leadingInitRegex = "/^(.\.*)(?= \p{L}{2})/"; // note the lookahead, which isn't returned or replaced
$firstRegex = "/^[^ ]+/"; //
It looks like this may handle middle names better than the only package on npmjs.org that does name parsing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.