| 1 |
/* OTGrammar_ex_NoCoda.cpp |
| 2 |
* |
| 3 |
* Copyright (C) 1997-2005,2007,2009,2011,2012,2015-2020 Paul Boersma |
| 4 |
* |
| 5 |
* This code is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 8 |
* your option) any later version. |
| 9 |
* |
| 10 |
* This code is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
* See the GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "OTGrammar.h" |
| 20 |
|
| 21 |
autoOTGrammar OTGrammar_create_NoCoda_grammar () { |
| 22 |
try { |
| 23 |
OTGrammarCandidate candidate; |
| 24 |
OTGrammarTableau tableau; |
| 25 |
OTGrammarConstraint constraint; |
| 26 |
autoOTGrammar me = Thing_new (OTGrammar); |
| 27 |
my constraints = newvectorzero <structOTGrammarConstraint> (my numberOfConstraints = 2); |
| 28 |
constraint = & my constraints [1]; |
| 29 |
constraint -> name = Melder_dup (U"N\\s{O}C\\s{ODA}"); |
| 30 |
constraint -> ranking = 100.0; |
| 31 |
constraint -> plasticity = 1.0; |
| 32 |
constraint = & my constraints [2]; |
| 33 |
constraint -> name = Melder_dup (U"P\\s{ARSE}"); |
| 34 |
constraint -> ranking = 90.0; |
| 35 |
constraint -> plasticity = 1.0; |
| 36 |
my tableaus = newvectorzero <structOTGrammarTableau> (my numberOfTableaus = 2); |
| 37 |
tableau = & my tableaus [1]; |
| 38 |
tableau -> input = Melder_dup (U"pat"); |
| 39 |
tableau -> candidates = newvectorzero <structOTGrammarCandidate> (tableau -> numberOfCandidates = 2); |
| 40 |
candidate = & tableau -> candidates [1]; |
| 41 |
candidate -> output = Melder_dup (U"pa"); |
| 42 |
candidate -> marks = zero_INTVEC (candidate -> numberOfConstraints = 2); |
| 43 |
candidate -> marks [2] = 1; |
| 44 |
candidate = & tableau -> candidates [2]; |
| 45 |
candidate -> output = Melder_dup (U"pat"); |
| 46 |
candidate -> marks = zero_INTVEC (candidate -> numberOfConstraints = 2); |
| 47 |
candidate -> marks [1] = 1; |
| 48 |
tableau = & my tableaus [2]; |
| 49 |
tableau -> input = Melder_dup (U"pa"); |
| 50 |
tableau -> candidates = newvectorzero <structOTGrammarCandidate> (tableau -> numberOfCandidates = 1); |
| 51 |
candidate = & tableau -> candidates [1]; |
| 52 |
candidate -> output = Melder_dup (U"pa"); |
| 53 |
candidate -> marks = zero_INTVEC (candidate -> numberOfConstraints = 2); |
| 54 |
OTGrammar_checkIndex (me.get()); |
| 55 |
OTGrammar_newDisharmonies (me.get(), 0.0); |
| 56 |
return me; |
| 57 |
} catch (MelderError) { |
| 58 |
Melder_throw (U"NoCoda grammar not created."); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
/* End of file OTGrammar_ex_NoCoda.cpp */ |