A generator comprises a name and a list of generation rules. The example below shows the basic syntax for a generator.
generator long_vowel
{
{} => {"a", "e"}{"a", "e"};
{} => "ae";
// identical result to "ae" above
{} => <vowel +open +front -rounded><vowel +close_mid +front -rounded>;
}
In the above generations rules "{}" on the left hand side of the rule (i.e. before the "=>") indicates the empty set. That is: we are generating text. This is the only construct allowed on the left hand side of a generation rule. In rewrite and sound change rules, other constructs are allowed (see below). The "=>" operator means, roughly, "is rewritten as".
Often, variable patterns are required.
generator a_syllable
{
{} => <consonant>? <vowel> <vowel>? <consonant >;
}
The generator above will produce sequences of (C)V(V)C, where the bracketed letters are optional. This is indicated by the"?" repeat specifier (zero or one). This is the only repeat specifier allowed in a generator, but in sound change rules, repeat specifiers "*" (zero or more) and "+" (one or more) are allowed..
Generators may be chained to construct more complex entities. For example, the generator two_syllables below takes the output of three generators (long_vowel, final syllable and initial syllable) and constructs feature structures with two syllables. The output of this generator is then used to construct words.
generator two_syllables
{
{} => <syllable <spelling long_vowel> <stress primary>>
<syllable <spelling final_syllable>>;
{} => <syllable <spelling initial_syllable> <stress primary>>
<syllable <spelling final_syllable>>;
}
generator make_a_word
{
{} => <word <stem two_syllables> <person first>>;
}
Blah blah
generator long_vowel
{
{} => $1:<vowel +close> $1;
{} => <vowel $1> <vowel $1:+close>;
}
Blah blah
Blah blah
sound change Lower_Schwa
{
// PIE schwa becomes /a/ (Prokosch 38)
$1:<V -front -back -high> => <$1 -front +low +back>;
}
Blah
sound change Lower_Long_e
{
// PIE e: becomes ae: (Prokosch 37), whence NW a:, E e:
// but not in diphthong e:is (Prokosch 39)
$1:<V +front +mid +long> not before <-obstr -punct> => <$1 -mid +low>;
}
Blah
Blah blah
rewrite <s <agreement $agree>>
{
<noun_phrase $np> => <noun_phrase $agree $np>;
<verb_phrase $vp> => <verb_phrase $agree $vp>;
}
Blah blah
Generating the affixes for inflections is straightforward:
enum number {singular, dual, paucal, plural};
rewrite <number>
{
singular => null; // Same effect as omitting the line
dual => "ne-";
paucal => "-etken";
plural => "-oni";
}
The rewrite rule matches any feature with number as its head. Each rule within the rewrite matches a given enumeration of number, and substitutes the appropriate text. But this says nothing about where they are to be applied and how to handle any sound changes these affixes might induce. To handle ordering, you might write:
rewrite <noun <class noun_15>>
{
<number dual> => dual;
<stem $stem> => $stem;
<case $1> => $1;
<number $2> => $2;
<gender $3> => $3;
}
This rewrite rule matches any noun with a category subfeature of noun_15. Because rewrite rules are applied in strict order, the dual nouns are handled by the first rule, but other numbers fall through to the third rule. This notation certainly works and allows almost any type of affix to be generated. The order of the affixes is governed by the order of the individual rules. The example above applies affixes in the order: a "dual" prefix, the stem, then postfixed for case, other numbers and finally gender.
The examples above could easily generated either inflected forms or isolated words. This is simply a case of indicating word boundaries:
rewrite <noun <class noun_15>>
{
<number dual> => ^ dual;
<stem $stem> => $stem;
<case $1> => $1;
<number $2> => $2;
<gender $3> => $3 $;
}
The "^" symbol indicates the start of a word, and the "$" symbol the end of a word. These may be inserted at any point in the output of the rewrite.
Sometimes it is necessary to manipulate values. The following examples give a rough idea of the syntax (which is not final yet):
int:($number + 4)
int:(($number % 5) * 4)
Blah
The following syntax is used to include predefined libraries:
using Finnish.Morphology;
Blah
Below is an example that actually works and correctly generates some simple noun phrases, with dual nouns marked with a prefix and plurals with a suffix:
// Rewrite for a simple noun phrase with noun / determiner agreement
rewrite <noun_phrase <agreement $1>>
{
<determiner $2> => <determiner $1 $2> $;
<noun $2> => <noun $1 $2>;
}
rewrite <noun>
{
<number $1:{dual}> => <number $1>;
<stem $1:{"dog", "fish"}> => $1;
<gender $1> => <gender $1>;
<case $1> => <case $1>;
<number $1> => <number $1>;
}
rewrite <determiner>
{
<gender $1> => <gender $1>;
<stem $1> => $1;
<number $1> => <det_number $1>;
}
rewrite <number>
{
dual => "ne";
paucal => "etken";
plural => "oni";
singular => null;
}
rewrite <gender>
{
female => "ef";
}
rewrite <det_number>
{
dual => "a";
plural => "n";
singular => null;
}
Things to note: