Morphological generator

From LING073
Revision as of 06:46, 16 February 2017 by Jwashin1 (talk | contribs) (→‎Examples of rules)

Jump to: navigation, search

The basics

Twol rules are written to change the output of the lexc level of the transducer on a character-by-character basis. The basic structure of a twol rule is a mapping of lexc-level symbols to orthographic form-level symbols in a particular environment. A basic rule mapping lexc-level (or "morphophonological") %{x%} to form-level (or "phonetic") x when it's before form-level y would be the following:

%{x%}:x <=> _ :y ;

The mapping is lexc-level character, a colon, and form-level character, and the environment is a series of characters separated by spaces. These characters can consist of multiple symbols, and also use : to separate lexc level from form level. An underscore (_) is used to show the exact position among these symbols where the change should take place.

Some useful symbols

The basic stuff:

  • : separates the lexc side of the transducer (left) from the output side (right); e.g. %>:0
  • 0 on the left side means empty output
  • _ is the location in which the rule is applied
  • <=> separates what gets mapped from the environment, and can be read as "where"
  • ; represents the end of an environment

Some more advanced stuff:

  • \ means "not" the thing after it
  • () means that the thing inside it is optional
  • [] groups blocks of things
  • | means "or"
  • * after a symbol (e.g., x:y* or [ … ]* means 0 to infinite occurrences of that thing
  • / optionally interleaves the symbol after it into all possible positions in the set of symbols before it, e.g. [ :a :b :c ]/:x should be equivalent to [ (:x) :a (:x) :b (:x) :c (:x) ].

Some more tricks

You can use list multiple environments

x:y <=> _ :a ;
        b: _ ;

The rule above maps x to y before an output a and after an output b.

You can also exclude certain environments using the word except:

x:y <=> _ :a ;
    except
        b: _ ;

The rule above maps x to y before an output a unless it's after an output b.

You can do a whole bunch of pairs of symbols in the same environment using a single rule, like this:

Cx:Cy <=> :Cy _ ;
      where Cx in ( %{A%} %{A%} %{A%} )
            Cy in (   a     e     o   ) ;
      matched ;

This rule turns %{A%} into either a, e, or o to match the character before it.

Useful commands

See what lexc outputs

echo "life<n><pl>" | hfst-lookup .deps/eng.LR.lexc.hfst 

There should be a line like this:

> life<n><pl>	li{f}e>{e}s	0.000000

This shows that lexc part of the transducer maps house<n><> to house>{e}s.

Check what's being generated by the full transducer

echo "^life<n><pl>$" | apertium -d . -f none eng-gener

will output something like

lifes/lifees/lives/livees

The assignment

Initial evaluation

  1. If you're still working on your analyser, finish that first.
  2. Make a subsection on your Transducer wiki page to note the number of passing and failing morphological analysis tests at this point using the morphology test method used for your analyser assignment.
  3. Run a morph test again on the same file, but this time with the -l option (morphological generation tests) instead of with -s (morphological analysis tests). You also don't need -i—the full command you'll probably want is morph-test -cl xyz.yaml | most.) Put the number of passes and fails for the generation test in the same subsection on the wiki page.

The hard stuff

  1. Continue development of your transducer, focussing on twol rules, so two-thirds of your [minimum 50] tests pass.
    • Note that if every test passes analysis but has multiple forms generated, exactly one-half of your tests will pass—this is simply due to the way the tests are counted (i.e., each form will be counted as both passing and failing). In such a situation, each form which subsequently is made to have only a correct form generated will reduce the number of failing tests by one, but not increase the number of passing tests. Hence, if all your tests analyse correctly, then you only need to write twol rules to make half of them generate correctly.