Difference between revisions of "Lexical selection"

From LING073
Jump to: navigation, search
(The assignment)
Line 36: Line 36:
 
An <code>lrx</code> file is written in xml.  It consists of a list of rules surrounded by {{tag|rules}}<code>...</code>{{tag|/rules}}.  Each {{tag|rule}}<code>...</code>{{tag|rule}} block contains some combination of {{tag|match}}{{tag|select ... /}}{{tag|/match}} blocks and {{tag|match .../}} blocks.  {{tag|match ...}} tags can contain attributes like <code>lemma=""</code> and <code>tags=""</code>.  Multiple {{tag|match .../}} blocks may be included within {{tag|or}}<code>...</code>{{tag|/or}} so that multiple rules don't have to be written in cases of multiple matching criteria.
 
An <code>lrx</code> file is written in xml.  It consists of a list of rules surrounded by {{tag|rules}}<code>...</code>{{tag|/rules}}.  Each {{tag|rule}}<code>...</code>{{tag|rule}} block contains some combination of {{tag|match}}{{tag|select ... /}}{{tag|/match}} blocks and {{tag|match .../}} blocks.  {{tag|match ...}} tags can contain attributes like <code>lemma=""</code> and <code>tags=""</code>.  Multiple {{tag|match .../}} blocks may be included within {{tag|or}}<code>...</code>{{tag|/or}} so that multiple rules don't have to be written in cases of multiple matching criteria.
  
Besides the additional documentation linked to above, countless examples can be found in the [https://github.com/apertium/ Apertium codebase], and some examples from class will also [https://github.swarthmore.edu/Ling073-sp18 be posted].
+
Besides the additional documentation linked to above, countless examples can be found in the [https://github.com/apertium/ Apertium codebase], and some examples from class will also [https://github.swarthmore.edu/Ling073-sp21/ling073-kir-eng be posted].
  
 
Here is an example to try in class:
 
Here is an example to try in class:

Revision as of 15:24, 13 April 2021

Lexical selection

Lexical selection provides a way to deal with what you do when a single word in one language translates to more than one word in another language. The formalism used in Apertium allows you to choose translations based on the lemma and/or part of speech of surrounding words. In the Apertium pipeline, it modifies the stream after lexical transfer and before structural transfer.

Writing rules

Lexical selection rules are in the apertium-xyz-abc.xyz-abc.lrx file in your language pair. You can find information about and examples of the formalism on the Apertium wiki: constraint-based lexical selection module, how to get started with lexical selection rules.

In short, you use the surrounding words (with morphological analyses) as context to decide which translation is the correct one.

Linguistic examples

An example that might need lexical selection is the following:

  • yard (a unit of length)
  • yard (an enclosed area)

What's different about these words? Spelling, pronunciation, part of speech? What [different] contexts might each occur in?

Can we decide which translation is right from the surrounding words?

  • (kir) кол → (eng) hand; arm
  • (kir) күн → (eng) sun; day
  • (kir) жаш → (eng) age; tear (eye water)
  • (kir) бир → (eng) one; a/an
  • (eng) paper → (kir) кагаз (material); доклад (written work)
  • (eng) horse → (kir) ат (for riding, working); жылкы (for herding, eating)
  • (eng) sister → (kir) сиңди (younger, of female); карындаш (younger, of male); эже (older)

What do we do with examples like this?

  • (eng) tear → (kir) жаш (eye water); айыр (rip)
  • (eng) plant → (kir) өсүмдүк (growing thing); отургуз (put in the ground to grow)
  • (kir) өч → (eng) revenge; be extinguished
  • (kir) кыл → (eng) strand of hair; string (of instrument); do; make

The structure of lrx files

An lrx file is written in xml. It consists of a list of rules surrounded by <rules>...</rules>. Each <rule>...<rule> block contains some combination of <match><select ... /></match> blocks and <match .../> blocks. <match ...> tags can contain attributes like lemma="" and tags="". Multiple <match .../> blocks may be included within <or>...</or> so that multiple rules don't have to be written in cases of multiple matching criteria.

Besides the additional documentation linked to above, countless examples can be found in the Apertium codebase, and some examples from class will also be posted.

Here is an example to try in class:

  • Көзүнөн жаш акты.
  • Анын жашын билбейм.

Additional guidelines

You may wish to make a "default" translation and then some more specific rules. Because of how lrx-proc works, the less specific rule (the "default") may override any more specific rules.

Currently, the best way to get the less specific rule to be the default seems to be with weights—i.e., give a lower weight to the rule you wish to be default than to the specific ones (e.g., by just giving a weight below 1 to the default rule).

The assignment

Due on Friday of the 10th week of class (this semester, Friday, April 16th, 2021, by the end of the day (midnight))

  1. Make a new page on the wiki, Language1_and_Language2/Lexical_selection, linking to it from the main page for your language pair, and adding it to the category Category:Sp21_LexicalSelection and the categories for the two languages.
  2. Add a sections xyz → abc.
  3. Find and document at least two cases of a one-to-many mapping for translation.
  4. For each ambiguous translation you work on, determine some generalisation for how to decide which translation is right, documenting these generalisations on the wiki.
    • It may be that there is no obvious generalisation that can be made for a given lexical selection problem; in this case, choose a default form to select and find some other one-to-many translation that can be solved with lexical selection. You must have at least one [mostly] solvable problem.
  5. For each translation of the word, add an example sentence (or phrase if necessary—but check with me) where the meaning is unambiguous (minimum: two sentences).
  6. In the appropriate lrx file (for the xyz-abc direction), set up any necessary default translations, and at least one set of lexical selection rules for one solvable lexical selection problem. Add the example sentences/phrases in a comment before the relevant rule.
  7. Compile and test that the sentences are translated with the correct stem.
  8. Commit and push your code!