python-nameparser icon indicating copy to clipboard operation
python-nameparser copied to clipboard

Strange parsing of name w lastname prefix and title before and after

Open kaspersorensen opened this issue 6 years ago • 2 comments

The combination of having lastname prefixes and repeated titles before and after a name seems to break the parsers logic around middle name handling.

Here's a test that fails:

        hn = HumanName("dr Vincent van Gogh dr")
        self.assertEqual("Vincent", hn.first)
        self.assertEqual("van", hn.middle)
        self.assertEqual("Gogh", hn.last)

For some reason, the middle name comes out as dr Vincent van instead of the expected van.

kaspersorensen avatar Dec 10 '19 18:12 kaspersorensen

Current master does this:

% python tests.py "dr Vincent van Gogh dr"
<HumanName : [
	title: 'dr' 
	first: 'Vincent' 
	middle: ' dr Vincent van' 
	last: 'Gogh' 
	suffix: 'dr'
	nickname: ''
]>

Actually this is what I would expect because "van" is a prefix and should attach itself to the following piece.

% python tests.py "dr Vincent van Gogh dr"
<HumanName : [
	title: 'dr' 
	first: 'Vincent' 
	middle: '' 
	last: 'van Gogh' 
	suffix: 'dr'
	nickname: ''
]>

I think this is a valid bug but I'm not sure what the issue is.

derek73 avatar Dec 12 '19 04:12 derek73

actually, "van" is not a prefix because it is sometimes a first name. So you're right, this should be the expected output:

% python tests.py "dr Vincent van Gogh dr"
<HumanName : [
	title: 'dr' 
	first: 'Vincent' 
	middle: 'van' 
	last: 'Gogh' 
	suffix: 'dr'
	nickname: ''
]>

derek73 avatar Dec 12 '19 05:12 derek73