Natural language grammar and user-entered names

Posted by Owen Blacker on Stack Overflow See other posts from Stack Overflow or by Owen Blacker
Published on 2010-05-19T17:27:34Z Indexed on 2010/05/19 17:30 UTC
Read the original article Hit count: 383

Some languages, particularly Slavic languages, change the endings of people's names according to the grammatical context. (For those of you who know grammar or studied languages that do this to words, such as German or Russian, and to help with search keywords, I'm talking about noun declension.)

This is probably easiest with a set of examples (in Polish, to save the whole different-alphabet problem):

  1. Dorothy saw the cat — Dorota zobaczyla kota
  2. The cat saw Dorothy — Kot zobaczyl Dorote
  3. It is Dorothy’s cat — To jest kot Doroty
  4. I gave the cat to Dorothy — Dalam kota Dorotie
  5. I went for a walk with Dorothy — Poszlam na spacer z Dorota
  6. “Hello, Dorothy!” — “Witam, Doroto!”

Now, if, in these examples, the name here were to be user-entered, that introduces a world of grammar nightmares. Importantly, if I went for Katie (Kasia), the examples are not directly comparable — 3 and 4 are both Kasi, rather than *Kasy and *Kasie — and male names will be wholly different again.

I'm guessing someone has dealt with this situation before, but my Google-fu appears to be weak today. I can find a lot of links about natural-language processing, but I don'think that's quite what I want. To be clear: I'm only ever gonna have one user-entered name per user and I'm gonna need to decline them into known configurations — I'll have a localised text that will have placeholders something like {name nominative} and {name dative}, for the sake of argument. I really don't want to have to do lexical analysis of text to work stuff out, I'll only ever need to decline that one user-entered name.

Anyone have any recommendations on how to do this, or do I need to start calling round localisation agencies ;o)


Further reading (all on Wikipedia) for the interested:

Disclaimer: I know this happens in many other languages; highlighting Slavic languages is merely because I have a project that is going to be localised into some Slavic languages.

© Stack Overflow or respective owner

Related posts about natural-language

Related posts about i18n