You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MSc in title makes for some strange behaviour. #41
I am currently trying to parse names with the nameparser which works perfectly fine, except i encounter some errors when trying to parse trailing titles such as MSc.
Here is a small example of what I am trying to do:
The first example works perfectly fine, but as soon as MSc is in the game it doesnt recognize the other titles nor split the name correctly. I have added MSc (as well as med. + univ.) to the CONSTANTS but it doesnt seem to help. It also acts strange when i just use default settings:
>>>HumanName("Dr. med. univ. Margit Popp, MSc")
<HumanName : [
title: 'MSc Dr. med. univ.'first: 'Margit'middle: ''last: 'Popp'suffix: ''nickname: ''
]>
I am running python 3.4 with the latest version of nameparser. Is there any possibility of making this work? Am i just missing some customizable setting?
Hmm, it looks like a bug. Thanks for reporting it. I'll look into it.
One probably minor thing, the MSc would go into the suffix property because it comes at the end of the name. In a future version I'm going to change those attribute names to prenominal and postnominal so people don't expect it to be semantic. It's based solely on position in the string.
Ahh, I see now. It's because "MSc" is not in a recognized suffix, so it assumes it's the "lastname, firstname" format. If you add "MSc" to your suffixes set it should work as expected.
>>> from nameparser.config import CONSTANTS
>>> CONSTANTS.suffixes.add('msc')
I'll go ahead and add that to the suffix/post-nominal constants in the next release.
Another one i have though is that if i add MSc to both suffixes and titles it doesnt work. It works fine for MSc in one of those two though. The data i have is very messy sadly so some rows have the MSc as a prefix others as a suffix. Is there any possibility of incorporating those two?
Otherwise i'd have to get a bit dirty with multiple instances i guess.
Thanks for your fast and thorough response though, appreciate it!
edit:
hm, doesnt seem the suffix is working sometimes, for instance i have added msc to titles as well as suffixes and get the following results:
>>>HumanName("MSc Dr. Margit Popp MSc")
<HumanName : [
title: 'MSc Dr.'first: 'Margit'middle: 'Popp'last: 'MSc'suffix: ''nickname: ''
]>
I would expect MSc to be in the suffix too, even if i omit the first MSc it doesnt get parsed even though it is in the suffix set.
Ok, I think I figured out what's going on. I recently separated suffixes into 2 groups, ones that are acronyms and could be separated by periods, and ones that are not. So I guess this means updating the suffixes set now has no effect. You'll need need to add your custom suffixes to CONSTANTS.suffix_acronyms in this case, or CONSTANTS.suffix_not_acronyms.
Activity
derek73 commentedon Feb 25, 2016
Hmm, it looks like a bug. Thanks for reporting it. I'll look into it.
One probably minor thing, the MSc would go into the
suffixproperty because it comes at the end of the name. In a future version I'm going to change those attribute names toprenominalandpostnominalso people don't expect it to be semantic. It's based solely on position in the string.derek73 commentedon Feb 25, 2016
Ahh, I see now. It's because "MSc" is not in a recognized suffix, so it assumes it's the "lastname, firstname" format. If you add "MSc" to your suffixes set it should work as expected.
I'll go ahead and add that to the suffix/post-nominal constants in the next release.
lawli3t commentedon Feb 26, 2016
Ah I see thanks, that fixes that problem.
Another one i have though is that if i add MSc to both suffixes and titles it doesnt work. It works fine for MSc in one of those two though. The data i have is very messy sadly so some rows have the MSc as a prefix others as a suffix. Is there any possibility of incorporating those two?
Otherwise i'd have to get a bit dirty with multiple instances i guess.
Thanks for your fast and thorough response though, appreciate it!
edit:
hm, doesnt seem the suffix is working sometimes, for instance i have added msc to titles as well as suffixes and get the following results:
I would expect MSc to be in the suffix too, even if i omit the first MSc it doesnt get parsed even though it is in the suffix set.
derek73 commentedon Feb 27, 2016
Ok, I think I figured out what's going on. I recently separated suffixes into 2 groups, ones that are acronyms and could be separated by periods, and ones that are not. So I guess this means updating the
suffixesset now has no effect. You'll need need to add your custom suffixes toCONSTANTS.suffix_acronymsin this case, orCONSTANTS.suffix_not_acronyms.improve string format handling of nickname punctuation #41
#41 add configurable default for string formatting