berkmancenter / namae

Namae (名前) parses personal names and splits them into their component parts.
159 stars 32 forks source link

Can't parse name with uppercase symbols. #18

Closed helper2424 closed 6 years ago

helper2424 commented 7 years ago

Example Namae.parse 'Benedict XVI, Pope' => []

If use capital case it's work: Namae.parse 'Benedict Xvi, Pope' => [#<Name family="Benedict Xvi" given="Pope">]

inukshuk commented 7 years ago

But 'Pope' is not a given name, is it? So I would seriously question that 'Benedict XVI, Pope' is a valid input. I think an appropriate parsing would be either literal: 'Pope Benedict XVI' or something like given: 'Benedict', title: 'Pope', suffix: 'XVI'.

Namae.parse 'Pope Benedict XVI'
=> [#<Name family="Benedict" given="Pope" suffix="XVI">]

You could adjust the lexer patterns in Namae::Parser.instance.options to accept 'Pope' as a title (but that's dangerous because 'Pope' is also a valid name).

helper2424 commented 7 years ago

Yep, you right. Pope is not a given. It's title. https://en.wikipedia.org/wiki/Pope_Benedict_XVI . Origin string I get from third-party API, so need some non empty result.