views:

124

answers:

3

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 zobaczyła kota
  2. The cat saw Dorothy — Kot zobaczył Dorotę
  3. It is Dorothy’s cat — To jest kot Doroty
  4. I gave the cat to Dorothy — Dałam kota Dorotie
  5. I went for a walk with Dorothy — Poszłam na spacer z Dorotą
  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.

A: 

in German the only thing that is modified is article: Der, Die, Das. And names don't have them. So nothing fancy about German. (btw it is not Slavic)

about russian (my native). this whole concept of changing ending is painful for processing, but (!) if you have only person's names and you have hints like {name nominative} it is relatively easy. Majority of female names have common structure: root + a/ya (а/я), and each hint will give you definite rool how to change the ending. I see that in Polish it is same: Dorot|a, Dorot|ę. Male names are also simple. They either follow exactly same rules (if end with a/ya (а/я)) or if they end with j/y (like my name Andrey) the mapping is slightly different.

Andrey
Thanks, Andrey. So do you think it would actually be easier to build a relatively simple grammar engine that analyses names and works out the declensions?I can see that it wouldn't be *very* difficult to build a look-up table for name-endings, but I'm worried about the difference between Kasia (Kasię, Kasi, Kasi, Kasią) and Dorota (Dorotę, Doroty, Dorotie, Dorotą), where I can't predict the genitive (генитив) and dative (датив) simply from them being female names ending in -a.
Owen Blacker
@Owen Blacker http://en.wikipedia.org/wiki/Russian_grammar#First_declension_-_masculine_nounsfollowing tables give you nice reference. sorry, but i feel that i don't understand your ultimate goal and what is given for your task.
Andrey
@Andrey: So is it reliable that all male names will be in the consonant/а/у/а/ом/е pattern (so you are Андреий Андреия Андреию Андреия Андреием Андреии) and female names will all be in the а/ы/е/у/ой/е pattern unless they end in ь ?So Артур Артура Артуру Артура Артуром Артуре. But they what about Илья? Я isn't one of the characters mentioned in the first declension. Also Екатерина becomes Екатерины Екатерине Екатерину Екатериной Екатерине and Любовь would decline to Любовьи Любовьи Любовь Любовью Любовьи. What if a girl is called Нелли, which declension do I use then?Still confused… :oS
Owen Blacker
The context is a user entering a child's name and that name being substituted into a children's story. In that story, I know I'm going to need at least nominative (именительный падеж), accusative (винительный падеж), dative (дательный падеж) and vocative (звательный падеж) and that should be all.So a look-up table of nom to acc, dat and voc should suffice, but I'd need that for every possible name entered. To complicate further, I assume that some ppl in Russia have non-Russian names (from other ex-Soviet nationalities?). I assume someone named Рycлан will still follow the same patterns?
Owen Blacker
@Owen Blacker. I understood you, your task is relatively easy. You need to implement two things: recognition of declension, and modification of ending. Both seem to be trivial. Male names are either 1 or 2 declension. 99% of female names are 1. There are 2 or 3 exceptions, including mentioned "Любовь", it is 3rd declension but still, it follows the rules. So algo is this: if last letter is а/я, then 1st. If ь then 3rd. Otherwise 2nd (й or consonant). Андрей ends with й, so it is ending. Then it goes: Андрея, Андрею and so on.
Andrey
Руслан is simple. н is consonant, so there is no ending. Руслана, Руслану. Илья (а/я => 1st) Ильи, Илье. Нелли is not Russian name, but it doesn't fall into any declension, so it keeps itself.
Andrey
you should take into consideration that your problems do not end with names. Adjective that comes with name must correspond to gender (something that english doesn't have at all) and it ALSO has declension. Example: kind Andrey. Добрый Андрей, доброго Андрея, доброму Андрею. Добрая Екатерина, доброй Екатерины, доброй Екатерины. You see? It is not hard, you just need dictionary to check gender of the name and have variants of endings for adjective.
Andrey
now final chapter of my tale. Verbs. They reflect gender only in case of past tense. Andrey went: Андрей пошел, Екатерина пошла. Again, rules are simple, but you should respect them.Summary: Russian language is hard to automate, but in case of our task rules are simple, but there are lots of them.
Andrey
Ok, thank you Andrey, that helps a lot. Now I just need to find a decent reference, which shouldn't be too difficult, I guess, as now I just need a grammar text book and there are plenty of them online and off :o)
Owen Blacker
+1  A: 

Seems to me like you want a morphology-engine for polish. In very short they can do both analysis and generation from surface-form (what we read and write) to some abstract form, like "Dorothy + FEM + DAT", taking both declensions and phonology into account.

Take a look here (im not polish but it looks good, and most imporantly it has downloads :) ) http://nlp.ipipan.waw.pl/~wolinski/morfeusz/

Here are some introductory on the subject.

johanbev
I think I'm getting rather out of my depth here.I think you're right — I need a morphology engine of some kind (it's Russian I actually need, not Polish, which I only used for the examples, to avoid confusing people with Cyrillic in the example).But I don't need something as complicated as morphological analysis. I know the input text can be assumed to be a name (and we can ask the user for the gender, if necessary). I just need to be able to do something like: Kasia + FEM + GEN = Kasi but Dorota + FEM + GEN = Doroty. I think a full morphology engine might well be overkill here, perhaps?
Owen Blacker
A: 

I don't know the first thing about Slavic languages, so I can't point you to a plug-and-play tool. However, I can recommend the book Speech and Language Processing by Jurafsky and Martin, chapters 2 and 3. J&M discuss finite-state morphology (declension etc. by means of regular expressions).

This is an academic textbook, but it starts out with some simple string manipulation that can be done using just Perl, sed or similar. They then go deeply in finite-state transducers, regular languages/relations/algebra and other stuff you need for difficult languages such as Turkish. Your problem is probably somewhere in between, judging by the examples, and may be doable with just regexp match & replace.

larsmans