| 1 | /* OTGrammar_ex_metrics.cpp |
| 2 | * |
| 3 | * Copyright (C) 2001-2007,2009,2011,2012,2014-2022 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 | * pb 2001/11/25 |
| 21 | * pb 2002/07/16 GPL |
| 22 | * pb 2003/03/31 removeConstraint |
| 23 | * pb 2003/05/09 added Peripheral and MainNonfinal |
| 24 | * pb 2004/01/14 added HeadNonfinal |
| 25 | * pb 2004/01/25 added overtFormsHaveSecondaryStress |
| 26 | * pb 2004/07/27 added Clash and Lapse |
| 27 | * pb 2004/08/11 complete rewrite in order to include WeightByPosition and *MoraicConsonant |
| 28 | * pb 2004/12/03 corrected *Lapse |
| 29 | * pb 2007/07/23 constraint plasticity |
| 30 | * pb 2007/08/12 wchar |
| 31 | * pb 2011/03/29 C++ |
| 32 | * pb 2011/06/29 C++ |
| 33 | */ |
| 34 | |
| 35 | #include "OTGrammar.h"cxx . . $ `<file>/gram/OTGrammar.h`/ |
| 36 | |
| 37 | #define WSPcxx . . $ `gram/OTGrammar_ex_metrics.cpp:37:9`! 1 |
| 38 | #define FtNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:38:9`! 2 |
| 39 | #define Iambiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:39:9`! 3 |
| 40 | #define Parsecxx . . $ `gram/OTGrammar_ex_metrics.cpp:40:9`! 4 |
| 41 | #define FootBincxx . . $ `gram/OTGrammar_ex_metrics.cpp:41:9`! 5 |
| 42 | #define WFLcxx . . $ `gram/OTGrammar_ex_metrics.cpp:42:9`! 6 |
| 43 | #define WFRcxx . . $ `gram/OTGrammar_ex_metrics.cpp:43:9`! 7 |
| 44 | #define Main_Lcxx . . $ `gram/OTGrammar_ex_metrics.cpp:44:9`! 8 |
| 45 | #define Main_Rcxx . . $ `gram/OTGrammar_ex_metrics.cpp:45:9`! 9 |
| 46 | #define AFLcxx . . $ `gram/OTGrammar_ex_metrics.cpp:46:9`! 10 |
| 47 | #define AFRcxx . . $ `gram/OTGrammar_ex_metrics.cpp:47:9`! 11 |
| 48 | #define Nonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:48:9`! 12 |
| 49 | |
| 50 | #define Trochaiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:50:9`! 13 |
| 51 | #define FootBimoraiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:51:9`! 14 |
| 52 | #define FootBisyllabiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:52:9`! 15 |
| 53 | #define Peripheralcxx . . $ `gram/OTGrammar_ex_metrics.cpp:53:9`! 16 |
| 54 | #define MainNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:54:9`! 17 |
| 55 | #define HeadNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:55:9`! 18 |
| 56 | #define Clashcxx . . $ `gram/OTGrammar_ex_metrics.cpp:56:9`! 19 |
| 57 | #define Lapsecxx . . $ `gram/OTGrammar_ex_metrics.cpp:57:9`! 20 |
| 58 | |
| 59 | #define WeightByPositioncxx . . $ `gram/OTGrammar_ex_metrics.cpp:59:9`! 21 |
| 60 | #define MoraicConsonantcxx . . $ `gram/OTGrammar_ex_metrics.cpp:60:9`! 22 |
| 61 | |
| 62 | #define NUMBER_OF_CONSTRAINTScxx . . $ `gram/OTGrammar_ex_metrics.cpp:62:9`! 22 |
| 63 | |
| 64 | static const conststring32cxx . . $ conststring32# constraintNamescxx . . $ constraintNames. [1+NUMBER_OF_CONSTRAINTScxx . . $ `gram/OTGrammar_ex_metrics.cpp:62:9`!] = { 0, |
| 65 | U"WSP", U"FtNonfinal", U"Iambic", U"Parse", U"FootBin", U"WFL", U"WFR", U"Main-L", U"Main-R", U"AFL", U"AFR", U"Nonfinal", |
| 66 | U"Trochaic", U"FtBimor", U"FtBisyl", U"Peripheral", U"MainNonfinal", U"HeadNonfinal", U"*Clash", U"*Lapse", U"WeightByPosition", U"*C\\mu" }; |
| 67 | |
| 68 | static void addCandidatecxx . . $ addCandidate(bbf9dad07eea29c8). (OTGrammarTableaucxx . . $ OTGrammarTableau# me, integercxx . . $ integer# numberOfSyllables, int stress [], |
| 69 | bool footedToTheLeft [], bool footedToTheRight [], int surfaceWeightPattern [], |
| 70 | bool overtFormsHaveSecondaryStress) |
| 71 | { |
| 72 | static const conststring32cxx . . $ conststring32# syllable [] = |
| 73 | { U"L", U"L1", U"L2", U"H", U"H1", U"H2", U"K", U"K1", U"K2", U"J", U"J1", U"J2" }; |
| 74 | static const conststring32cxx . . $ conststring32# syllableWithoutSecondaryStress [] = |
| 75 | { U"L", U"L1", U"L", U"H", U"H1", U"H", U"K", U"K1", U"K", U"J", U"J1", U"J" }; |
| 76 | char32cxx . . $ char32# output [100]; |
| 77 | str32cpycxx . . $ str32cpy(6ab934322573b179). (output, U"["); |
| 78 | for (integercxx . . $ integer# isyll = 1; isyll <= numberOfSyllables; isyll ++) { |
| 79 | if (isyll > 1) |
| 80 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U" "); |
| 81 | str32catcxx . . $ str32cat(6ab934322573b179). (output, ( overtFormsHaveSecondaryStress ? syllable : syllableWithoutSecondaryStress ) |
| 82 | [stress [isyll] + 3 * (surfaceWeightPattern [isyll] - 1)]); |
| 83 | } |
| 84 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U"] \\-> /"); |
| 85 | for (integercxx . . $ integer# isyll = 1; isyll <= numberOfSyllables; isyll ++) { |
| 86 | if (isyll > 1) |
| 87 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U" "); |
| 88 | if (footedToTheRight [isyll] || (! footedToTheLeft [isyll] && stress [isyll] != 0)) |
| 89 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U"("); |
| 90 | str32catcxx . . $ str32cat(6ab934322573b179). (output, syllable [stress [isyll] + 3 * (surfaceWeightPattern [isyll] - 1)]); |
| 91 | if (footedToTheLeft [isyll] || (! footedToTheRight [isyll] && stress [isyll] != 0)) |
| 92 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U")"); |
| 93 | } |
| 94 | str32catcxx . . $ str32cat(6ab934322573b179). (output, U"/"); |
| 95 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structOTGrammarTableau#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ mycxx . . $ `melder/melder.h:44:9`! numberOfCandidatescxx . . $ structOTGrammarTableau#numberOfCandidates.]. outputcxx . . $ structOTGrammarCandidate#output. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (output); |
| 96 | } |
| 97 | |
| 98 | static void fillSurfaceWeightPatterncxx . . $ fillSurfaceWeightPattern(bbf9dad07eea29c8). (OTGrammarTableaucxx . . $ OTGrammarTableau# me, integercxx . . $ integer# numberOfSyllables, int stress [], |
| 99 | bool footedToTheLeft [], bool footedToTheRight [], int underlyingWeightPattern [], |
| 100 | bool overtFormsHaveSecondaryStress) |
| 101 | { |
| 102 | int surfaceWeightPattern [1+7], minSurfaceWeight [1+7], maxSurfaceWeight [1+7]; |
| 103 | for (integercxx . . $ integer# isyll = 1; isyll <= numberOfSyllables; isyll ++) { |
| 104 | if (underlyingWeightPattern [isyll] < 3) { |
| 105 | minSurfaceWeight [isyll] = maxSurfaceWeight [isyll] = underlyingWeightPattern [isyll]; // L -> L; H -> H |
| 106 | } else { |
| 107 | minSurfaceWeight [isyll] = 3; |
| 108 | maxSurfaceWeight [isyll] = 4; // C -> { J, K } |
| 109 | } |
| 110 | } |
| 111 | surfaceWeightPattern [6] = surfaceWeightPattern [7] = 1; // constant L |
| 112 | for (int weight1 = minSurfaceWeight [1]; weight1 <= maxSurfaceWeight [1]; weight1 ++) { |
| 113 | surfaceWeightPattern [1] = weight1; |
| 114 | for (int weight2 = minSurfaceWeight [2]; weight2 <= maxSurfaceWeight [2]; weight2 ++) { |
| 115 | surfaceWeightPattern [2] = weight2; |
| 116 | if (numberOfSyllables == 2) { |
| 117 | addCandidatecxx . . $ addCandidate(bbf9dad07eea29c8). (me, 2, stress, footedToTheLeft, footedToTheRight, surfaceWeightPattern, overtFormsHaveSecondaryStress); |
| 118 | } else for (int weight3 = minSurfaceWeight [3]; weight3 <= maxSurfaceWeight [3]; weight3 ++) { |
| 119 | surfaceWeightPattern [3] = weight3; |
| 120 | if (numberOfSyllables == 3) { |
| 121 | addCandidatecxx . . $ addCandidate(bbf9dad07eea29c8). (me, 3, stress, footedToTheLeft, footedToTheRight, surfaceWeightPattern, overtFormsHaveSecondaryStress); |
| 122 | } else for (int weight4 = minSurfaceWeight [4]; weight4 <= maxSurfaceWeight [4]; weight4 ++) { |
| 123 | surfaceWeightPattern [4] = weight4; |
| 124 | if (numberOfSyllables == 4) { |
| 125 | addCandidatecxx . . $ addCandidate(bbf9dad07eea29c8). (me, 4, stress, footedToTheLeft, footedToTheRight, surfaceWeightPattern, overtFormsHaveSecondaryStress); |
| 126 | } else for (int weight5 = minSurfaceWeight [5]; weight5 <= maxSurfaceWeight [5]; weight5 ++) { |
| 127 | surfaceWeightPattern [5] = weight5; |
| 128 | addCandidatecxx . . $ addCandidate(bbf9dad07eea29c8). (me, numberOfSyllables, stress, footedToTheLeft, footedToTheRight, surfaceWeightPattern, overtFormsHaveSecondaryStress); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | static void pathcxx . . $ path(3e9b0633ecb8dffa). (OTGrammarTableaucxx . . $ OTGrammarTableau# me, integercxx . . $ integer# numberOfSyllables, int stress [], |
| 137 | int startingSyllable, bool footedToTheLeft_in [], bool footedToTheRight_in [], int underlyingWeightPattern [], |
| 138 | bool overtFormsHaveSecondaryStress) |
| 139 | { |
| 140 | bool footedToTheLeft [10], footedToTheRight [10]; |
| 141 | /* Localize all arguments. */ |
| 142 | for (integercxx . . $ integer# isyll = 1; isyll <= startingSyllable; isyll ++) { |
| 143 | footedToTheLeft [isyll] = footedToTheLeft_in [isyll]; |
| 144 | footedToTheRight [isyll] = footedToTheRight_in [isyll]; |
| 145 | } |
| 146 | for (integercxx . . $ integer# isyll = startingSyllable + 1; isyll <= numberOfSyllables; isyll ++) |
| 147 | footedToTheLeft [isyll] = footedToTheRight [isyll] = 0; |
| 148 | if (startingSyllable > numberOfSyllables) { |
| 149 | fillSurfaceWeightPatterncxx . . $ fillSurfaceWeightPattern(bbf9dad07eea29c8). (me, numberOfSyllables, stress, footedToTheLeft, footedToTheRight, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 150 | } else { |
| 151 | pathcxx . . $ path(3e9b0633ecb8dffa). (me, numberOfSyllables, stress, startingSyllable + 1, |
| 152 | footedToTheLeft, footedToTheRight, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 153 | if (stress [startingSyllable] == 0 && startingSyllable < numberOfSyllables && stress [startingSyllable + 1] != 0) { |
| 154 | footedToTheLeft [startingSyllable + 1] = true; |
| 155 | footedToTheRight [startingSyllable] = true; |
| 156 | pathcxx . . $ path(3e9b0633ecb8dffa). (me, numberOfSyllables, stress, startingSyllable + 1, |
| 157 | footedToTheLeft, footedToTheRight, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 158 | footedToTheLeft [startingSyllable + 1] = false; |
| 159 | footedToTheRight [startingSyllable] = false; |
| 160 | } |
| 161 | if (stress [startingSyllable] == 0 && startingSyllable > 1 && stress [startingSyllable - 1] != 0 |
| 162 | && ! footedToTheLeft [startingSyllable - 1]) |
| 163 | { |
| 164 | footedToTheRight [startingSyllable - 1] = true; |
| 165 | footedToTheLeft [startingSyllable] = true; |
| 166 | pathcxx . . $ path(3e9b0633ecb8dffa). (me, numberOfSyllables, stress, startingSyllable + 1, |
| 167 | footedToTheLeft, footedToTheRight, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | static void fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (OTGrammarTableaucxx . . $ OTGrammarTableau# me, integercxx . . $ integer# numberOfSyllables, int stress [], int underlyingWeightPattern [], |
| 173 | bool overtFormsHaveSecondaryStress) |
| 174 | { |
| 175 | bool footedToTheLeft [10], footedToTheRight [10]; |
| 176 | for (int isyll = 1; isyll <= numberOfSyllables; isyll ++) |
| 177 | footedToTheLeft [isyll] = footedToTheRight [isyll] = 0; |
| 178 | pathcxx . . $ path(3e9b0633ecb8dffa). (me, numberOfSyllables, stress, 1, footedToTheLeft, footedToTheRight, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 179 | } |
| 180 | |
| 181 | static void fillTableaucxx . . $ fillTableau(d87a657946ebe59e). (OTGrammarTableaucxx . . $ OTGrammarTableau# me, integercxx . . $ integer# numberOfSyllables, int underlyingWeightPattern [], bool overtFormsHaveSecondaryStress, bool includeCodas) { |
| 182 | char32cxx . . $ char32# input [100]; |
| 183 | static int numberOfCandidates_noCodas [1+7] = |
| 184 | { 0, 1, 6, 24, 88, 300, 984, 3136 }; |
| 185 | static int numberOfCandidates_codas [1+7] = |
| 186 | { 0, 1, 24, 192, 1408, 9600, 984, 3136 }; |
| 187 | str32cpycxx . . $ str32cpy(6ab934322573b179). (input, U"|"); |
| 188 | for (integercxx . . $ integer# isyll = 1; isyll <= numberOfSyllables; isyll ++) { |
| 189 | static const conststring32cxx . . $ conststring32# syllable_noCodas [] = { U"", U"L", U"H" }; |
| 190 | static const conststring32cxx . . $ conststring32# syllable_codas [] = { U"", U"cv", U"cv:", U"cvc" }; |
| 191 | if (isyll > 1) |
| 192 | str32catcxx . . $ str32cat(6ab934322573b179). (input, includeCodas ? U"." : U" "); |
| 193 | str32catcxx . . $ str32cat(6ab934322573b179). (input, ( includeCodas ? syllable_codas : syllable_noCodas ) [underlyingWeightPattern [isyll]]); |
| 194 | } |
| 195 | str32catcxx . . $ str32cat(6ab934322573b179). (input, U"|"); |
| 196 | mycxx . . $ `melder/melder.h:44:9`! inputcxx . . $ structOTGrammarTableau#input. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (input); |
| 197 | mycxx . . $ `melder/melder.h:44:9`! candidatescxx . . $ structOTGrammarTableau#candidates. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <structOTGrammarCandidatecxx . . $ structOTGrammarCandidate#> (( includeCodas ? numberOfCandidates_codas : numberOfCandidates_noCodas ) [numberOfSyllables]); |
| 198 | for (integercxx . . $ integer# mainStressed = 1; mainStressed <= numberOfSyllables; mainStressed ++) { |
| 199 | int stress [10]; |
| 200 | stress [mainStressed] = 1; |
| 201 | for (int secondary1 = false; secondary1 <= true; secondary1 ++) { |
| 202 | stress [mainStressed <= 1 ? 2 : 1] = secondary1 ? 2 : 0; |
| 203 | if (numberOfSyllables == 2) { |
| 204 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 2, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 205 | } else for (int secondary2 = false; secondary2 <= true; secondary2 ++) { |
| 206 | stress [mainStressed <= 2 ? 3 : 2] = secondary2 ? 2 : 0; |
| 207 | if (numberOfSyllables == 3) { |
| 208 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 3, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 209 | } else for (int secondary3 = false; secondary3 <= true; secondary3 ++) { |
| 210 | stress [mainStressed <= 3 ? 4 : 3] = secondary3 ? 2 : 0; |
| 211 | if (numberOfSyllables == 4) { |
| 212 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 4, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 213 | } else for (int secondary4 = false; secondary4 <= true; secondary4 ++) { |
| 214 | stress [mainStressed <= 4 ? 5 : 4] = secondary4 ? 2 : 0; |
| 215 | if (numberOfSyllables == 5) { |
| 216 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 5, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 217 | } else for (int secondary5 = false; secondary5 <= true; secondary5 ++) { |
| 218 | stress [mainStressed <= 5 ? 6 : 5] = secondary5 ? 2 : 0; |
| 219 | if (numberOfSyllables == 6) { |
| 220 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 6, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 221 | } else for (int secondary6 = false; secondary6 <= true; secondary6 ++) { |
| 222 | stress [mainStressed <= 6 ? 7 : 6] = secondary6 ? 2 : 0; |
| 223 | fillOvertStressPatterncxx . . $ fillOvertStressPattern(d1070d6d103f050c). (me, 7, stress, underlyingWeightPattern, overtFormsHaveSecondaryStress); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | static void computeViolationMarkscxx . . $ computeViolationMarks(4f9a5c4cf6c3eb02). (OTGrammarCandidatecxx . . $ OTGrammarCandidate# me) { |
| 234 | #define isHeavycxx . . $ `gram/OTGrammar_ex_metrics.cpp:234:10`!(s) ((s) == 'H' || (s) == 'J') |
| 235 | #define isLightcxx . . $ `gram/OTGrammar_ex_metrics.cpp:235:10`!(s) ((s) == 'L' || (s) == 'K') |
| 236 | #define isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`!(s) (isHeavycxx . . $ `gram/OTGrammar_ex_metrics.cpp:234:10`! (s) || isLightcxx . . $ `gram/OTGrammar_ex_metrics.cpp:235:10`! (s)) |
| 237 | #define isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`!(s) ((s) == '1' || (s) == '2') |
| 238 | const char32cxx . . $ char32# *firstSlash = str32chrcxx . . $ str32chr(328a9ede0fba853a). (mycxx . . $ `melder/melder.h:44:9`! outputcxx . . $ structOTGrammarCandidate#output..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U'/'); |
| 239 | const char32cxx . . $ char32# *lastSlash = & mycxx . . $ `melder/melder.h:44:9`! outputcxx . . $ structOTGrammarCandidate#output. [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (mycxx . . $ `melder/melder.h:44:9`! outputcxx . . $ structOTGrammarCandidate#output..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) - 1]; |
| 240 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_INTVECcxx . . $ zero_INTVEC(dab5d3ef28d6a25). (mycxx . . $ `melder/melder.h:44:9`! numberOfConstraintscxx . . $ structOTGrammarCandidate#numberOfConstraints. = NUMBER_OF_CONSTRAINTScxx . . $ `gram/OTGrammar_ex_metrics.cpp:62:9`!); |
| 241 | /* Violations of WSP: count all H not followed by 1 or 2. */ |
| 242 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 243 | if (isHeavycxx . . $ `gram/OTGrammar_ex_metrics.cpp:234:10`! (p [0]) && ! isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [1])) |
| 244 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).WSPcxx . . $ `gram/OTGrammar_ex_metrics.cpp:37:9`!] ++; |
| 245 | /* Violations of FtNonfinal: count all heads followed by ). */ |
| 246 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 247 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [0]) && p [1] == U')') |
| 248 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).FtNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:38:9`!] ++; |
| 249 | /* Violations of Iambic: count all heads not followed by ). */ |
| 250 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 251 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [0]) && p [1] != U')') |
| 252 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Iambiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:39:9`!] ++; |
| 253 | /* Violations of Parse and Peripheral: count all syllables not between (). */ |
| 254 | int depth = 0; |
| 255 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) { |
| 256 | if (p [0] == U'(') |
| 257 | depth ++; |
| 258 | else if (p [0] == U')') |
| 259 | depth --; |
| 260 | else if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0]) && depth != 1) { |
| 261 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Parsecxx . . $ `gram/OTGrammar_ex_metrics.cpp:40:9`!] ++; |
| 262 | if (p != firstSlash + 1 && p != lastSlash - 1) |
| 263 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Peripheralcxx . . $ `gram/OTGrammar_ex_metrics.cpp:53:9`!] ++; |
| 264 | } |
| 265 | } |
| 266 | /* Violations of FootBin: count all (L1) and (L2). */ |
| 267 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 268 | if (isLightcxx . . $ `gram/OTGrammar_ex_metrics.cpp:235:10`! (p [0]) && p [-1] == U'(' && isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [1]) && p [2] == ')') |
| 269 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).FootBincxx . . $ `gram/OTGrammar_ex_metrics.cpp:41:9`!] ++; |
| 270 | /* Violations of WFL: count all initial / not followed by (. */ |
| 271 | if (firstSlash [1] != '(') |
| 272 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).WFLcxx . . $ `gram/OTGrammar_ex_metrics.cpp:42:9`!] = 1; |
| 273 | /* Violations of WFR: count all final / not preceded by ). */ |
| 274 | if (lastSlash [-1] != ')') |
| 275 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).WFRcxx . . $ `gram/OTGrammar_ex_metrics.cpp:43:9`!] = 1; |
| 276 | /* Violations of Main_L: count syllables from foot containing X1 to left edge. */ |
| 277 | { |
| 278 | char32cxx . . $ char32# *p = str32chrcxx . . $ str32chr(328a9ede0fba853a). (firstSlash, U'1'); |
| 279 | for (; *p != U'('; p --) { } |
| 280 | for (; p != firstSlash; p --) |
| 281 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0])) |
| 282 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Main_Lcxx . . $ `gram/OTGrammar_ex_metrics.cpp:44:9`!] ++; |
| 283 | } |
| 284 | /* Violations of Main_R: count syllables from foot containing X1 to right edge. */ |
| 285 | { |
| 286 | char32cxx . . $ char32# *p = str32chrcxx . . $ str32chr(328a9ede0fba853a). (firstSlash, U'1'); |
| 287 | for (; *p != U')'; p ++) { } |
| 288 | for (; p != lastSlash; p ++) |
| 289 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0])) |
| 290 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Main_Rcxx . . $ `gram/OTGrammar_ex_metrics.cpp:45:9`!] ++; |
| 291 | } |
| 292 | /* Violations of AFL: count syllables from every foot to left edge. */ |
| 293 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 294 | if (p [0] == U'(') |
| 295 | for (const char32cxx . . $ char32# *q = p; q != firstSlash; q --) |
| 296 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (q [0])) |
| 297 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).AFLcxx . . $ `gram/OTGrammar_ex_metrics.cpp:46:9`!] ++; |
| 298 | /* Violations of AFR: count syllables from every foot to right edge. */ |
| 299 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 300 | if (p [0] == U')') |
| 301 | for (const char32cxx . . $ char32# *q = p; q != lastSlash; q ++) |
| 302 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (q [0])) |
| 303 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).AFRcxx . . $ `gram/OTGrammar_ex_metrics.cpp:47:9`!] ++; |
| 304 | /* Violations of Nonfinal: count all final / preceded by ). */ |
| 305 | if (lastSlash [-1] == U')') |
| 306 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Nonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:48:9`!] = 1; |
| 307 | /* Violations of Trochaic: count all heads not preceded by (. */ |
| 308 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 309 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [0]) && p [-2] != U'(') |
| 310 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Trochaiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:50:9`!] ++; |
| 311 | /* Violations of FootBimoraic: count weight between (). */ |
| 312 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) { |
| 313 | if (p [0] == U'(') { |
| 314 | int weight = 0; |
| 315 | for (p ++; p [0] != U')'; p ++) { |
| 316 | if (isHeavycxx . . $ `gram/OTGrammar_ex_metrics.cpp:234:10`! (p [0])) |
| 317 | weight += 2; |
| 318 | else if (isLightcxx . . $ `gram/OTGrammar_ex_metrics.cpp:235:10`! (p [0])) |
| 319 | weight += 1; |
| 320 | } |
| 321 | if (weight != 2) |
| 322 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).FootBimoraiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:51:9`!] ++; |
| 323 | } |
| 324 | } |
| 325 | /* Violations of FootBisyllabic: count all (X1) and (X2). */ |
| 326 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) { |
| 327 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0]) && p [-1] == U'(' && isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [1]) && p [2] == U')') |
| 328 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).FootBisyllabiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:52:9`!] ++; |
| 329 | } |
| 330 | /* Violations of MainNonfinal: count all final / preceded by ) preceded by 1 in the same foot. */ |
| 331 | if (lastSlash [-1] == U')') { |
| 332 | for (const char32cxx . . $ char32# *p = lastSlash - 2; ; p --) { |
| 333 | if (p [0] == U'2') |
| 334 | break; |
| 335 | if (p [0] == U'1') { |
| 336 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).MainNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:54:9`!] = 1; |
| 337 | break; |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | /* Violations of HeadNonfinal: count all final / preceded by ) directly preceded by 1, plus MainNonfinal. */ |
| 342 | if (lastSlash [-1] == U')') { |
| 343 | if (lastSlash [-2] == U'1') { |
| 344 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).HeadNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:55:9`!] = 2; |
| 345 | } else { |
| 346 | for (const char32cxx . . $ char32# *p = lastSlash - 2; ; p --) { |
| 347 | if (p [0] == U'2') |
| 348 | break; |
| 349 | if (p [0] == U'1') { |
| 350 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).HeadNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:55:9`!] = 1; |
| 351 | break; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | /* Violations of *Clash: count all 1 and 2 followed by an 1 or 2 after the next L or H. */ |
| 357 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) { |
| 358 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [0])) { |
| 359 | for (const char32cxx . . $ char32# *q = p + 1; q != lastSlash; q ++) { |
| 360 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (q [0])) { |
| 361 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (q [1])) |
| 362 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Clashcxx . . $ `gram/OTGrammar_ex_metrics.cpp:56:9`!] ++; |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | /* Violations of *Lapse: count all sequences of three unstressed syllables. */ |
| 369 | depth = 0; |
| 370 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) { |
| 371 | if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0])) { |
| 372 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [1])) { |
| 373 | depth = 0; |
| 374 | } else { |
| 375 | if (++ depth > 2) |
| 376 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Lapsecxx . . $ `gram/OTGrammar_ex_metrics.cpp:57:9`!] ++; |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | /* Violations of WeightByPosition: count all K. */ |
| 381 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 382 | if (p [0] == U'K') |
| 383 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).WeightByPositioncxx . . $ `gram/OTGrammar_ex_metrics.cpp:59:9`!] ++; |
| 384 | /* Violations of *MoraicConsonant: count all J. */ |
| 385 | for (const char32cxx . . $ char32# *p = firstSlash + 1; p != lastSlash; p ++) |
| 386 | if (p [0] == U'J') |
| 387 | mycxx . . $ `melder/melder.h:44:9`! markscxx . . $ structOTGrammarCandidate#marks. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).MoraicConsonantcxx . . $ `gram/OTGrammar_ex_metrics.cpp:60:9`!] ++; |
| 388 | } |
| 389 | |
| 390 | static void replaceOutputcxx . . $ replaceOutput(4f9a5c4cf6c3eb02). (OTGrammarCandidatecxx . . $ OTGrammarCandidate# me) { |
| 391 | bool abstract = false; |
| 392 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! output); |
| 393 | char32cxx . . $ char32# newOutput [100], *q = & newOutput [0]; |
| 394 | for (const char32cxx . . $ char32# *p = & mycxx . . $ `melder/melder.h:44:9`! outputcxx . . $ structOTGrammarCandidate#output. [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0]; *p != U'\0'; p ++) { |
| 395 | if (p [0] == U' ') { |
| 396 | *q ++ = ( p [-1] == U']' || p [1] == U'/' ? U' ' : U'.' ); |
| 397 | } else if (isSyllablecxx . . $ `gram/OTGrammar_ex_metrics.cpp:236:10`! (p [0])) { |
| 398 | *q ++ = U'c'; |
| 399 | if (abstract) { |
| 400 | *q ++ = U'V'; |
| 401 | if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [1])) |
| 402 | *q ++ = p [1]; |
| 403 | if (p [0] == U'L') { |
| 404 | ; |
| 405 | } else if (p [0] == U'H') { |
| 406 | *q ++ = U'V'; |
| 407 | } else if (p [0] == U'K') { |
| 408 | *q ++ = U'c'; |
| 409 | } else { |
| 410 | *q ++ = U'C'; |
| 411 | } |
| 412 | } else { |
| 413 | *q ++ = U'v'; |
| 414 | if (p [0] == U'L') { |
| 415 | ; |
| 416 | } else if (p [0] == U'H') { |
| 417 | *q ++ = U':'; |
| 418 | } else { |
| 419 | *q ++ = U'c'; |
| 420 | } |
| 421 | } |
| 422 | } else if (isStresscxx . . $ `gram/OTGrammar_ex_metrics.cpp:237:10`! (p [0]) && abstract) { |
| 423 | ; |
| 424 | } else { |
| 425 | if (p [0] == U'/') |
| 426 | abstract = true; |
| 427 | *q ++ = p [0]; |
| 428 | } |
| 429 | } |
| 430 | *q = U'\0'; |
| 431 | mycxx . . $ `melder/melder.h:44:9`! outputcxx . . $ structOTGrammarCandidate#output. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (newOutput); |
| 432 | } |
| 433 | |
| 434 | autoOTGrammarcxx . . $ autoOTGrammar# OTGrammar_create_metricscxx . . $ OTGrammar_create_metrics(16e8b8c6d2dce2df). ( |
| 435 | kOTGrammar_createMetricsGrammar_initialRankingcxx . . $ kOTGrammar_createMetricsGrammar_initialRanking# equal_footForm_wsp, |
| 436 | int trochaicityConstraint, bool includeFootBimoraic, bool includeFootBisyllabic, |
| 437 | bool includePeripheral, int nonfinalityConstraint, bool overtFormsHaveSecondaryStress, |
| 438 | bool includeClashAndLapse, bool includeCodas) |
| 439 | { |
| 440 | try { |
| 441 | int underlyingWeightPattern [1+7], maximumUnderlyingWeight = ( includeCodas ? 3 : 2 ); |
| 442 | const integercxx . . $ integer# numberOfTableaus = ( includeCodas ? 9 + 27 + 81 + 243 + 2 : 62 ); |
| 443 | autoOTGrammarcxx . . $ autoOTGrammar# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (OTGrammar); |
| 444 | mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <structOTGrammarConstraintcxx . . $ structOTGrammarConstraint#> (mycxx . . $ `melder/melder.h:44:9`! numberOfConstraintscxx . . $ structOTGrammar#numberOfConstraints. = NUMBER_OF_CONSTRAINTScxx . . $ `gram/OTGrammar_ex_metrics.cpp:62:9`!); |
| 445 | for (integercxx . . $ integer# icons = 1; icons <= NUMBER_OF_CONSTRAINTScxx . . $ `gram/OTGrammar_ex_metrics.cpp:62:9`!; icons ++) { |
| 446 | OTGrammarConstraintcxx . . $ OTGrammarConstraint# constraint = & mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icons]; |
| 447 | constraint -> namecxx . . $ structOTGrammarConstraint#name. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (constraintNamescxx . . $ constraintNames. [icons]); |
| 448 | constraint -> rankingcxx . . $ structOTGrammarConstraint#ranking. = 100.0; |
| 449 | constraint -> plasticitycxx . . $ structOTGrammarConstraint#plasticity. = 1.0; |
| 450 | } |
| 451 | if (equal_footForm_wsp >= kOTGrammar_createMetricsGrammar_initialRankingcxx . . $ kOTGrammar_createMetricsGrammar_initialRanking#::FOOT_FORM_HIGHcxx . . $ kOTGrammar_createMetricsGrammar_initialRanking#FOOT_FORM_HIGH.) { |
| 452 | /* |
| 453 | Foot form constraints high. |
| 454 | */ |
| 455 | mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).FtNonfinalcxx . . $ `gram/OTGrammar_ex_metrics.cpp:38:9`!]. rankingcxx . . $ structOTGrammarConstraint#ranking. = 101.0; |
| 456 | mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Iambiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:39:9`!]. rankingcxx . . $ structOTGrammarConstraint#ranking. = 101.0; |
| 457 | mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).Trochaiccxx . . $ `gram/OTGrammar_ex_metrics.cpp:50:9`!]. rankingcxx . . $ structOTGrammarConstraint#ranking. = -1e9; |
| 458 | } |
| 459 | if (equal_footForm_wsp == kOTGrammar_createMetricsGrammar_initialRankingcxx . . $ kOTGrammar_createMetricsGrammar_initialRanking#::WSP_HIGHcxx . . $ kOTGrammar_createMetricsGrammar_initialRanking#WSP_HIGH.) { |
| 460 | /* |
| 461 | Quantity sensitivity high, foot form constraints in the second stratum. |
| 462 | */ |
| 463 | mycxx . . $ `melder/melder.h:44:9`! constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).WSPcxx . . $ `gram/OTGrammar_ex_metrics.cpp:37:9`!]. rankingcxx . . $ structOTGrammarConstraint#ranking. = 102.0; |
| 464 | } |
| 465 | mycxx . . $ `melder/melder.h:44:9`! tableauscxx . . $ structOTGrammar#tableaus. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <structOTGrammarTableaucxx . . $ structOTGrammarTableau#> (numberOfTableaus); |
| 466 | for (int numberOfSyllables = 2; numberOfSyllables <= 7; numberOfSyllables ++) { |
| 467 | const integercxx . . $ integer# numberOfUnderlyingWeightPatterns = |
| 468 | ( numberOfSyllables > 5 ? 1 : Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (powcxx . . $ pow(9454dda30a4b8335). (maximumUnderlyingWeight, numberOfSyllables)) ); |
| 469 | for (integercxx . . $ integer# isyll = 1; isyll <= numberOfSyllables; isyll ++) |
| 470 | underlyingWeightPattern [isyll] = 1; // L or cv |
| 471 | for (integercxx . . $ integer# iweightPattern = 1; iweightPattern <= numberOfUnderlyingWeightPatterns; iweightPattern ++) { |
| 472 | fillTableaucxx . . $ fillTableau(d87a657946ebe59e). (& mycxx . . $ `melder/melder.h:44:9`! tableauscxx . . $ structOTGrammar#tableaus. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ mycxx . . $ `melder/melder.h:44:9`! numberOfTableauscxx . . $ structOTGrammar#numberOfTableaus.], numberOfSyllables, underlyingWeightPattern, overtFormsHaveSecondaryStress, includeCodas); |
| 473 | /* |
| 474 | Cycle to next underlying weight pattern. |
| 475 | */ |
| 476 | underlyingWeightPattern [numberOfSyllables] += 1; |
| 477 | for (integercxx . . $ integer# isyll = numberOfSyllables; isyll >= 2; isyll --) { |
| 478 | if (underlyingWeightPattern [isyll] > maximumUnderlyingWeight) { |
| 479 | underlyingWeightPattern [isyll] = 1; |
| 480 | underlyingWeightPattern [isyll - 1] += 1; |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | /* Compute violation marks. */ |
| 486 | for (integercxx . . $ integer# itab = 1; itab <= mycxx . . $ `melder/melder.h:44:9`! numberOfTableauscxx . . $ structOTGrammar#numberOfTableaus.; itab ++) { |
| 487 | OTGrammarTableaucxx . . $ OTGrammarTableau# tableau = & mycxx . . $ `melder/melder.h:44:9`! tableauscxx . . $ structOTGrammar#tableaus. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).itab]; |
| 488 | for (integercxx . . $ integer# icand = 1; icand <= tableau -> numberOfCandidatescxx . . $ structOTGrammarTableau#numberOfCandidates.; icand ++) |
| 489 | computeViolationMarkscxx . . $ computeViolationMarks(4f9a5c4cf6c3eb02). (& tableau -> candidatescxx . . $ structOTGrammarTableau#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icand]); |
| 490 | } |
| 491 | OTGrammar_checkIndexcxx . . $ OTGrammar_checkIndex(17bef8f582790df). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 492 | OTGrammar_newDisharmoniescxx . . $ OTGrammar_newDisharmonies(ebbb2d2a494dd028). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0); |
| 493 | if (trochaicityConstraint == 1) |
| 494 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Trochaic"); |
| 495 | else |
| 496 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"FtNonfinal"); |
| 497 | if (! includeFootBimoraic) |
| 498 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"FtBimor"); |
| 499 | if (! includeFootBisyllabic) |
| 500 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"FtBisyl"); |
| 501 | if (! includePeripheral) |
| 502 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Peripheral"); |
| 503 | if (nonfinalityConstraint == 1) { |
| 504 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"MainNonfinal"); |
| 505 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"HeadNonfinal"); |
| 506 | } else if (nonfinalityConstraint == 2) { |
| 507 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"HeadNonfinal"); |
| 508 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Nonfinal"); |
| 509 | } else { |
| 510 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"MainNonfinal"); |
| 511 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"Nonfinal"); |
| 512 | } |
| 513 | if (! includeClashAndLapse) { |
| 514 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"*Clash"); |
| 515 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"*Lapse"); |
| 516 | } |
| 517 | if (! includeCodas) { |
| 518 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"WeightByPosition"); |
| 519 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), U"*C\\mu"); |
| 520 | } |
| 521 | if (includeCodas) { |
| 522 | for (integercxx . . $ integer# itab = 1; itab <= mycxx . . $ `melder/melder.h:44:9`! numberOfTableauscxx . . $ structOTGrammar#numberOfTableaus.; itab ++) { |
| 523 | OTGrammarTableaucxx . . $ OTGrammarTableau# tableau = & mycxx . . $ `melder/melder.h:44:9`! tableauscxx . . $ structOTGrammar#tableaus. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).itab]; |
| 524 | for (integercxx . . $ integer# icand = 1; icand <= tableau -> numberOfCandidatescxx . . $ structOTGrammarTableau#numberOfCandidates.; icand ++) |
| 525 | replaceOutputcxx . . $ replaceOutput(4f9a5c4cf6c3eb02). (& tableau -> candidatescxx . . $ structOTGrammarTableau#candidates. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icand]); |
| 526 | } |
| 527 | } |
| 528 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 529 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 530 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Metrics grammar not created."); |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | /* End of file OTGrammar_ex_metrics.cpp */ |