string - Parse full name for UK users in c++ considering multiple scenarios -
i working third party api, receives forename, middlename, , surname parameters. have fullname of user. cannot change structure because part of large scale system cannot changed.
the structure of parameters of third party api cannot change, despite not best solution have parse fullname , split 3 fields.
the names uk, good. doing now:
vector<string> fields; mylibrary::split(' ', name, fields); string firstname = fields[0]; string middlename = fields.size() == 3 ? fields[1] : ""; string surname = fields.size() == 3 ? fields[2] : fields[1];
but pretty sure bad solution, since there multiple scenarios, example when name contains text mr. @ beginning, or jr. @ end.
is there code block can give me better guarantees code?
thanks!
[update]
the name requested in form user "account holder's name", , information related bank account information, user won't put nickname. added example of jr. or sr. 1 possible scenario found, there might other known problems names. insights properties of names in uk useful.
if have freeform input in full name, including things aren't name (like "mr." technically title separate one's name), there's no foolproof way convert first/middle/last split.
you can come system of heuristics catches common cases, , keep running data set through until passes. won't find silver bullet makes problem go away.
my advice make heuristics, them working 100% best can, , convert data in large scale system split format. whoever designed name 1 monolithic field made mistake. if that's not possible, let employers know continue cause problems down road , design error not yours.
Comments
Post a Comment