| 1 | /* OTGrammar_def.h |
| 2 | * |
| 3 | * Copyright (C) 1997-2011,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 | |
| 20 | #define ooSTRUCT OTGrammarConstraint |
| 21 | oo_DEFINE_STRUCT (OTGrammarConstraint) |
| 22 | |
| 23 | oo_STRING (name) |
| 24 | oo_DOUBLE (ranking) |
| 25 | oo_DOUBLE (disharmony) |
| 26 | |
| 27 | oo_FROM (2) |
| 28 | oo_DOUBLE (plasticity) |
| 29 | oo_ENDFROM |
| 30 | #if oo_READING |
| 31 | oo_VERSION_UNTIL (2) |
| 32 | our plasticity = 1.0; |
| 33 | oo_VERSION_END |
| 34 | #endif |
| 35 | |
| 36 | #if ! oo_READING && ! oo_WRITING && ! oo_COMPARING |
| 37 | oo_BOOLEAN (tiedToTheLeft) |
| 38 | oo_BOOLEAN (tiedToTheRight) |
| 39 | #endif |
| 40 | |
| 41 | oo_END_STRUCT (OTGrammarConstraint) |
| 42 | #undef ooSTRUCT |
| 43 | |
| 44 | |
| 45 | #define ooSTRUCT OTGrammarFixedRanking |
| 46 | oo_DEFINE_STRUCT (OTGrammarFixedRanking) |
| 47 | |
| 48 | oo_INTEGER (higher) |
| 49 | oo_INTEGER (lower) |
| 50 | |
| 51 | oo_END_STRUCT (OTGrammarFixedRanking) |
| 52 | #undef ooSTRUCT |
| 53 | |
| 54 | |
| 55 | #define ooSTRUCT OTGrammarCandidate |
| 56 | oo_DEFINE_STRUCT (OTGrammarCandidate) |
| 57 | |
| 58 | oo_STRING (output) |
| 59 | oo_INTEGER (numberOfConstraints) |
| 60 | oo_INTVEC16 (marks, numberOfConstraints) |
| 61 | |
| 62 | #if ! oo_READING && ! oo_WRITING && ! oo_COMPARING |
| 63 | oo_DOUBLE (harmony) |
| 64 | oo_DOUBLE (probability) |
| 65 | oo_INTEGER (numberOfPotentialPartialOutputsMatching) |
| 66 | oo_BOOLVEC (partialOutputMatches, numberOfPotentialPartialOutputsMatching) |
| 67 | #endif |
| 68 | |
| 69 | oo_END_STRUCT (OTGrammarCandidate) |
| 70 | #undef ooSTRUCT |
| 71 | |
| 72 | |
| 73 | #define ooSTRUCT OTGrammarTableau |
| 74 | oo_DEFINE_STRUCT (OTGrammarTableau) |
| 75 | |
| 76 | oo_STRING (input) |
| 77 | oo_INTEGER (numberOfCandidates) |
| 78 | oo_STRUCTVEC (OTGrammarCandidate, candidates, numberOfCandidates) |
| 79 | |
| 80 | oo_END_STRUCT (OTGrammarTableau) |
| 81 | #undef ooSTRUCT |
| 82 | |
| 83 | |
| 84 | #define ooSTRUCT OTGrammar |
| 85 | oo_DEFINE_CLASS (OTGrammar, Daata) |
| 86 | |
| 87 | oo_FROM (1) |
| 88 | oo_ENUM (kOTGrammar_decisionStrategy, decisionStrategy) |
| 89 | oo_ENDFROM |
| 90 | oo_FROM (2) |
| 91 | oo_DOUBLE (leak) |
| 92 | oo_ENDFROM |
| 93 | oo_INTEGER (numberOfConstraints) |
| 94 | oo_STRUCTVEC (OTGrammarConstraint, constraints, numberOfConstraints) |
| 95 | oo_INTVEC (index, numberOfConstraints) // not read or written in text files |
| 96 | oo_INTEGER (numberOfFixedRankings) |
| 97 | oo_STRUCTVEC (OTGrammarFixedRanking, fixedRankings, numberOfFixedRankings) |
| 98 | oo_INTEGER (numberOfTableaus) |
| 99 | oo_STRUCTVEC (OTGrammarTableau, tableaus, numberOfTableaus) |
| 100 | |
| 101 | #if oo_READING |
| 102 | OTGrammar_sort (this); |
| 103 | #endif |
| 104 | |
| 105 | #if oo_DECLARING |
| 106 | void v1_info () |
| 107 | override; |
| 108 | void checkConstraintNumber (integer constraintNumber) { |
| 109 | Melder_require (constraintNumber >= 1, |
| 110 | U"The specified constraint number (", constraintNumber, U") should not be less than 1."); |
| 111 | Melder_require (constraintNumber <= our numberOfConstraints, |
| 112 | U"The specified constraint number (", constraintNumber, |
| 113 | U") should not exceed the number of constraints (", our numberOfConstraints, U")." |
| 114 | ); |
| 115 | } |
| 116 | void checkTableauNumber (integer tableauNumber) { |
| 117 | Melder_require (tableauNumber >= 1, |
| 118 | U"The specified tableau number (", tableauNumber, U") should not be less than 1."); |
| 119 | Melder_require (tableauNumber <= our numberOfTableaus, |
| 120 | U"The specified tableau number (", tableauNumber, |
| 121 | U") should not exceed the number of tableaus (", our numberOfTableaus, U")." |
| 122 | ); |
| 123 | } |
| 124 | void checkTableauAndCandidateNumber (integer tableauNumber, integer candidateNumber) { |
| 125 | our checkTableauNumber (tableauNumber); |
| 126 | Melder_require (candidateNumber >= 1, |
| 127 | U"The specified candidate number (", candidateNumber, U") should not be less than 1."); |
| 128 | Melder_require (candidateNumber <= our tableaus [tableauNumber]. numberOfCandidates, |
| 129 | U"The specified candidate number (", candidateNumber, |
| 130 | U") should not exceed the number of candidates in tableau ", tableauNumber, |
| 131 | U" (", our tableaus [tableauNumber]. numberOfCandidates, U")." |
| 132 | ); |
| 133 | } |
| 134 | #endif |
| 135 | |
| 136 | oo_END_CLASS (OTGrammar) |
| 137 | #undef ooSTRUCT |
| 138 | |
| 139 | |
| 140 | /* End of file OTGrammar_def.h */ |