Difference between revisions of "Курсы машинного перевода для языков России/Session 3"

From Apertium
Jump to navigation Jump to search
Line 25: Line 25:
   
 
* ''Примером может быть конденсация '''воды'''.''{{slc|ru}}
 
* ''Примером может быть конденсация '''воды'''.''{{slc|ru}}
* ''Příkladem může být kondenzace '''vody'''.''{{slc|cs}}
 
 
* ''Príkladom môže byť kondenzácia '''vody'''.''{{slc|sk}}
 
* ''Príkladom môže byť kondenzácia '''vody'''.''{{slc|sk}}
 
* ''Przykładem może być kondensacja '''wody'''.''{{slc|pl}}
 
* ''Przykładem może być kondensacja '''wody'''.''{{slc|pl}}

Revision as of 15:41, 24 December 2011

The aim of this session is to give an overview of the issue of morphological ambiguity, and describe how it is treated in Constraint Grammar. We will give some theory regarding different types of morphological ambiguity, and an overview of how they are dealt with using rules. The practice section will involve discovering tagging errors and trying to solve the errors with rules.

Theory

The ambiguity that we are going to cover in this session is morphological ambiguity. This is the ambiguity that comes from a surface form having more than one possible morphological analysis (also referred to as homonymy — samenameness). For example, the Chuvash word чалка can be,

  • The noun "чалка" in the singular number and nominative case.
  • The adjective "чалка".
  • The verb "чалка" in imperative, 2nd person, singular.

The translational ambiguity that чалка as a verbs can be translated to Russian as кричать, стрекотать, верещать, галдеть etc. does not come into morphological ambiguity, and thus is not treated in this session.

Morphological ambiguity

There are two principle types of morphological ambiguity. The morphological ambiguity between parts of speech (for example a word that could be either noun or verb) and the morphological ambiguity within parts of speech (for example that a word form can only be a noun, but may be nominative or genitive). Typically the more complex morphology a language has, the higher the ratio of within part-of-speech ambiguity to between part-of-speech ambiguity.

Between parts-of-speech

An example of ambiguity between parts-of-speech is given above, the word чалка can be a noun, a verb or an adjective. Consider also the frequent ambiguity between adjectives denoting ethnic groups (e.g. in Russian русский) or professions (e.g. in Russian военный) and the nouns denoting the languages or people (русский) or professions (военный).

Within parts-of-speech

For examples of ambiguity within parts-of-speech we can look at the Slavic languages, where there is a frequent syncretism between nominative, accusative and genitive.

  • Примером может быть конденсация воды.(ru)
  • Príkladom môže byť kondenzácia vody.(sk)
  • Przykładem może być kondensacja wody.(pl)
  • Primer je lahko kondenzacija vode.(sl)

This is not however exclusive to Slavic languages, Turkic and Finno-Ugric languages also exhibit limited within part-of-speech ambiguity, consider the Chuvash итлĕр (ambiguous future and imperative), and Finnish xxx (ambiguous zzz, yyy).

Syntactic ambiguity

Another form of ambiguity is syntactic ambiguity, that is where a sentence or phrase has more than one possible interpretation that cannot be resolved morphologically. An example might be prepositional phrase attachment, where it is not necessarily clear from the morphology to which constituent the prepositional phrase attaches. Consider the following example

  • Сегодня я говорил с подругой Анны, с которой я познакомился вчера. (met Anna yesterday)
  • Сегодня я говорил с подругой Анны, с которой я познакомился вчера. (met the friend of Anna yesterday)

A problem arises for machine translation when a sentence or phrase is ambiguous in the source language, but not in the target language. If the ambiguity is preserved there is less problem.

For example for the above sentence, the ambiguity is retained in the majority of western-European languages (e.g. Indo-European), but for XXX the two different readings require different translations:

  • xxx
  • yyy

Rule-based disambiguation

There are many ways of writing disambiguation rules, but the most important thing is to be able to express the rule in terms of the context that provides disambiguation. For example, while individual words can be very ambiguous, often they are disambiguated by context. Take the Russian phrase « нашим старым преподавателям », while both нашим and старым are quite ambiguous (three analyses for both), the head of the phrase преподавателям, which only has one analysis, disambiguates them.

  • наш<det><pos><m><sg><ins> старый<adj><m><sg><ins> преподаватель<n><m><aa><pl><dat>
  • наш<det><pos><nt><sg><ins> старый<adj><m><sg><ins> преподаватель<n><m><aa><pl><dat>
  • наш<det><pos><mfn><pl><dat> старый<adj><m><sg><ins> преподаватель<n><m><aa><pl><dat>
  • наш<det><pos><m><sg><ins> старый<adj><mfn><pl><dat> преподаватель<n><m><aa><pl><dat>
  • наш<det><pos><nt><sg><ins> старый<adj><mfn><pl><dat> преподаватель<n><m><aa><pl><dat>
  • наш<det><pos><mfn><pl><dat> старый<adj><mfn><pl><dat> преподаватель<n><m><aa><pl><dat>
  • ...

We could thus conceive of writing a rule which removes the analyses that do not agree with the head of the phrase.

Constraint grammar

One way of writing rules is with a formalism called constraint grammar. Constraint grammar rules consist of two parts, an operation on a pattern and a context. For example:

  • select: Given a context, remove all the readings apart from the one(s) matched by the pattern.
  • remove: Given a context, remove the reading(s) that match the pattern.

A context can be any combination of words or tags in a given sentence. To get an idea of the kind of contexts that can be used, let's look at some real disambiguation rules. We're going to use the Russian phrase:

« Услугами детских садов пользуются 135 тысяч работающих матерей. »
Ambiguity #1

The word детских is ambiguous between genitive, prepositional and accusative. We want to select the genitive reading.

  • SELECT Gen IF (0C A) (*1C GEN BARRIER NPNHA);
    • SELECT Gen: Select genitive, IF
    • (0C A): The current word only has adjective readings.
    • (*1C GEN BARRIER NPNHA): After the current word there is a word which is only in the genitive case. Keep searching the words after the current word until a word which is any word except a word which can modify a noun, or an adverb.
Ambiguity #2

The word работающих is ambiguous between genitive plural, prepositional plural, accusative plural. We want to select the genitive plural reading.

  • SELECT Gen IF (0C ACC-GEN-PRP) (*-1C Num LINK 1C Gen BARRIER NOTGEN);
    • SELECT Gen: Select genitive, IF
      • (0C ACC-GEN-PRP): The current word can only be accusative, genitive or locative
      • (*-1C Num LINK 1C Gen BARRIER NOTGEN): Before the current word there is a word which can only be a numeral followed by a word which can only be genitive, keep searching towards the beginning of the sentence until there is a word that does not contain the genitive tag.
Ambiguity #3

The word матери is ambiguous between genitive plural and accusative plural. We want to select the genitive plural reading (or better, remove the accusative).

  • REMOVE Acc IF (0C ACC-OR-GEN) (*-1C Num LINK 1C Gen BARRIER NOTGEN);
    • REMOVE Acc: Remove accusative, IF
      • (0C ACC-OR-GEN): The current word can only be accusative or genitive
      • (*-1C Num LINK 1C Gen BARRIER NOTGEN): There is a previous numeral which has a word which can only be genitive after it (e.g. тысяч) and we stop searching when we find a word that is not in genitive (BARRIER NOTGEN)

Practice

In this practice session, we are going to run the tagger, discover some tagging errors and finally propose some disambiguation rules for solving these tagging errors.

Running the morphological analyser

Let's try running the morphological analyser on what seems like a fairly simple phrase:

echo "Уран — седьмая по удалённости от Солнца." | lt-proc ru-kv.automorf.bin
^Уран/Уран<np><top><m><sg><acc>/Уран<np><top><m><sg><nom>$ 
^—/—<guio>$ ^седьмая/седьмой<det><ord><f><sg><nom>$ 
^по/по<pr>$ 
^удалённости/удалённость<n><f><nn><sg><gen>/удалённость<n><f><nn><sg><dat>/удалённость<n><f><nn><sg><prp>/удалённость<n><f><nn><pl><acc>/удалённость<n><f><nn><pl><nom>$ 
^от/от<pr>$ 
^Солнца/Солнце<n><nt><nn><sg><gen>/Солнце<n><nt><nn><pl><acc>/Солнце<n><nt><nn><pl><nom>$
^./.<sent>$

What seemed like a fairly simple phrase is not, there are multiple ambiguities.

Finding errors

Apertium comes with a statistical tagger, which can be run as follows:

$ echo "Уран — седьмая по удалённости от Солнца." | lt-proc ru-kv.automorf.bin | apertium-tagger -p -g kv-ru.prob 
^Уран/Уран<np><top><m><sg><acc>$ 
^—/—<guio>$ 
^седьмая/седьмой<det><ord><f><sg><nom>$ 
^по/по<pr>$ ^удалённости/удалённость<n><f><nn><sg><gen>$ 
^от/от<pr>$ ^Солнца/Солнце<n><nt><nn><sg><gen>$^./.<sent>$

It is fairly easy to find the errors in the tagging, there are two:

  • "Уран" should be nominative, not accusative.
  • After the preposition "по", the case of "удалённость" should be dative, not genitive.

The rest of the words have been disambiguated correctly.

Conceiving rules

When thinking about rules, it is important to take into account the following:

  • The scope of application of the rule. Should it work just on the current word, the current word and one or two words context either side, at the level of the clause, or on the whole sentence ?
  • Should the rule only apply to one lemma, or should it apply to any word that has the same part of speech ?
  • The kind of ambiguity we want the rule to work on, for example, should it work on any ambiguity between nominative and accusative, or only ambiguities in case involving nouns ?
  • There are often several rules which could equally well disambiguate a sentence, it is important not to get caught up in finding the "perfect" one.

In the above example, we could consider the following rules:

  • If a word can only be nominative or accusative and the following word is the hyphen (—) with an adjective that can only be in nominative following, then select the nominative reading.
  • After the preposition "по" remove any genitive readings.

For your chosen language pair, describe some rules that solve specific disambiguation problems you have found.

Constraint grammar

If you have finished with describing the rules, you can try coding them in constraint grammar, as in the Russian example above. Below is a skeleton constraint grammar file to encode the two rules from the previous example, and instructions on how to run it.

DELIMITERS = "<.>" "<!>" "<?>" ;
SOFT-DELIMITERS = "<,>" ;

LIST BOS = (>>>) ; # Beginning of sentence
LIST EOS = (<<<) ; # End of sentence

LIST Hyphen = guio ;
LIST Nom = nom ;
LIST Acc = acc ;
LIST Gen = gen ;

LIST Not-Gen-Prep = "по";

SET  Acc-Or-Nom = Acc | Nom ;

SECTION

# Rule 1
REMOVE Acc IF                          # Remove accusative reading if,
              (0C Acc-Or-Nom)          #   the current word is only accusative or nominative
              (1C Hyphen LINK 1 Nom);  #   there is a hyphen directly to the right, with a nominative following

# Rule 2
REMOVE Gen IF                          # Remove a genitive reading if,
              (-1C Not-Gen-Prep);      # it is preceeded by a preposition which does not ever govern the genitive

Copy this file into a text editor, and save it as rules.rlx. First we need to compile the rules:

$ cg-comp rules.rlx rules.bin

Sections: 1, Rules: 2, Sets: 17, Tags: 18

And now run them:

$ echo "Уран — седьмая по удалённости от Солнца." | lt-proc ru-kv.automorf.bin | cg-proc rules.bin 
^Уран/Уран<np><top><m><sg><nom>$ ^—/—<guio>$ ^седьмая/седьмой<det><ord><f><sg><nom>$ 
^по/по<pr>$ 
^удалённости/удалённость<n><f><nn><pl><nom>/удалённость<n><f><nn><sg><dat>/удалённость<n><f><nn><sg><prp>/удалённость<n><f><nn><pl><acc>$ 
^от/от<pr>$ ^Солнца/Солнце<n><nt><nn><sg><gen>/Солнце<n><nt><nn><pl><acc>/Солнце<n><nt><nn><pl><nom>$
^./.<sent>$

And in conjunction with the apertium-tagger:

$  echo "Уран — седьмая по удалённости от Солнца." | lt-proc ru-kv.automorf.bin | cg-proc rules.bin  |\
   apertium-tagger -g ru-kv.prob
^Уран<np><top><m><sg><nom>$ ^—<guio>$ ^седьмой<det><ord><f><sg><nom>$ ^по<pr>$ 
^удалённость<n><f><nn><pl><nom>$ ^от<pr>$ ^Солнце<n><nt><nn><sg><gen>$^.<sent>$

We can see that although we've removed the incorrect genitive, now we get an incorrect plural nominative reading. As "по" never governs the nominative, we can remove that too, using a similar rule to the second one.

Further reading

  • van Halteren, H. (1999) Syntactic wordclass tagging (Dordrecht: Kluwer)