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
Nickname surrounded by single quotes gets taken as the middle name. #74
I think the only reason I didn't include single quotes is because I wasn't sure how to write the regex so that the second match only matches the same character that it found in the first match. Also there's some weird edge case names like "ab'ad al am'an" that I wasn't sure how to weed out. My regex chops are not very strong. If you come up with a better regex, I'd be happy to put it in the library.
Thanks @boxabirds for the tip. That put me on the right track. Once I dug into it I realized that the 3 different ways to indicate a nickname had slightly different rules around them. Single quotes cannot contains white space, but double quotes and parenthesis can. Double quote matches the same character twice but parenthesis does not. So I ended up splitting them up into 3 different regexes and not needing to use groups in that way after all. I appreciate the prodding though because that's the way it should work and now it will be fixed in v1.0.
Activity
derek73 commentedon Jun 1, 2018
Currently the parser recognizes nicknames that are surrounded in parenthesis or double quotes. This is controlled by a regex, defined here:
python-nameparser/nameparser/config/regexes.py
Line 26 in fb1475a
And the parse_nicknames() method runs it:
python-nameparser/nameparser/parser.py
Lines 385 to 395 in fb1475a
You could update the regex to look for single quotes by replace that regex, something like:
CONSTANTS.regexes.nickname = re.compile(r'\s*?[\(\'"](.+?)[\'"]', re.U))I think the only reason I didn't include single quotes is because I wasn't sure how to write the regex so that the second match only matches the same character that it found in the first match. Also there's some weird edge case names like "ab'ad al am'an" that I wasn't sure how to weed out. My regex chops are not very strong. If you come up with a better regex, I'd be happy to put it in the library.
boxabirds commentedon Aug 29, 2018
What about using groups? https://gist.github.com/bpeterso2000/11277541
v1.0, fix support for nicknames in single quotes (#74)
derek73 commentedon Aug 30, 2018
Thanks @boxabirds for the tip. That put me on the right track. Once I dug into it I realized that the 3 different ways to indicate a nickname had slightly different rules around them. Single quotes cannot contains white space, but double quotes and parenthesis can. Double quote matches the same character twice but parenthesis does not. So I ended up splitting them up into 3 different regexes and not needing to use groups in that way after all. I appreciate the prodding though because that's the way it should work and now it will be fixed in v1.0.