/* OTGrammar_ex_NPA.c */
/* Paul Boersma, August 19, 2001 */

#include "OTGrammar.h"

OTGrammar OTGrammar_create_NPA_grammar (void) {
	OTGrammarCandidate candidate;
	OTGrammarTableau tableau;
	OTGrammarConstraint constraint;
	OTGrammar me = new (OTGrammar); cherror
	my constraints = NUMstructvector (OTGrammarConstraint, 1, my numberOfConstraints = 3); cherror
	constraint = & my constraints [1];
		constraint -> name = Melder_strdup ("*G\\s{ESTURE}"); cherror
		constraint -> ranking = 102.7;
	constraint = & my constraints [2];
		constraint -> name = Melder_strdup ("*R\\s{EPLACE} (n, m)"); cherror
		constraint -> ranking = 100.0;
	constraint = & my constraints [3];
		constraint -> name = Melder_strdup ("*R\\s{EPLACE} (t, p)"); cherror
		constraint -> ranking = 112.0;
	my tableaus = NUMstructvector (OTGrammarTableau, 1, my numberOfTableaus = 2); cherror
	tableau = & my tableaus [1];
		tableau -> input = Melder_strdup ("an+pa"); cherror
		tableau -> candidates = NUMstructvector (OTGrammarCandidate, 1, tableau -> numberOfCandidates = 2); cherror
		candidate = & tableau -> candidates [1];
			candidate -> output = Melder_strdup ("anpa");
			candidate -> marks = NUMivector (1, candidate -> numberOfConstraints = 3); cherror
			candidate -> marks [1] = 1;
		candidate = & tableau -> candidates [2];
			candidate -> output = Melder_strdup ("ampa");
			candidate -> marks = NUMivector (1, candidate -> numberOfConstraints = 3); cherror
			candidate -> marks [2] = 1;
	tableau = & my tableaus [2];
		tableau -> input = Melder_strdup ("at+ma"); cherror
		tableau -> candidates = NUMstructvector (OTGrammarCandidate, 1, tableau -> numberOfCandidates = 2); cherror
		candidate = & tableau -> candidates [1];
			candidate -> output = Melder_strdup ("atma");
			candidate -> marks = NUMivector (1, candidate -> numberOfConstraints = 3); cherror
			candidate -> marks [1] = 1;
		candidate = & tableau -> candidates [2];
			candidate -> output = Melder_strdup ("apma");
			candidate -> marks = NUMivector (1, candidate -> numberOfConstraints = 3); cherror
			candidate -> marks [3] = 1;
	OTGrammar_checkIndex (me);
	OTGrammar_newDisharmonies (me, 0.0);
end:	iferror forget (me);
	return me;
}

PairDistribution OTGrammar_create_NPA_distribution (void) {
	PairDistribution me = PairDistribution_create ();
	PairDistribution_add (me, "at+ma", "atma", 100);
	PairDistribution_add (me, "at+ma", "apma",   0);
	PairDistribution_add (me, "an+pa", "anpa",  20);
	PairDistribution_add (me, "an+pa", "ampa",  80);
	return me;
}

/* End of file OTGrammar_ex_NPA.c */
