(due to Lauri Karttunen, Bonnie Webber, Mark Steedman)
Using the xfst tool, create a transducer for translating from English (or any other language) into Pig Latin.There may be different varieties of Pig Latin. Let's pick the simplest one, defined by the rule
If the word begins with a consonant, the
corresponding Pig Latin word
is the same except that the initial consonant
has been moved to the end
of the word and suffixed with "ay".
For example, the sentence "pig latin is fun" corresponds to "igpay atinlay is unfay" in Pig Latin.
Your task is to write an xfst script, to be run with the command,
xfst -l FileName |
that leaves on the stack a transducer with the following properties:
xfst -l piglatin.scr | Execute piglatin.scr and wait for commands. |
xfst[1]: apply down | Start applying the transducer downwards. |
apply down> pig igpay apply down> pig latin igpay atinlay apply down> the little brown fox jumped over the lazy dog hetay ittlelay rownbay oxfay umpedjay over hetay azylay ogday |
define Cons [ b ] ; define Vowel [a | e | i | o | u ] ; define Ltr [ Cons | Vowel ]+ ; define Limit [" " | "\t" | .#. ] ; |
Because you cannot literally "move" the initial consonant from the beginning to the end of the word, you need to think of movement in terms of two more primitive operations:
One more important hint:
[ ] -> a || b _ c ; | Maps the string "bc" to the infinite language [ b a* c ]. |
[. .] -> a || b _ c ; | Maps the string "bc" to the string "bac". |
Work with simple replacement and composition. Don't try using parallel replacement.
With just one consonant, your Pig Latin translator should have around 8 states and 44 arcs. With the full set of 21 consonants, the size of the transducer is about 48 states, 1220 arcs.