Morphological generator

From LING073
Revision as of 05:24, 16 February 2017 by Jwashin1 (talk | contribs) (→‎Some useful symbols)

Jump to: navigation, search

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

Examples of rules

Remove a symbol

"

Choose an output for a symbol