Difference between revisions of "Morphological generator"
From LING073
(Created page with "== Some useful symbols == The basic stuff: * <code>:</code> separates the lexc side of the transducer (left) from the output side (right); e.g. <code>%>:0</code> * <code>0...") |
(→Some useful symbols) |
||
| Line 14: | Line 14: | ||
* <code>|</code> means "or" | * <code>|</code> means "or" | ||
* <code>*</code> after a symbol (e.g., <code>x:y*</code> or <code>[ … ]*</code> means 0 to infinite occurrences of that thing | * <code>*</code> after a symbol (e.g., <code>x:y*</code> or <code>[ … ]*</code> means 0 to infinite occurrences of that thing | ||
| + | * <code>/</code> optionally interleaves the symbol after it into all possible positions in the set of symbols before it, e.g. <code>[ :a :b :c ]/:x</code> should be equivalent to <code>[ (:x) :a (:x) :b (:x) :c (:x) ]</code>. | ||
=== Some more tricks === | === Some more tricks === | ||
| Line 32: | Line 33: | ||
You can do a whole bunch of pairs of symbols in the same environment using a single rule, like this: | You can do a whole bunch of pairs of symbols in the same environment using a single rule, like this: | ||
| − | {{ | + | <pre> |
| − | + | Cx:Cy <=> :Cy _ ; | |
| + | where Cx in ( %{A%} %{A%} %{A%} ) | ||
| + | Cy in ( a e o ) ; | ||
| + | matched ; | ||
| + | </pre> | ||
| + | This rule turns <code>%{A%}</code> into either a, e, or o to match the character before it. | ||
== Useful commands == | == Useful commands == | ||
Revision as of 05:24, 16 February 2017
Contents
Some useful symbols
The basic stuff:
-
:separates the lexc side of the transducer (left) from the output side (right); e.g.%>:0 -
0on 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 ]/:xshould 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
"