OT learning 2.3. Defining your own grammar

By editing a text file created from an example in the New menu, you can define your own OT grammars.

As explained at Save as text file..., Praat is quite resilient about its text file formats. As long as the strings and numbers appear in the correct order, you can redistribute the data across the lines, add all kinds of comments, or leave the comments out. For the NOCODA example, the text file could also have looked like:

`"ooTextFile"
` `"OTGrammar 2"
` `<OptimalityTheory>
` `0.0 ! leak
` `2 ! number of constraints
` `"N\s{O}C\s{ODA}" 100 100 1
` `"P\s{ARSE}" 90 90 1
` `0 ! number of fixed rankings
` `2 ! number of accepted inputs
` `"pat" 2 ! input form with number of output candidates
` `"pa" 0 1 ! first candidate with violations
` `"pat" 1 0 ! second candidate with violations
` `"pa" 1 ! input form with number of candidates
` `"pa" 0 0
`

To define your own grammar, you just provide a number of constraints and their rankings, and all the possible input forms with all their output candidates, and all the constraint violations for each candidate. The order in which you specify the constraints is free (you don't have to specify the highest-ranked first), as long as the violations are in the same order; you could also have reversed the order of the two input forms, as long as the corresponding candidates follow them; and, you could also have reversed the order of the candidates within the /pat/ tableau, as long as the violations follow the output forms. Thus, you could just as well have written:

`"ooTextFile"
` `"OTGrammar 2"
` `<OptimalityTheory> 0.0
` `2
` `"P\s{ARSE}" 90 90 1.0
` `"N\s{O}C\s{ODA}" 100 100 1.0
` `0
` `2
` `"pa" 1
` `"pa" 0 0
` `"pat" 2
` `"pat" 0 1
` `"pa" 1 0
`

The `<OptimalityTheory>` thing in the above refers to the decision strategy. In this tutorial I mostly assume OT’s strict ranking, but you can experiment with Smolensky’s `<HarmonicGrammar>` (where the constraint disharmonies represent addable, possibly negative weights), or with Frank Keller’s `<LinearOT>` (like Harmonic Grammar, but with the restriction that negative disharmonies do not count), or with `<PositiveHG>` (like Harmonic Grammar, but with the restriction that disharmonies below 1.0 have weight 1.0), or with `<ExponentialHG>` (where the weights are exp(disharmony), somewhere between Harmonic Grammar and Linear OT), or with a `<MaximumEntropy>` grammar (where the probability that a candidate is chosen is proportional to exp(-disharmony)).

The `leak` thing in the above refers to the amount to which constraint weights (especially in Harmonic Grammar) can leak while learning.

### Links to this page

- OT learning
- OT learning 2. The grammar