Comments (6)
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.
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.
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.
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.
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.
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)
- Nickname parsing failed when single quotes are used and nickname is at beginning of string HOT 2
- Req: Seperate prefixes HOT 5
- Additional prefix (for config.cs) HOT 2
- Improvement: A few examples that aren't parsing properly HOT 2
- NuGet DLL version is incorrect HOT 2
- Parser throws ArgumentOutOfRangeExceptionexception when name has parenthesis (just nickname) HOT 1
- Incorrectly identifying name parts HOT 3
- Name with suffix and last name prefix fail to parse correctly
- Support for netstandard HOT 1
- Invalid Name Parsing HOT 1
- Invalid Parsing HOT 1
- Request functionality to add to lists. HOT 3
- Request to accept 2 names in first name
- First name is a known prefix HOT 8
- D'Juan O'Connor does not parse properly
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 nameparsersharp.