Difference between revisions of "Morphological generator"

From LING073
Jump to: navigation, search
(→‎Some useful symbols)
Line 1: Line 1:
−
== Some useful symbols ==
+
== 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") <code>%{x%}</code> to form-level (or "phonetic") <code>x</code> when it's before form-level <code>y</code> 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 <code>:</code> to separate lexc level from form level.  An underscore (<code>_</code>) is used to show the exact position among these symbols where the change should take place.
 +
 
 +
=== Some useful symbols ===
  
 
The basic stuff:
 
The basic stuff:

Revision as of 06:28, 16 February 2017

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

Examples of rules

Remove a symbol

"

Choose an output for a symbol