| 1 | /* praat_gram.cpp |
| 2 | * |
| 3 | * Copyright (C) 1997-2026 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 3 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 "Network.h" |
| 20 | #include "OTGrammar.h" |
| 21 | #include "OTMulti.h" |
| 22 | #include "OTGrammarEditor.h" |
| 23 | #include "OTMultiEditor.h" |
| 24 | #include "Net.h" |
| 25 | #include "NoulliGridEditor.h" |
| 26 | #include "CubeGridEditor.h" |
| 27 | |
| 28 | #include "praat_TableOfReal.h" |
| 29 | #include "praat_TimeFunction.h" |
| 30 | |
| 31 | // MARK: - NETWORK |
| 32 | |
| 33 | // MARK: New |
| 34 | |
| 35 | #define UiForm_addNetworkFields \ |
| 36 | COMMENT (U"Activity spreading settings:") \ |
| 37 | REAL (spreadingRate, U"Spreading rate", U"0.01") \ |
| 38 | OPTIONMENU_ENUM (kNetwork_activityClippingRule, activityClippingRule, \ |
| 39 | U"Activity clipping rule", kNetwork_activityClippingRule::DEFAULT) \ |
| 40 | REAL (minimumActivity, U"left Activity range", U"0.0") \ |
| 41 | REAL (maximumActivity, U"right Activity range", U"1.0") \ |
| 42 | REAL (activityLeak, U"Activity leak", U"1.0") \ |
| 43 | COMMENT (U"Weight update settings:") \ |
| 44 | REAL (learningRate, U"Learning rate", U"0.1") \ |
| 45 | REAL (minimumWeight, U"left Weight range", U"-1.0") \ |
| 46 | REAL (maximumWeight, U"right Weight range", U"1.0") \ |
| 47 | REAL (weightLeak, U"Weight leak", U"0.0") |
| 48 | |
| 49 | FORM (CREATE_ONE__Create_empty_Network, U"Create empty Network", nullptr) { |
| 50 | WORD (name, U"Name", U"network") |
| 51 | UiForm_addNetworkFields |
| 52 | COMMENT (U"World coordinates:") |
| 53 | REAL (fromX, U"left x range", U"0.0") |
| 54 | REAL (toX, U"right x range", U"10.0") |
| 55 | REAL (fromY, U"left y range", U"0.0") |
| 56 | REAL (toY, U"right y range", U"10.0") |
| 57 | OK |
| 58 | DO |
| 59 | CREATE_ONE |
| 60 | autoNetwork result = Network_create (spreadingRate, activityClippingRule, |
| 61 | minimumActivity, maximumActivity, activityLeak, learningRate, minimumWeight, maximumWeight, weightLeak, |
| 62 | fromX, toX, fromY, toY, 0, 0 |
| 63 | ); |
| 64 | CREATE_ONE_END (name) |
| 65 | } |
| 66 | |
| 67 | FORM (CREATE_ONE__Create_rectangular_Network, U"Create rectangular Network", nullptr) { |
| 68 | UiForm_addNetworkFields |
| 69 | COMMENT (U"Structure settings:") |
| 70 | NATURAL (numberOfRows, U"Number of rows", U"10") |
| 71 | NATURAL (numberOfColumns, U"Number of columns", U"10") |
| 72 | BOOLEAN (bottomRowClamped, U"Bottom row clamped", 1) |
| 73 | COMMENT (U"Initial state settings:") |
| 74 | REAL (minimumInitialWeight, U"left Initial weight range", U"-0.1") |
| 75 | REAL (maximumInitialWeight, U"right Initial weight range", U"0.1") |
| 76 | OK |
| 77 | DO |
| 78 | CREATE_ONE |
| 79 | autoNetwork result = Network_create_rectangle (spreadingRate, activityClippingRule, |
| 80 | minimumActivity, maximumActivity, activityLeak, learningRate, minimumWeight, maximumWeight, weightLeak, |
| 81 | numberOfRows, numberOfColumns, bottomRowClamped, minimumInitialWeight, maximumInitialWeight |
| 82 | ); |
| 83 | CREATE_ONE_END (U"rectangle_", numberOfRows, U"_", numberOfColumns) |
| 84 | } |
| 85 | |
| 86 | FORM (CREATE_ONE__Create_rectangular_Network_vertical, U"Create rectangular Network (vertical)", nullptr) { |
| 87 | UiForm_addNetworkFields |
| 88 | COMMENT (U"Structure settings:") |
| 89 | NATURAL (numberOfRows, U"Number of rows", U"10") |
| 90 | NATURAL (numberOfColumns, U"Number of columns", U"10") |
| 91 | BOOLEAN (bottomRowClamped, U"Bottom row clamped", 1) |
| 92 | COMMENT (U"Initial state settings:") |
| 93 | REAL (minimumInitialWeight, U"left Initial weight range", U"-0.1") |
| 94 | REAL (maximumInitialWeight, U"right Initial weight range", U"0.1") |
| 95 | OK |
| 96 | DO |
| 97 | CREATE_ONE |
| 98 | autoNetwork result = Network_create_rectangle_vertical (spreadingRate, |
| 99 | (kNetwork_activityClippingRule) activityClippingRule, |
| 100 | minimumActivity, maximumActivity, activityLeak, learningRate, minimumWeight, maximumWeight, weightLeak, |
| 101 | numberOfRows, numberOfColumns, bottomRowClamped, minimumInitialWeight, maximumInitialWeight |
| 102 | ); |
| 103 | CREATE_ONE_END (U"rectangle_", numberOfRows, U"_", numberOfColumns) |
| 104 | } |
| 105 | |
| 106 | // MARK: Draw |
| 107 | |
| 108 | FORM (GRAPHICS_EACH__Network_draw, U"Draw Network", nullptr) { |
| 109 | BOOLEAN (useColour, U"Use colour", true) |
| 110 | OK |
| 111 | DO |
| 112 | GRAPHICS_EACH (Network) |
| 113 | Network_draw (me, GRAPHICS, useColour); |
| 114 | GRAPHICS_EACH_END |
| 115 | } |
| 116 | |
| 117 | // MARK: Tabulate |
| 118 | |
| 119 | FORM (INFO_ONE__Network_listNodes, U"Network: List nodes", nullptr) { |
| 120 | INTEGER (fromNodeNumber, U"From node number", U"1") |
| 121 | INTEGER (toNodeNumber, U"To node number", U"1000") |
| 122 | BOOLEAN (includeNodeNumbers, U"Include node numbers", true) |
| 123 | BOOLEAN (includeX, U"Include x", false) |
| 124 | BOOLEAN (includeY, U"Include y", false) |
| 125 | INTEGER (positionDecimals, U"Position decimals", U"6") |
| 126 | BOOLEAN (includeClamped, U"Include clamped", false) |
| 127 | BOOLEAN (includeActivity, U"Include activity", true) |
| 128 | BOOLEAN (includeExcitation, U"Include excitation", false) |
| 129 | INTEGER (activityDecimals, U"Activity decimals", U"6") |
| 130 | OK |
| 131 | DO |
| 132 | INFO_ONE (Network) |
| 133 | Network_listNodes (me, fromNodeNumber, toNodeNumber, |
| 134 | includeNodeNumbers, includeX, includeY, positionDecimals, |
| 135 | includeClamped, includeActivity, includeExcitation, activityDecimals |
| 136 | ); |
| 137 | INFO_ONE_END |
| 138 | } |
| 139 | |
| 140 | FORM (CONVERT_EACH_TO_ONE__Network_nodes_downto_Table, U"Network: Nodes down to Table", nullptr) { |
| 141 | INTEGER (fromNodeNumber, U"From node number", U"1") |
| 142 | INTEGER (toNodeNumber, U"To node number", U"1000") |
| 143 | BOOLEAN (includeNodeNumbers, U"Include node numbers", true) |
| 144 | BOOLEAN (includeX, U"Include x", false) |
| 145 | BOOLEAN (includeY, U"Include y", false) |
| 146 | INTEGER (positionDecimals, U"Position decimals", U"6") |
| 147 | BOOLEAN (includeClamped, U"Include clamped", false) |
| 148 | BOOLEAN (includeActivity, U"Include activity", true) |
| 149 | BOOLEAN (includeExcitation, U"Include excitation", false) |
| 150 | INTEGER (activityDecimals, U"Activity decimals", U"6") |
| 151 | OK |
| 152 | DO |
| 153 | CONVERT_EACH_TO_ONE (Network) |
| 154 | autoTable result = Network_nodes_downto_Table (me, fromNodeNumber, toNodeNumber, |
| 155 | includeNodeNumbers, includeX, includeY, positionDecimals, |
| 156 | includeClamped, includeActivity, includeExcitation, activityDecimals |
| 157 | ); |
| 158 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 159 | } |
| 160 | |
| 161 | // MARK: Query |
| 162 | |
| 163 | FORM (QUERY_ONE_FOR_REAL__Network_getActivity, U"Network: Get activity", nullptr) { |
| 164 | NATURAL (node, U"Node", U"1") |
| 165 | OK |
| 166 | DO |
| 167 | QUERY_ONE_FOR_REAL (Network) |
| 168 | const double result = Network_getActivity (me, node); |
| 169 | QUERY_ONE_FOR_REAL_END (U" (activity of node ", node, U")") |
| 170 | } |
| 171 | |
| 172 | FORM (QUERY_ONE_FOR_REAL_VECTOR__Network_getActivities, U"Network: Get activities", nullptr) { |
| 173 | NATURAL (fromNode, U"From node", U"1") |
| 174 | NATURAL (toNode, U"To node", U"0 (= all)") |
| 175 | OK |
| 176 | DO |
| 177 | QUERY_ONE_FOR_REAL_VECTOR (Network) |
| 178 | autoVEC result = Network_getActivities (me, fromNode, toNode); |
| 179 | QUERY_ONE_FOR_REAL_VECTOR_END |
| 180 | } |
| 181 | |
| 182 | FORM (QUERY_ONE_FOR_REAL__Network_getWeight, U"Network: Get weight", nullptr) { |
| 183 | NATURAL (connection, U"Connection", U"1") |
| 184 | OK |
| 185 | DO |
| 186 | QUERY_ONE_FOR_REAL (Network) |
| 187 | const double result = Network_getWeight (me, connection); |
| 188 | QUERY_ONE_FOR_REAL_END (U" (weight of connection ", connection, U")") |
| 189 | } |
| 190 | |
| 191 | // MARK: Modify |
| 192 | |
| 193 | FORM (MODIFY_EACH__Network_addConnection, U"Network: Add connection", nullptr) { |
| 194 | NATURAL (fromNode, U"From node", U"1") |
| 195 | NATURAL (toNode, U"To node", U"2") |
| 196 | REAL (weight, U"Weight", U"0.0") |
| 197 | REAL (plasticity, U"Plasticity", U"1.0") |
| 198 | OK |
| 199 | DO |
| 200 | MODIFY_EACH (Network) |
| 201 | Network_addConnection (me, fromNode, toNode, weight, plasticity); |
| 202 | MODIFY_EACH_END |
| 203 | } |
| 204 | |
| 205 | FORM (MODIFY_EACH__Network_addNode, U"Network: Add node", nullptr) { |
| 206 | REAL (x, U"x", U"5.0") |
| 207 | REAL (y, U"y", U"5.0") |
| 208 | REAL (activity, U"Activity", U"0.0") |
| 209 | BOOLEAN (clamping, U"Clamping", false) |
| 210 | OK |
| 211 | DO |
| 212 | MODIFY_EACH (Network) |
| 213 | Network_addNode (me, x, y, activity, clamping); |
| 214 | MODIFY_EACH_END |
| 215 | } |
| 216 | |
| 217 | FORM (MODIFY_EACH__Network_normalizeActivities, U"Network: Normalize activities", nullptr) { |
| 218 | INTEGER (fromNode, U"From node", U"1") |
| 219 | INTEGER (toNode, U"To node", U"0 (= all)") |
| 220 | OK |
| 221 | DO |
| 222 | MODIFY_EACH (Network) |
| 223 | Network_normalizeActivities (me, fromNode, toNode); |
| 224 | MODIFY_EACH_END |
| 225 | } |
| 226 | |
| 227 | FORM (MODIFY_EACH__Network_normalizeWeights, U"Network: Normalize weights", nullptr) { |
| 228 | INTEGER (fromNode, U"From node", U"1") |
| 229 | INTEGER (toNode, U"To node", U"0 (= all)") |
| 230 | INTEGER (fromIncomingNode, U"From incoming node", U"1") |
| 231 | INTEGER (toIncomingNode, U"To incoming node", U"10") |
| 232 | REAL (newSum, U"New sum", U"1.0") |
| 233 | OK |
| 234 | DO |
| 235 | MODIFY_EACH (Network) |
| 236 | Network_normalizeWeights (me, fromNode, toNode, fromIncomingNode, toIncomingNode, newSum); |
| 237 | MODIFY_EACH_END |
| 238 | } |
| 239 | |
| 240 | FORM (MODIFY_EACH__Network_setActivity, U"Network: Set activity", nullptr) { |
| 241 | NATURAL (node, U"Node", U"1") |
| 242 | REAL (activity, U"Activity", U"1.0") |
| 243 | OK |
| 244 | DO |
| 245 | MODIFY_EACH (Network) |
| 246 | Network_setActivity (me, node, activity); |
| 247 | MODIFY_EACH_END |
| 248 | } |
| 249 | |
| 250 | FORM (MODIFY_EACH_WEAK__Network_formula_activities, U"Network: Formula (activities)", nullptr) { |
| 251 | INTEGER (fromNode, U"From node", U"1") |
| 252 | INTEGER (toNode, U"To node", U"0 (= all)") |
| 253 | COMMENT (U"`col` is the node number, `self` is the current activity") |
| 254 | COMMENT (U"for col := 1 to ncol do { self [col] := `formula' }") |
| 255 | FORMULA (formula, U"Formula", U"0") |
| 256 | OK |
| 257 | DO |
| 258 | MODIFY_EACH_WEAK (Network) |
| 259 | Network_formula_activities (me, fromNode, toNode, formula, interpreter); |
| 260 | MODIFY_EACH_WEAK_END |
| 261 | } |
| 262 | |
| 263 | FORM (MODIFY_EACH__Network_setActivityClippingRule, U"Network: Set activity clipping rule", nullptr) { |
| 264 | CHOICE_ENUM (kNetwork_activityClippingRule, activityClippingRule, |
| 265 | U"Activity clipping rule", kNetwork_activityClippingRule::DEFAULT) |
| 266 | OK |
| 267 | DO |
| 268 | MODIFY_EACH (Network) |
| 269 | Network_setActivityClippingRule (me, activityClippingRule); |
| 270 | MODIFY_EACH_END |
| 271 | } |
| 272 | |
| 273 | FORM (MODIFY_EACH__Network_setActivityLeak, U"Network: Set activity leak", nullptr) { |
| 274 | REAL (activityLeak, U"Activity leak", U"1.0") |
| 275 | OK |
| 276 | DO |
| 277 | MODIFY_EACH (Network) |
| 278 | Network_setActivityLeak (me, activityLeak); |
| 279 | MODIFY_EACH_END |
| 280 | } |
| 281 | |
| 282 | FORM (MODIFY_EACH__Network_setClamping, U"Network: Set clamping", nullptr) { |
| 283 | NATURAL (node, U"Node", U"1") |
| 284 | BOOLEAN (clamping, U"Clamping", true) |
| 285 | OK |
| 286 | DO |
| 287 | MODIFY_EACH (Network) |
| 288 | Network_setClamping (me, node, clamping); |
| 289 | MODIFY_EACH_END |
| 290 | } |
| 291 | |
| 292 | FORM (MODIFY_EACH__Network_setInstar, U"Network: Set instar", nullptr) { |
| 293 | REAL (instar, U"Instar", U"0.0") |
| 294 | OK |
| 295 | DO |
| 296 | MODIFY_EACH (Network) |
| 297 | Network_setInstar (me, instar); |
| 298 | MODIFY_EACH_END |
| 299 | } |
| 300 | |
| 301 | FORM (MODIFY_EACH__Network_setWeightLeak, U"Network: Set weight leak", nullptr) { |
| 302 | REAL (weightLeak, U"Weight leak", U"0.0") |
| 303 | OK |
| 304 | DO |
| 305 | MODIFY_EACH (Network) |
| 306 | Network_setWeightLeak (me, weightLeak); |
| 307 | MODIFY_EACH_END |
| 308 | } |
| 309 | |
| 310 | FORM (MODIFY_EACH__Network_setOutstar, U"Network: Set outstar", nullptr) { |
| 311 | REAL (outstar, U"Outstar", U"0.0") |
| 312 | OK |
| 313 | DO |
| 314 | MODIFY_EACH (Network) |
| 315 | Network_setOutstar (me, outstar); |
| 316 | MODIFY_EACH_END |
| 317 | } |
| 318 | |
| 319 | FORM (MODIFY_EACH__Network_setShunting, U"Network: Set shunting", nullptr) { |
| 320 | REAL (shunting, U"Shunting", U"1.0") |
| 321 | OK |
| 322 | DO |
| 323 | MODIFY_EACH (Network) |
| 324 | Network_setShunting (me, shunting); |
| 325 | MODIFY_EACH_END |
| 326 | } |
| 327 | |
| 328 | FORM (MODIFY_EACH__Network_setWeight, U"Network: Set weight", nullptr) { |
| 329 | NATURAL (connection, U"Connection", U"1") |
| 330 | REAL (weight, U"Weight", U"1.0") |
| 331 | OK |
| 332 | DO |
| 333 | MODIFY_EACH (Network) |
| 334 | Network_setWeight (me, connection, weight); |
| 335 | MODIFY_EACH_END |
| 336 | } |
| 337 | |
| 338 | FORM (MODIFY_EACH__Network_spreadActivities, U"Network: Spread activities", nullptr) { |
| 339 | NATURAL (numberOfSteps, U"Number of steps", U"20") |
| 340 | OK |
| 341 | DO |
| 342 | MODIFY_EACH (Network) |
| 343 | Network_spreadActivities (me, numberOfSteps); |
| 344 | MODIFY_EACH_END |
| 345 | } |
| 346 | |
| 347 | DIRECT (MODIFY_EACH__Network_updateWeights) { |
| 348 | MODIFY_EACH (Network) |
| 349 | Network_updateWeights (me); |
| 350 | MODIFY_EACH_END |
| 351 | } |
| 352 | |
| 353 | FORM (MODIFY_EACH__Network_zeroActivities, U"Network: Zero activities", nullptr) { |
| 354 | INTEGER (fromNode, U"From node", U"1") |
| 355 | INTEGER (toNode, U"To node", U"0 (= all)") |
| 356 | OK |
| 357 | DO |
| 358 | MODIFY_EACH (Network) |
| 359 | Network_zeroActivities (me, fromNode, toNode); |
| 360 | MODIFY_EACH_END |
| 361 | } |
| 362 | |
| 363 | // MARK: - OTGRAMMAR |
| 364 | |
| 365 | // MARK: New |
| 366 | |
| 367 | DIRECT (HELP__OT_learning_tutorial) { |
| 368 | HELP (U"OT learning") |
| 369 | } |
| 370 | |
| 371 | DIRECT (CREATE_ONE__Create_NoCoda_grammar) { |
| 372 | CREATE_ONE |
| 373 | autoOTGrammar result = OTGrammar_create_NoCoda_grammar (); |
| 374 | CREATE_ONE_END (U"NoCoda") |
| 375 | } |
| 376 | |
| 377 | DIRECT (CREATE_ONE__Create_NPA_grammar) { |
| 378 | CREATE_ONE |
| 379 | autoOTGrammar result = OTGrammar_create_NPA_grammar (); |
| 380 | CREATE_ONE_END (U"assimilation") |
| 381 | } |
| 382 | |
| 383 | DIRECT (CREATE_ONE__Create_NPA_distribution) { |
| 384 | CREATE_ONE |
| 385 | autoPairDistribution result = OTGrammar_create_NPA_distribution (); |
| 386 | CREATE_ONE_END (U"assimilation") |
| 387 | } |
| 388 | |
| 389 | FORM (CREATE_ONE__Create_tongue_root_grammar, U"Create tongue-root grammar", U"Create tongue-root grammar...") { |
| 390 | CHOICE_ENUM (kOTGrammar_createTongueRootGrammar_constraintSet, constraintSet, |
| 391 | U"Constraint set", kOTGrammar_createTongueRootGrammar_constraintSet::DEFAULT) |
| 392 | CHOICE_ENUM (kOTGrammar_createTongueRootGrammar_ranking, ranking, |
| 393 | U"Ranking", kOTGrammar_createTongueRootGrammar_ranking::DEFAULT) |
| 394 | OK |
| 395 | DO |
| 396 | CREATE_ONE |
| 397 | autoOTGrammar result = OTGrammar_create_tongueRoot_grammar (constraintSet, ranking); |
| 398 | CREATE_ONE_END (kOTGrammar_createTongueRootGrammar_ranking_getText (ranking)) |
| 399 | } |
| 400 | |
| 401 | FORM (CREATE_ONE__Create_metrics_grammar, U"Create metrics grammar", nullptr) { |
| 402 | OPTIONMENU_ENUM (kOTGrammar_createMetricsGrammar_initialRanking, initialRanking, |
| 403 | U"Initial ranking", kOTGrammar_createMetricsGrammar_initialRanking::DEFAULT) |
| 404 | OPTIONMENU (trochaicityConstraint, U"Trochaicity constraint", 1) |
| 405 | OPTION (U"FtNonfinal") |
| 406 | OPTION (U"Trochaic") |
| 407 | BOOLEAN (includeFootBimoraic, U"Include FootBimoraic", false) |
| 408 | BOOLEAN (includeFootBisyllabic, U"Include FootBisyllabic", false) |
| 409 | BOOLEAN (includePeripheral, U"Include Peripheral", false) |
| 410 | OPTIONMENU (nonfinalityConstraint, U"Nonfinality constraint", 1) |
| 411 | OPTION (U"Nonfinal") |
| 412 | OPTION (U"MainNonfinal") |
| 413 | OPTION (U"HeadNonfinal") |
| 414 | BOOLEAN (overtFormsHaveSecondaryStress, U"Overt forms have secondary stress", true) |
| 415 | BOOLEAN (includeClashAndLapse, U"Include *Clash and *Lapse", false) |
| 416 | BOOLEAN (includeCodas, U"Include codas", false) |
| 417 | OK |
| 418 | DO |
| 419 | CREATE_ONE |
| 420 | autoOTGrammar result = OTGrammar_create_metrics (initialRanking, trochaicityConstraint, |
| 421 | includeFootBimoraic, includeFootBisyllabic, includePeripheral, nonfinalityConstraint, |
| 422 | overtFormsHaveSecondaryStress, includeClashAndLapse, includeCodas |
| 423 | ); |
| 424 | CREATE_ONE_END (kOTGrammar_createMetricsGrammar_initialRanking_getText (initialRanking)) |
| 425 | } |
| 426 | |
| 427 | // MARK: Save |
| 428 | |
| 429 | FORM_SAVE (SAVE_ONE__OTGrammar_writeToHeaderlessSpreadsheetFile, U"Write OTGrammar to spreadsheet", 0, U"txt") { |
| 430 | SAVE_ONE (OTGrammar, U"save the selected OTGrammar object to the spreadsheet file") |
| 431 | OTGrammar_writeToHeaderlessSpreadsheetFile (me, file); |
| 432 | SAVE_ONE_END |
| 433 | } |
| 434 | |
| 435 | // MARK: Help |
| 436 | |
| 437 | DIRECT (HELP__OTGrammar_help) { |
| 438 | HELP (U"OTGrammar") |
| 439 | } |
| 440 | |
| 441 | // MARK: View & Edit |
| 442 | |
| 443 | DIRECT (EDITOR_ONE__OTGrammar_viewAndEdit) { |
| 444 | EDITOR_ONE (an,OTGrammar) |
| 445 | autoOTGrammarEditor editor = OTGrammarEditor_create (ID_AND_FULL_NAME, me); |
| 446 | EDITOR_ONE_END |
| 447 | } |
| 448 | |
| 449 | // MARK: Draw |
| 450 | |
| 451 | FORM (GRAPHICS_EACH__OTGrammar_drawTableau, U"Draw tableau", U"OT learning") { |
| 452 | SENTENCE (inputString, U"Input string", U"") |
| 453 | OK |
| 454 | DO |
| 455 | GRAPHICS_EACH (OTGrammar) |
| 456 | OTGrammar_drawTableau (me, GRAPHICS, false, inputString); |
| 457 | GRAPHICS_EACH_END |
| 458 | } |
| 459 | |
| 460 | FORM (GRAPHICS_EACH__OTGrammar_drawTableau_narrowly, U"Draw tableau (narrowly)", U"OT learning") { |
| 461 | SENTENCE (inputString, U"Input string", U"") |
| 462 | OK |
| 463 | DO |
| 464 | GRAPHICS_EACH (OTGrammar) |
| 465 | OTGrammar_drawTableau (me, GRAPHICS, true, inputString); |
| 466 | GRAPHICS_EACH_END |
| 467 | } |
| 468 | |
| 469 | // MARK: Query |
| 470 | |
| 471 | DIRECT (QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfConstraints) { |
| 472 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 473 | const integer result = my numberOfConstraints; |
| 474 | QUERY_ONE_FOR_INTEGER_END (U" constraints") |
| 475 | } |
| 476 | |
| 477 | FORM (QUERY_ONE_FOR_STRING__OTGrammar_getConstraint, U"Get constraint name", nullptr) { |
| 478 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 479 | OK |
| 480 | DO |
| 481 | QUERY_ONE_FOR_STRING (OTGrammar) |
| 482 | my checkConstraintNumber (constraintNumber); |
| 483 | const conststring32 result = my constraints [constraintNumber]. name.get(); |
| 484 | QUERY_ONE_FOR_STRING_END |
| 485 | } |
| 486 | |
| 487 | FORM (QUERY_ONE_FOR_REAL__OTGrammar_getRankingValue, U"Get ranking value", nullptr) { |
| 488 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 489 | OK |
| 490 | DO |
| 491 | QUERY_ONE_FOR_REAL (OTGrammar) |
| 492 | my checkConstraintNumber (constraintNumber); |
| 493 | const double result = my constraints [constraintNumber]. ranking; |
| 494 | QUERY_ONE_FOR_REAL_END (U" (ranking of constraint ", constraintNumber, U")") |
| 495 | } |
| 496 | |
| 497 | FORM (QUERY_ONE_FOR_REAL__OTGrammar_getDisharmony, U"Get disharmony", nullptr) { |
| 498 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 499 | OK |
| 500 | DO |
| 501 | QUERY_ONE_FOR_REAL (OTGrammar) |
| 502 | my checkConstraintNumber (constraintNumber); |
| 503 | const double result = my constraints [constraintNumber]. disharmony; |
| 504 | QUERY_ONE_FOR_REAL_END (U" (disharmony of constraint ", constraintNumber, U")") |
| 505 | } |
| 506 | |
| 507 | DIRECT (QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfTableaus) { |
| 508 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 509 | const integer result = my numberOfTableaus; |
| 510 | QUERY_ONE_FOR_INTEGER_END (U" tableaus") |
| 511 | } |
| 512 | |
| 513 | FORM (QUERY_ONE_FOR_STRING__OTGrammar_getInput, U"Get input", nullptr) { |
| 514 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 515 | OK |
| 516 | DO |
| 517 | QUERY_ONE_FOR_STRING (OTGrammar) |
| 518 | my checkTableauNumber (tableauNumber); |
| 519 | const conststring32 result = my tableaus [tableauNumber]. input.get(); |
| 520 | QUERY_ONE_FOR_STRING_END |
| 521 | } |
| 522 | |
| 523 | FORM (QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfCandidates, U"Get number of candidates", nullptr) { |
| 524 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 525 | OK |
| 526 | DO |
| 527 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 528 | my checkTableauNumber (tableauNumber); |
| 529 | const integer result = my tableaus [tableauNumber]. numberOfCandidates; |
| 530 | QUERY_ONE_FOR_INTEGER_END (U" candidates in tableau ", tableauNumber) |
| 531 | } |
| 532 | |
| 533 | FORM (QUERY_ONE_FOR_STRING__OTGrammar_getCandidate, U"Get candidate", nullptr) { |
| 534 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 535 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 536 | OK |
| 537 | DO |
| 538 | QUERY_ONE_FOR_STRING (OTGrammar) |
| 539 | my checkTableauAndCandidateNumber (tableauNumber, candidateNumber); |
| 540 | const conststring32 result = my tableaus [tableauNumber]. candidates [candidateNumber]. output.get(); |
| 541 | QUERY_ONE_FOR_STRING_END |
| 542 | } |
| 543 | |
| 544 | FORM (QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfViolations, U"Get number of violations", nullptr) { |
| 545 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 546 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 547 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 548 | OK |
| 549 | DO |
| 550 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 551 | my checkTableauAndCandidateNumber (tableauNumber, candidateNumber); |
| 552 | my checkConstraintNumber (constraintNumber); |
| 553 | const integer result = my tableaus [tableauNumber]. candidates [candidateNumber]. marks [constraintNumber]; |
| 554 | QUERY_ONE_FOR_INTEGER_END (U" violations") |
| 555 | } |
| 556 | |
| 557 | DIRECT (QUERY_ONE_FOR_BOOLEAN__OTGrammar_areAllOutputsDistinguishable) { |
| 558 | QUERY_ONE_FOR_BOOLEAN (OTGrammar) |
| 559 | const integer result = OTGrammar_areAllOutputsDistinguishable (me); |
| 560 | QUERY_ONE_FOR_BOOLEAN_END (result ? U" (all pairs are distinguishable)" : U" (at least one equivalent pair)") |
| 561 | } |
| 562 | |
| 563 | DIRECT (CONVERT_EACH_TO_ONE_OTGrammar_tabulateEquivalentPairs) { |
| 564 | CONVERT_EACH_TO_ONE (OTGrammar) |
| 565 | autoTable result = OTGrammar_tabulateEquivalentPairs (me); |
| 566 | CONVERT_EACH_TO_ONE_END (my name.get()) |
| 567 | } |
| 568 | |
| 569 | // MARK: Query (parse) |
| 570 | |
| 571 | FORM (QUERY_ONE_FOR_INTEGER__OTGrammar_getWinner, U"Get winner", nullptr) { |
| 572 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 573 | OK |
| 574 | DO |
| 575 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 576 | my checkTableauNumber (tableauNumber); |
| 577 | const integer result = OTGrammar_getWinner (me, tableauNumber); |
| 578 | QUERY_ONE_FOR_INTEGER_END (U" (winner in tableau ", tableauNumber, U")") |
| 579 | } |
| 580 | |
| 581 | FORM (QUERY_ONE_FOR_INTEGER__OTGrammar_compareCandidates, U"Compare candidates", nullptr) { |
| 582 | NATURAL (tableauNumber1, U"Tableau number 1", U"1") |
| 583 | NATURAL (candidateNumber1, U"Candidate number 1", U"1") |
| 584 | NATURAL (tableauNumber2, U"Tableau number 2", U"1") |
| 585 | NATURAL (candidateNumber2, U"Candidate number 2", U"2") |
| 586 | OK |
| 587 | DO |
| 588 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 589 | my checkTableauAndCandidateNumber (tableauNumber1, candidateNumber1); |
| 590 | my checkTableauAndCandidateNumber (tableauNumber2, candidateNumber2); |
| 591 | const integer result = OTGrammar_compareCandidates (me, tableauNumber1, candidateNumber1, tableauNumber2, candidateNumber2); |
| 592 | QUERY_ONE_FOR_INTEGER_END (result == -1 ? U" (candidate 1 is better)" : |
| 593 | result == +1 ? U" (candidate 2 is better)" : U" (candidates are equally good)") |
| 594 | } |
| 595 | |
| 596 | FORM (QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfOptimalCandidates, U"Get number of optimal candidates", nullptr) { |
| 597 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 598 | OK |
| 599 | DO |
| 600 | QUERY_ONE_FOR_INTEGER (OTGrammar) |
| 601 | my checkTableauNumber (tableauNumber); |
| 602 | const integer result = OTGrammar_getNumberOfOptimalCandidates (me, tableauNumber); |
| 603 | QUERY_ONE_FOR_INTEGER_END (U" optimal candidates in tableau ", tableauNumber) |
| 604 | } |
| 605 | |
| 606 | FORM (QUERY_ONE_FOR_BOOLEAN__OTGrammar_isCandidateGrammatical, U"Is candidate grammatical?", nullptr) { |
| 607 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 608 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 609 | OK |
| 610 | DO |
| 611 | QUERY_ONE_FOR_BOOLEAN (OTGrammar) |
| 612 | my checkTableauAndCandidateNumber (tableauNumber, candidateNumber); |
| 613 | const integer result = OTGrammar_isCandidateGrammatical (me, tableauNumber, candidateNumber); |
| 614 | QUERY_ONE_FOR_BOOLEAN_END (result ? U" (grammatical)" : U" (ungrammatical)") |
| 615 | } |
| 616 | |
| 617 | FORM (QUERY_ONE_FOR_BOOLEAN__OTGrammar_isCandidateSinglyGrammatical, U"Is candidate singly grammatical?", nullptr) { |
| 618 | NATURAL (tableauNumber, U"Tableau number", U"1") |
| 619 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 620 | OK |
| 621 | DO |
| 622 | QUERY_ONE_FOR_BOOLEAN (OTGrammar) |
| 623 | my checkTableauAndCandidateNumber (tableauNumber, candidateNumber); |
| 624 | const integer result = OTGrammar_isCandidateSinglyGrammatical (me, tableauNumber, candidateNumber); |
| 625 | QUERY_ONE_FOR_BOOLEAN_END (result ? U" (singly grammatical)" : U" (not singly grammatical)") |
| 626 | } |
| 627 | |
| 628 | FORM (INFO_ONE__OTGrammar_getInterpretiveParse, U"OTGrammar: Interpretive parse", nullptr) { |
| 629 | SENTENCE (partialOutput, U"Partial output", U"") |
| 630 | OK |
| 631 | DO |
| 632 | INFO_ONE (OTGrammar) |
| 633 | integer bestInput, bestOutput; |
| 634 | OTGrammar_getInterpretiveParse (me, partialOutput, & bestInput, & bestOutput); |
| 635 | Melder_information (U"Best input = ", bestInput, U": ", my tableaus [bestInput]. input.get(), |
| 636 | U"\nBest output = ", bestOutput, U": ", my tableaus [bestInput]. candidates [bestOutput]. output.get()); |
| 637 | INFO_ONE_END |
| 638 | } |
| 639 | |
| 640 | FORM (QUERY_ONE_FOR_BOOLEAN__OTGrammar_isPartialOutputGrammatical, U"Is partial output grammatical?", nullptr) { |
| 641 | SENTENCE (partialOutput, U"Partial output", U"") |
| 642 | OK |
| 643 | DO |
| 644 | QUERY_ONE_FOR_BOOLEAN (OTGrammar) |
| 645 | const integer result = OTGrammar_isPartialOutputGrammatical (me, partialOutput); |
| 646 | QUERY_ONE_FOR_BOOLEAN_END (result ? U" (grammatical)" : U" (ungrammatical)") |
| 647 | } |
| 648 | |
| 649 | FORM (QUERY_ONE_FOR_BOOLEAN__OTGrammar_isPartialOutputSinglyGrammatical, U"Is partial output singly grammatical?", nullptr) { |
| 650 | SENTENCE (partialOutput, U"Partial output", U"") |
| 651 | OK |
| 652 | DO |
| 653 | QUERY_ONE_FOR_BOOLEAN (OTGrammar) |
| 654 | const integer result = OTGrammar_isPartialOutputSinglyGrammatical (me, partialOutput); |
| 655 | QUERY_ONE_FOR_BOOLEAN_END (result ? U" (singly grammatical)" : U" (not singly grammatical)") |
| 656 | } |
| 657 | |
| 658 | // MARK: - |
| 659 | |
| 660 | FORM (CONVERT_EACH_TO_ONE__OTGrammar_generateInputs, U"Generate inputs", U"OTGrammar: Generate inputs...") { |
| 661 | NATURAL (numberOfTrials, U"Number of trials", U"1000") |
| 662 | OK |
| 663 | DO |
| 664 | CONVERT_EACH_TO_ONE (OTGrammar) |
| 665 | autoStrings result = OTGrammar_generateInputs (me, numberOfTrials); |
| 666 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_in") |
| 667 | } |
| 668 | |
| 669 | DIRECT (CONVERT_EACH_TO_ONE__OTGrammar_getInputs) { |
| 670 | CONVERT_EACH_TO_ONE (OTGrammar) |
| 671 | autoStrings result = OTGrammar_getInputs (me); |
| 672 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_in") |
| 673 | } |
| 674 | |
| 675 | DIRECT (CONVERT_EACH_WEAK_TO_ONE__OTGrammar_measureTypology) { |
| 676 | CONVERT_EACH_WEAK_TO_ONE (OTGrammar) |
| 677 | autoDistributions result = OTGrammar_measureTypology_WEAK (me); |
| 678 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 679 | } |
| 680 | |
| 681 | // MARK: Evaluate |
| 682 | |
| 683 | FORM (MODIFY_EACH__OTGrammar_evaluate, U"OTGrammar: Evaluate", nullptr) { |
| 684 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 685 | OK |
| 686 | DO |
| 687 | MODIFY_EACH (OTGrammar) |
| 688 | OTGrammar_newDisharmonies (me, evaluationNoise); |
| 689 | MODIFY_EACH_END |
| 690 | } |
| 691 | |
| 692 | FORM (QUERY_ONE_WEAK_FOR_STRING__OTGrammar_inputToOutput, U"OTGrammar: Input to output", U"OTGrammar: Input to output...") { |
| 693 | SENTENCE (inputForm, U"Input form", U"") |
| 694 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 695 | OK |
| 696 | DO |
| 697 | QUERY_ONE_WEAK_FOR_STRING (OTGrammar) |
| 698 | autostring32 output = OTGrammar_inputToOutput (me, inputForm, evaluationNoise); |
| 699 | conststring32 result = output.get(); |
| 700 | QUERY_ONE_WEAK_FOR_STRING_END |
| 701 | } |
| 702 | |
| 703 | FORM (CONVERT_EACH_WEAK_TO_ONE__OTGrammar_inputToOutputs, U"OTGrammar: Input to outputs", U"OTGrammar: Input to outputs...") { |
| 704 | NATURAL (trials, U"Trials", U"1000") |
| 705 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 706 | SENTENCE (inputForm, U"Input form", U"") |
| 707 | OK |
| 708 | DO |
| 709 | CONVERT_EACH_WEAK_TO_ONE (OTGrammar) |
| 710 | autoStrings result = OTGrammar_inputToOutputs (me, inputForm, trials, evaluationNoise); |
| 711 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 712 | } |
| 713 | |
| 714 | FORM (CONVERT_EACH_WEAK_TO_ONE__OTGrammar_to_Distributions, U"OTGrammar: Compute output distributions", U"OTGrammar: To output Distributions...") { |
| 715 | NATURAL (trialsPerInput, U"Trials per input", U"100000") |
| 716 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 717 | OK |
| 718 | DO |
| 719 | CONVERT_EACH_WEAK_TO_ONE (OTGrammar) |
| 720 | autoDistributions result = OTGrammar_to_Distribution (me, trialsPerInput, evaluationNoise); |
| 721 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 722 | } |
| 723 | |
| 724 | FORM (CONVERT_EACH_WEAK_TO_ONE__OTGrammar_to_PairDistribution, U"OTGrammar: Compute output distributions", nullptr) { |
| 725 | NATURAL (trialsPerInput, U"Trials per input", U"100000") |
| 726 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 727 | OK |
| 728 | DO |
| 729 | CONVERT_EACH_WEAK_TO_ONE (OTGrammar) |
| 730 | autoPairDistribution result = OTGrammar_to_PairDistribution (me, trialsPerInput, evaluationNoise); |
| 731 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 732 | } |
| 733 | |
| 734 | // MARK: Modify ranking |
| 735 | |
| 736 | FORM (MODIFY_EACH__OTGrammar_setRanking, U"OTGrammar: Set ranking", nullptr) { |
| 737 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 738 | REAL (ranking, U"Ranking", U"100.0") |
| 739 | REAL (disharmony, U"Disharmony", U"100.0") |
| 740 | OK |
| 741 | DO |
| 742 | MODIFY_EACH (OTGrammar) |
| 743 | OTGrammar_setRanking (me, constraintNumber, ranking, disharmony); |
| 744 | MODIFY_EACH_END |
| 745 | } |
| 746 | |
| 747 | FORM (MODIFY_EACH__OTGrammar_resetAllRankings, U"OTGrammar: Reset all rankings", nullptr) { |
| 748 | REAL (ranking, U"Ranking", U"100.0") |
| 749 | OK |
| 750 | DO |
| 751 | MODIFY_EACH (OTGrammar) |
| 752 | OTGrammar_reset (me, ranking); |
| 753 | MODIFY_EACH_END |
| 754 | } |
| 755 | |
| 756 | FORM (MODIFY_EACH__OTGrammar_resetToRandomRanking, U"OTGrammar: Reset to random ranking", nullptr) { |
| 757 | REAL (mean, U"Mean", U"10.0") |
| 758 | POSITIVE (standardDeviation, U"Standard deviation", U"1e-4") |
| 759 | OK |
| 760 | DO |
| 761 | MODIFY_EACH (OTGrammar) |
| 762 | OTGrammar_resetToRandomRanking (me, mean, standardDeviation); |
| 763 | MODIFY_EACH_END |
| 764 | } |
| 765 | |
| 766 | FORM (MODIFY_EACH__OTGrammar_resetToRandomTotalRanking, U"OTGrammar: Reset to random total ranking", nullptr) { |
| 767 | REAL (maximumRanking, U"Maximum ranking", U"100.0") |
| 768 | POSITIVE (rankingDistance, U"Ranking distance", U"1.0") |
| 769 | OK |
| 770 | DO |
| 771 | MODIFY_EACH (OTGrammar) |
| 772 | OTGrammar_resetToRandomTotalRanking (me, maximumRanking, rankingDistance); |
| 773 | MODIFY_EACH_END |
| 774 | } |
| 775 | |
| 776 | FORM (MODIFY_EACH_WEAK__OTGrammar_learnOne, U"OTGrammar: Learn one", U"OTGrammar: Learn one...") { |
| 777 | SENTENCE (inputString, U"Input string", U"") |
| 778 | SENTENCE (outputString, U"Output string", U"") |
| 779 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 780 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 781 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 782 | REAL (plasticity, U"Plasticity", U"0.1") |
| 783 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 784 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 785 | OK |
| 786 | DO |
| 787 | MODIFY_EACH_WEAK (OTGrammar) |
| 788 | OTGrammar_learnOne (me, inputString, outputString, evaluationNoise, updateRule, honourLocalRankings, |
| 789 | plasticity, relativePlasticitySpreading, true, true, nullptr); |
| 790 | MODIFY_EACH_WEAK_END |
| 791 | } |
| 792 | |
| 793 | FORM (MODIFY_EACH_WEAK__OTGrammar_learnOneFromPartialOutput, U"OTGrammar: Learn one from partial adult output", nullptr) { |
| 794 | COMMENT (U"Partial adult surface form (e.g. overt form):") |
| 795 | SENTENCE (partialOutput, U"Partial output", U"") |
| 796 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 797 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 798 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 799 | REAL (plasticity, U"Plasticity", U"0.1") |
| 800 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 801 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 802 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 803 | OK |
| 804 | DO |
| 805 | MODIFY_EACH_WEAK (OTGrammar) |
| 806 | OTGrammar_learnOneFromPartialOutput (me, partialOutput, evaluationNoise, updateRule, honourLocalRankings, |
| 807 | plasticity, relativePlasticitySpreading, numberOfChews, true); |
| 808 | MODIFY_EACH_WEAK_END |
| 809 | } |
| 810 | |
| 811 | // MARK: Modify behaviour |
| 812 | |
| 813 | FORM (MODIFY_EACH__OTGrammar_setDecisionStrategy, U"OTGrammar: Set decision strategy", nullptr) { |
| 814 | CHOICE_ENUM (kOTGrammar_decisionStrategy, decisionStrategy, |
| 815 | U"Decision strategy", kOTGrammar_decisionStrategy::DEFAULT) |
| 816 | OK |
| 817 | FIND_ONE (OTGrammar) |
| 818 | SET_ENUM (decisionStrategy, kOTGrammar_decisionStrategy, my decisionStrategy); |
| 819 | DO |
| 820 | MODIFY_EACH (OTGrammar) |
| 821 | my decisionStrategy = decisionStrategy; |
| 822 | MODIFY_EACH_END |
| 823 | } |
| 824 | |
| 825 | FORM (MODIFY_EACH__OTGrammar_setLeak, U"OTGrammar: Set leak", nullptr) { |
| 826 | REAL (leak, U"Leak", U"0.0") |
| 827 | OK |
| 828 | FIND_ONE (OTGrammar) |
| 829 | SET_REAL (leak, my leak) |
| 830 | DO |
| 831 | MODIFY_EACH (OTGrammar) |
| 832 | my leak = leak; |
| 833 | MODIFY_EACH_END |
| 834 | } |
| 835 | |
| 836 | FORM (MODIFY_EACH__OTGrammar_setConstraintPlasticity, U"OTGrammar: Set constraint plasticity", nullptr) { |
| 837 | NATURAL (constraint, U"Constraint", U"1") |
| 838 | REAL (plasticity, U"Plasticity", U"1.0") |
| 839 | OK |
| 840 | DO |
| 841 | MODIFY_EACH (OTGrammar) |
| 842 | OTGrammar_setConstraintPlasticity (me, constraint, plasticity); |
| 843 | MODIFY_EACH_END |
| 844 | } |
| 845 | |
| 846 | // MARK: Modify structure |
| 847 | |
| 848 | FORM (MODIFY_EACH__OTGrammar_removeConstraint, U"OTGrammar: Remove constraint", nullptr) { |
| 849 | SENTENCE (constraintName, U"Constraint name", U"") |
| 850 | OK |
| 851 | DO |
| 852 | MODIFY_EACH (OTGrammar) |
| 853 | OTGrammar_removeConstraint (me, constraintName); |
| 854 | MODIFY_EACH_END |
| 855 | } |
| 856 | |
| 857 | FORM (MODIFY_EACH__OTGrammar_removeHarmonicallyBoundedCandidates, U"OTGrammar: Remove harmonically bounded candidates", nullptr) { |
| 858 | BOOLEAN (singly, U"Singly", false) |
| 859 | OK |
| 860 | DO |
| 861 | MODIFY_EACH (OTGrammar) |
| 862 | OTGrammar_removeHarmonicallyBoundedCandidates (me, singly); // strong exception guarantee (2021-05-05) |
| 863 | MODIFY_EACH_END |
| 864 | } |
| 865 | |
| 866 | // MARK: OTGRAMMAR & STRINGS |
| 867 | |
| 868 | FORM (CONVERT_ONE_WEAK_AND_ONE_TO_ONE__OTGrammar_Strings_inputsToOutputs, U"OTGrammar: Inputs to outputs", U"OTGrammar: Inputs to outputs...") { |
| 869 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 870 | OK |
| 871 | DO |
| 872 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE (OTGrammar, Strings) |
| 873 | autoStrings result = OTGrammar_inputsToOutputs (me, you, evaluationNoise); |
| 874 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE_END (my name.get(), U"_out") |
| 875 | } |
| 876 | |
| 877 | DIRECT (QUERY_ONE_AND_ONE_FOR_BOOLEAN__OTGrammar_Strings_areAllPartialOutputsGrammatical) { |
| 878 | QUERY_ONE_AND_ONE_FOR_BOOLEAN (OTGrammar, Strings) |
| 879 | const bool result = OTGrammar_areAllPartialOutputsGrammatical (me, you); |
| 880 | QUERY_ONE_AND_ONE_FOR_BOOLEAN_END (result ? U" (all grammatical)" : U" (not all grammatical)") |
| 881 | } |
| 882 | |
| 883 | DIRECT (QUERY_ONE_AND_ONE_FOR_BOOLEAN__OTGrammar_Strings_areAllPartialOutputsSinglyGrammatical) { |
| 884 | QUERY_ONE_AND_ONE_FOR_BOOLEAN (OTGrammar, Strings) |
| 885 | const bool result = OTGrammar_areAllPartialOutputsSinglyGrammatical (me, you); |
| 886 | QUERY_ONE_AND_ONE_FOR_BOOLEAN_END (result ? U" (all singly grammatical)" : U" (not all singly grammatical)") |
| 887 | } |
| 888 | |
| 889 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_TWO__OTGrammar_Stringses_learn, U"OTGrammar: Learn", U"OTGrammar & 2 Strings: Learn...") { |
| 890 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 891 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 892 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 893 | REAL (plasticity, U"Plasticity", U"0.1") |
| 894 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 895 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 896 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 897 | OK |
| 898 | DO |
| 899 | MODIFY_FIRST_OF_ONE_WEAK_AND_TWO (OTGrammar, Strings) |
| 900 | OTGrammar_learn (me, you, him, evaluationNoise, updateRule, honourLocalRankings, |
| 901 | plasticity, relativePlasticitySpreading, numberOfChews); |
| 902 | MODIFY_FIRST_OF_ONE_WEAK_AND_TWO_END |
| 903 | } |
| 904 | |
| 905 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Strings_learnFromPartialOutputs, U"OTGrammar: Learn from partial adult outputs", nullptr) { |
| 906 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 907 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 908 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 909 | REAL (plasticity, U"Plasticity", U"0.1") |
| 910 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 911 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 912 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 913 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 914 | OK |
| 915 | DO |
| 916 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTGrammar, Strings, OTHistory) |
| 917 | OTGrammar_learnFromPartialOutputs (me, you, evaluationNoise, updateRule, honourLocalRankings, |
| 918 | plasticity, relativePlasticitySpreading, numberOfChews, storeHistoryEvery, & history); |
| 919 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 920 | } |
| 921 | |
| 922 | DIRECT (CONVERT_ONE_AND_TWO_TO_ONE__OTGrammar_Stringses_tabulateAllCorrectRankings) { |
| 923 | CONVERT_ONE_AND_TWO_TO_ONE (OTGrammar, Strings) |
| 924 | autoTable result = OTGrammar_tabulateAllCorrectRankings (me, you, him); |
| 925 | CONVERT_ONE_AND_TWO_TO_ONE_END (my name.get()) |
| 926 | } |
| 927 | |
| 928 | // MARK: OTGRAMMAR & DISTRIBUTIONS |
| 929 | |
| 930 | FORM (QUERY_ONE_WEAK_AND_ONE_FOR_REAL__OTGrammar_Distributions_getFractionCorrect, U"OTGrammar & Distributions: Get fraction correct...", nullptr) { |
| 931 | NATURAL (columnNumber, U"Column number", U"1") |
| 932 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 933 | INTEGER (replications, U"Replications", U"100000") |
| 934 | OK |
| 935 | DO |
| 936 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL (OTGrammar, Distributions) |
| 937 | const double result = OTGrammar_Distributions_getFractionCorrect (me, you, columnNumber, |
| 938 | evaluationNoise, replications); |
| 939 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL_END (U" (fraction correct)") |
| 940 | } |
| 941 | |
| 942 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs, |
| 943 | U"OTGrammar & Distributions: Learn from partial outputs", U"OT learning 6. Shortcut to grammar learning") |
| 944 | { |
| 945 | NATURAL (columnNumber, U"Column number", U"1") |
| 946 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 947 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 948 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 949 | REAL (initialPlasticity, U"Initial plasticity", U"1.0") |
| 950 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 951 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 952 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 953 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 954 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 955 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 956 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 957 | OK |
| 958 | DO |
| 959 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTGrammar, Distributions, OTHistory) |
| 960 | OTGrammar_Distributions_learnFromPartialOutputs (me, you, columnNumber, evaluationNoise, |
| 961 | updateRule, honourLocalRankings, |
| 962 | initialPlasticity, replicationsPerPlasticity, plasticityDecrement, numberOfPlasticities, |
| 963 | relativePlasticitySpreading, numberOfChews, storeHistoryEvery, & history, false, false, 0 |
| 964 | ); |
| 965 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 966 | } |
| 967 | |
| 968 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_rrip, |
| 969 | U"OTGrammar & Distributions: Learn from partial outputs (rrip)", U"OT learning 6. Shortcut to grammar learning") |
| 970 | { |
| 971 | NATURAL (columnNumber, U"Column number", U"1") |
| 972 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 973 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 974 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 975 | REAL (initialPlasticity, U"Initial plasticity", U"1.0") |
| 976 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 977 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 978 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 979 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 980 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 981 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 982 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 983 | OK |
| 984 | DO |
| 985 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTGrammar, Distributions, OTHistory) |
| 986 | OTGrammar_Distributions_learnFromPartialOutputs (me, you, columnNumber, evaluationNoise, |
| 987 | updateRule, honourLocalRankings, |
| 988 | initialPlasticity, replicationsPerPlasticity, plasticityDecrement, numberOfPlasticities, |
| 989 | relativePlasticitySpreading, numberOfChews, storeHistoryEvery, & history, true, true, 0 |
| 990 | ); |
| 991 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 992 | } |
| 993 | |
| 994 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_eip, |
| 995 | U"OTGrammar & Distributions: Learn from partial outputs (eip)", U"OT learning 6. Shortcut to grammar learning") |
| 996 | { |
| 997 | NATURAL (columnNumber, U"Column number", U"1") |
| 998 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 999 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 1000 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 1001 | REAL (initialPlasticity, U"Initial plasticity", U"1.0") |
| 1002 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 1003 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 1004 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 1005 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 1006 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 1007 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 1008 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 1009 | OK |
| 1010 | DO |
| 1011 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTGrammar, Distributions, OTHistory) |
| 1012 | OTGrammar_Distributions_learnFromPartialOutputs (me, you, columnNumber, evaluationNoise, |
| 1013 | updateRule, honourLocalRankings, |
| 1014 | initialPlasticity, replicationsPerPlasticity, plasticityDecrement, numberOfPlasticities, |
| 1015 | relativePlasticitySpreading, numberOfChews, storeHistoryEvery, & history, true, true, 1000 |
| 1016 | ); |
| 1017 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 1018 | } |
| 1019 | |
| 1020 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_wrip, |
| 1021 | U"OTGrammar & Distributions: Learn from partial outputs (wrip)", U"OT learning 6. Shortcut to grammar learning") |
| 1022 | { |
| 1023 | NATURAL (columnNumber, U"Column number", U"1") |
| 1024 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1025 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 1026 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 1027 | REAL (initialPlasticity, U"Initial plasticity", U"1.0") |
| 1028 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 1029 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 1030 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 1031 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 1032 | BOOLEAN (honourLocalRankings, U"Honour local rankings", 1) |
| 1033 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 1034 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 1035 | OK |
| 1036 | DO |
| 1037 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTGrammar, Distributions, OTHistory) |
| 1038 | OTGrammar_Distributions_learnFromPartialOutputs (me, you, columnNumber, evaluationNoise, |
| 1039 | updateRule, honourLocalRankings, |
| 1040 | initialPlasticity, replicationsPerPlasticity, plasticityDecrement, numberOfPlasticities, |
| 1041 | relativePlasticitySpreading, numberOfChews, storeHistoryEvery, & history, true, true, 1 |
| 1042 | ); |
| 1043 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 1044 | } |
| 1045 | |
| 1046 | FORM (INFO_ONE_AND_ONE__OTGrammar_Distributions_listObligatoryRankings, U"OTGrammar & Distributions: Get fraction correct...", nullptr) { |
| 1047 | NATURAL (columnNumber, U"Column number", U"1") |
| 1048 | OK |
| 1049 | DO |
| 1050 | INFO_ONE_AND_ONE (OTGrammar, Distributions) |
| 1051 | OTGrammar_Distributions_listObligatoryRankings (me, you, columnNumber); |
| 1052 | INFO_ONE_AND_ONE_END |
| 1053 | } |
| 1054 | |
| 1055 | // MARK: OTGRAMMAR & PAIRDISTRIBUTION |
| 1056 | |
| 1057 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__OTGrammar_PairDistribution_findPositiveWeights, |
| 1058 | U"OTGrammar & PairDistribution: Find positive weights", U"OTGrammar & PairDistribution: Find positive weights...") |
| 1059 | { |
| 1060 | POSITIVE (weightFloor, U"Weight floor", U"1.0") |
| 1061 | POSITIVE (marginOfSeparation, U"Margin of separation", U"1.0") |
| 1062 | OK |
| 1063 | DO |
| 1064 | MODIFY_FIRST_OF_ONE_AND_ONE (OTGrammar, PairDistribution) |
| 1065 | OTGrammar_PairDistribution_findPositiveWeights (me, you, weightFloor, marginOfSeparation); |
| 1066 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1067 | } |
| 1068 | |
| 1069 | FORM (QUERY_ONE_WEAK_AND_ONE_FOR_REAL__OTGrammar_PairDistribution_getFractionCorrect, U"OTGrammar & PairDistribution: Get fraction correct...", nullptr) { |
| 1070 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1071 | INTEGER (replications, U"Replications", U"100000") |
| 1072 | OK |
| 1073 | DO |
| 1074 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL (OTGrammar, PairDistribution) |
| 1075 | const double result = OTGrammar_PairDistribution_getFractionCorrect (me, you, evaluationNoise, replications); |
| 1076 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL_END (U" (fraction correct)") |
| 1077 | } |
| 1078 | |
| 1079 | FORM (QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER__OTGrammar_PairDistribution_getMinimumNumberCorrect, U"OTGrammar & PairDistribution: Get minimum number correct...", nullptr) { |
| 1080 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1081 | INTEGER (replicationsPerInput, U"Replications per input", U"1000") |
| 1082 | OK |
| 1083 | DO |
| 1084 | QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER (OTGrammar, PairDistribution) |
| 1085 | const integer result = OTGrammar_PairDistribution_getMinimumNumberCorrect (me, you, |
| 1086 | evaluationNoise, replicationsPerInput); |
| 1087 | QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER_END (U" (minimally correct)") |
| 1088 | } |
| 1089 | |
| 1090 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE__OTGrammar_PairDistribution_learn, U"OTGrammar & PairDistribution: Learn", U"OT learning 6. Shortcut to grammar learning") { |
| 1091 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1092 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 1093 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 1094 | POSITIVE (initialPlasticity, U"Initial plasticity", U"1.0") |
| 1095 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 1096 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 1097 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 1098 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 1099 | BOOLEAN (honourLocalRankings, U"Honour local rankings", true) |
| 1100 | NATURAL (numberOfChews, U"Number of chews", U"1") |
| 1101 | OK |
| 1102 | DO |
| 1103 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE (OTGrammar, PairDistribution) |
| 1104 | OTGrammar_PairDistribution_learn (me, you, |
| 1105 | evaluationNoise, updateRule, honourLocalRankings, |
| 1106 | initialPlasticity, replicationsPerPlasticity, |
| 1107 | plasticityDecrement, numberOfPlasticities, relativePlasticitySpreading, numberOfChews |
| 1108 | ); |
| 1109 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_END |
| 1110 | } |
| 1111 | |
| 1112 | DIRECT (INFO_ONE_AND_ONE__OTGrammar_PairDistribution_listObligatoryRankings) { |
| 1113 | INFO_ONE_AND_ONE (OTGrammar, PairDistribution) |
| 1114 | OTGrammar_PairDistribution_listObligatoryRankings (me, you); |
| 1115 | INFO_ONE_AND_ONE_END |
| 1116 | } |
| 1117 | |
| 1118 | // MARK: - OTMULTI |
| 1119 | |
| 1120 | // MARK: New |
| 1121 | |
| 1122 | FORM (CREATE_ONE__Create_multi_level_metrics_grammar, U"Create multi-level metrics grammar", nullptr) { |
| 1123 | OPTIONMENU_ENUM (kOTGrammar_createMetricsGrammar_initialRanking, initialRanking, |
| 1124 | U"Initial ranking", kOTGrammar_createMetricsGrammar_initialRanking::DEFAULT) |
| 1125 | OPTIONMENU (trochaicityConstraint, U"Trochaicity constraint", 1) |
| 1126 | OPTION (U"FtNonfinal") |
| 1127 | OPTION (U"Trochaic") |
| 1128 | BOOLEAN (includeFootBimoraic, U"Include FootBimoraic", false) |
| 1129 | BOOLEAN (includeFootBisyllabic, U"Include FootBisyllabic", false) |
| 1130 | BOOLEAN (includePeripheral, U"Include Peripheral", false) |
| 1131 | OPTIONMENU (nonfinalityConstraint, U"Nonfinality constraint", 1) |
| 1132 | OPTION (U"Nonfinal") |
| 1133 | OPTION (U"MainNonfinal") |
| 1134 | OPTION (U"HeadNonfinal") |
| 1135 | BOOLEAN (overtFormsHaveSecondaryStress, U"Overt forms have secondary stress", true) |
| 1136 | BOOLEAN (includeClashAndLapse, U"Include *Clash and *Lapse", false) |
| 1137 | BOOLEAN (includeCodas, U"Include codas", false) |
| 1138 | OK |
| 1139 | DO |
| 1140 | CREATE_ONE |
| 1141 | autoOTMulti result = OTMulti_create_metrics (initialRanking, trochaicityConstraint, |
| 1142 | includeFootBimoraic, includeFootBisyllabic, includePeripheral, nonfinalityConstraint, |
| 1143 | overtFormsHaveSecondaryStress, includeClashAndLapse, includeCodas |
| 1144 | ); |
| 1145 | CREATE_ONE_END (kOTGrammar_createMetricsGrammar_initialRanking_getText (initialRanking)) |
| 1146 | } |
| 1147 | |
| 1148 | // MARK: Draw |
| 1149 | |
| 1150 | FORM (GRAPHICS_EACH__OTMulti_drawTableau, U"Draw tableau", U"OT learning") { |
| 1151 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1152 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1153 | BOOLEAN (showDisharmonies, U"Show disharmonies", true) |
| 1154 | OK |
| 1155 | DO |
| 1156 | GRAPHICS_EACH (OTMulti) |
| 1157 | OTMulti_drawTableau (me, GRAPHICS, partialForm1, partialForm2, false, showDisharmonies); |
| 1158 | GRAPHICS_EACH_END |
| 1159 | } |
| 1160 | |
| 1161 | FORM (GRAPHICS_EACH__OTMulti_drawTableau_narrowly, U"Draw tableau (narrowly)", U"OT learning") { |
| 1162 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1163 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1164 | BOOLEAN (showDisharmonies, U"Show disharmonies", true) |
| 1165 | OK |
| 1166 | DO |
| 1167 | GRAPHICS_EACH (OTMulti) |
| 1168 | OTMulti_drawTableau (me, GRAPHICS, partialForm1, partialForm2, true, showDisharmonies); |
| 1169 | GRAPHICS_EACH_END |
| 1170 | } |
| 1171 | |
| 1172 | // MARK: View & Edit |
| 1173 | |
| 1174 | DIRECT (EDITOR_ONE__OTMulti_viewAndEdit) { |
| 1175 | EDITOR_ONE (an,OTMulti) |
| 1176 | autoOTMultiEditor editor = OTMultiEditor_create (ID_AND_FULL_NAME, me); |
| 1177 | EDITOR_ONE_END |
| 1178 | } |
| 1179 | |
| 1180 | // MARK: Query |
| 1181 | |
| 1182 | DIRECT (QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfConstraints) { |
| 1183 | QUERY_ONE_FOR_INTEGER (OTMulti) |
| 1184 | const integer result = my numberOfConstraints; |
| 1185 | QUERY_ONE_FOR_INTEGER_END (U" constraints") |
| 1186 | } |
| 1187 | |
| 1188 | FORM (QUERY_ONE_FOR_STRING__OTMulti_getConstraint, U"Get constraint name", nullptr) { |
| 1189 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 1190 | OK |
| 1191 | DO |
| 1192 | QUERY_ONE_FOR_STRING (OTMulti) |
| 1193 | if (constraintNumber > my numberOfConstraints) |
| 1194 | Melder_throw (U"Your constraint number should not exceed the number of constraints."); |
| 1195 | const conststring32 result = my constraints [constraintNumber]. name.get(); |
| 1196 | QUERY_ONE_FOR_STRING_END |
| 1197 | } |
| 1198 | |
| 1199 | FORM (QUERY_ONE_FOR_INTEGER__OTMulti_getConstraintIndexFromName, U"OTMulti: Get constraint number", nullptr) { |
| 1200 | SENTENCE (constraintName, U"Constraint name", U"") |
| 1201 | OK |
| 1202 | DO |
| 1203 | QUERY_ONE_FOR_INTEGER (OTMulti) |
| 1204 | const integer result = OTMulti_getConstraintIndexFromName (me, constraintName); |
| 1205 | QUERY_ONE_FOR_INTEGER_END (U" (index of constraint ", constraintName, U")") |
| 1206 | } |
| 1207 | |
| 1208 | FORM (QUERY_ONE_FOR_REAL__OTMulti_getRankingValue, U"Get ranking value", nullptr) { |
| 1209 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 1210 | OK |
| 1211 | DO |
| 1212 | QUERY_ONE_FOR_REAL (OTMulti) |
| 1213 | if (constraintNumber > my numberOfConstraints) |
| 1214 | Melder_throw (U"Your constraint number should not exceed the number of constraints."); |
| 1215 | const double result = my constraints [constraintNumber]. ranking; |
| 1216 | QUERY_ONE_FOR_REAL_END (U" (ranking of constraint ", constraintNumber, U")") |
| 1217 | } |
| 1218 | |
| 1219 | FORM (QUERY_ONE_FOR_REAL__OTMulti_getDisharmony, U"Get disharmony", nullptr) { |
| 1220 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 1221 | OK |
| 1222 | DO |
| 1223 | QUERY_ONE_FOR_REAL (OTMulti) |
| 1224 | if (constraintNumber > my numberOfConstraints) |
| 1225 | Melder_throw (U"Your constraint number should not exceed the number of constraints."); |
| 1226 | const double result = my constraints [constraintNumber]. disharmony; |
| 1227 | QUERY_ONE_FOR_REAL_END (U" (disharmony of constraint ", constraintNumber, U")") |
| 1228 | } |
| 1229 | |
| 1230 | DIRECT (QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfCandidates) { |
| 1231 | QUERY_ONE_FOR_INTEGER (OTMulti) |
| 1232 | integer result = my numberOfCandidates; |
| 1233 | QUERY_ONE_FOR_INTEGER_END (U" candidates") |
| 1234 | } |
| 1235 | |
| 1236 | FORM (QUERY_ONE_FOR_STRING__OTMulti_getCandidate, U"Get candidate", nullptr) { |
| 1237 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 1238 | OK |
| 1239 | DO |
| 1240 | QUERY_ONE_FOR_STRING (OTMulti) |
| 1241 | if (candidateNumber > my numberOfCandidates) |
| 1242 | Melder_throw (U"Your candidate number should not exceed the number of candidates."); |
| 1243 | const conststring32 result = my candidates [candidateNumber]. string.get(); |
| 1244 | QUERY_ONE_FOR_STRING_END |
| 1245 | } |
| 1246 | |
| 1247 | FORM (QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfViolations, U"Get number of violations", nullptr) { |
| 1248 | NATURAL (candidateNumber, U"Candidate number", U"1") |
| 1249 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 1250 | OK |
| 1251 | DO |
| 1252 | QUERY_ONE_FOR_INTEGER (OTMulti) |
| 1253 | if (candidateNumber > my numberOfCandidates) |
| 1254 | Melder_throw (U"Your candidate number should not exceed the number of candidates."); |
| 1255 | if (constraintNumber > my numberOfConstraints) |
| 1256 | Melder_throw (U"Your constraint number should not exceed the number of constraints."); |
| 1257 | const integer result = my candidates [candidateNumber]. marks [constraintNumber]; |
| 1258 | QUERY_ONE_FOR_INTEGER_END (U" violations") |
| 1259 | } |
| 1260 | |
| 1261 | FORM (QUERY_ONE_FOR_INTEGER__OTMulti_getWinner, U"OTMulti: Get winner", nullptr) { |
| 1262 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1263 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1264 | OK |
| 1265 | DO |
| 1266 | QUERY_ONE_FOR_INTEGER (OTMulti) |
| 1267 | const integer result = OTMulti_getWinner (me, partialForm1, partialForm2); |
| 1268 | QUERY_ONE_FOR_INTEGER_END (U" (winner)") |
| 1269 | } |
| 1270 | |
| 1271 | // MARK: Evaluate |
| 1272 | |
| 1273 | FORM (MODIFY_EACH__OTMulti_evaluate, U"OTMulti: Evaluate", nullptr) { |
| 1274 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1275 | OK |
| 1276 | DO |
| 1277 | MODIFY_EACH (OTMulti) |
| 1278 | OTMulti_newDisharmonies (me, evaluationNoise); |
| 1279 | MODIFY_EACH_END |
| 1280 | } |
| 1281 | |
| 1282 | FORM (QUERY_ONE_WEAK_FOR_STRING__OTMulti_generateOptimalForm, U"OTMulti: Generate optimal form", nullptr) { |
| 1283 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1284 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1285 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1286 | OK |
| 1287 | DO |
| 1288 | QUERY_ONE_WEAK_FOR_STRING (OTMulti) |
| 1289 | autostring32 output = OTMulti_generateOptimalForm (me, partialForm1, partialForm2, evaluationNoise); |
| 1290 | conststring32 result = output.get(); |
| 1291 | QUERY_ONE_WEAK_FOR_STRING_END |
| 1292 | } |
| 1293 | |
| 1294 | FORM (CONVERT_EACH_WEAK_TO_ONE__OTMulti_generateOptimalForms, U"OTMulti: Generate optimal forms", nullptr) { |
| 1295 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1296 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1297 | NATURAL (numberOfTrials, U"Number of trials", U"1000") |
| 1298 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1299 | OK |
| 1300 | DO |
| 1301 | CONVERT_EACH_WEAK_TO_ONE (OTMulti) |
| 1302 | autoStrings result = OTMulti_generateOptimalForms (me, partialForm1, partialForm2, |
| 1303 | numberOfTrials, evaluationNoise); |
| 1304 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 1305 | } |
| 1306 | |
| 1307 | FORM (CONVERT_EACH_WEAK_TO_ONE__OTMulti_to_Distribution, U"OTMulti: Compute output distribution", nullptr) { |
| 1308 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1309 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1310 | NATURAL (numberOfTrials, U"Number of trials", U"100000") |
| 1311 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1312 | OK |
| 1313 | DO |
| 1314 | CONVERT_EACH_WEAK_TO_ONE (OTMulti) |
| 1315 | autoDistributions result = OTMulti_to_Distribution (me, partialForm1, partialForm2, |
| 1316 | numberOfTrials, evaluationNoise); |
| 1317 | CONVERT_EACH_WEAK_TO_ONE_END (my name.get(), U"_out") |
| 1318 | } |
| 1319 | |
| 1320 | // MARK: Modify ranking |
| 1321 | |
| 1322 | FORM (MODIFY_EACH__OTMulti_setRanking, U"OTMulti: Set ranking", nullptr) { |
| 1323 | NATURAL (constraint, U"Constraint", U"1") |
| 1324 | REAL (ranking, U"Ranking", U"100.0") |
| 1325 | REAL (disharmony, U"Disharmony", U"100.0") |
| 1326 | OK |
| 1327 | DO |
| 1328 | MODIFY_EACH (OTMulti) |
| 1329 | OTMulti_setRanking (me, constraint, ranking, disharmony); |
| 1330 | MODIFY_EACH_END |
| 1331 | } |
| 1332 | |
| 1333 | FORM (MODIFY_EACH__OTMulti_resetAllRankings, U"OTMulti: Reset all rankings", nullptr) { |
| 1334 | REAL (ranking, U"Ranking", U"100.0") |
| 1335 | OK |
| 1336 | DO |
| 1337 | MODIFY_EACH (OTMulti) |
| 1338 | OTMulti_reset (me, ranking); |
| 1339 | MODIFY_EACH_END |
| 1340 | } |
| 1341 | |
| 1342 | FORM (MODIFY_EACH_WEAK__OTMulti_learnOne, U"OTMulti: Learn one", nullptr) { |
| 1343 | SENTENCE (partialForm1, U"Partial form 1", U"") |
| 1344 | SENTENCE (partialForm2, U"Partial form 2", U"") |
| 1345 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 1346 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 1347 | OPTIONMENU (direction, U"Direction", 3) |
| 1348 | OPTION (U"forward") |
| 1349 | OPTION (U"backward") |
| 1350 | OPTION (U"bidirectionally") |
| 1351 | POSITIVE (plasticity, U"Plasticity", U"0.1") |
| 1352 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 1353 | OK |
| 1354 | DO |
| 1355 | MODIFY_EACH_WEAK (OTMulti) |
| 1356 | OTMulti_learnOne (me, partialForm1, partialForm2, updateRule, |
| 1357 | direction, plasticity, relativePlasticitySpreading); |
| 1358 | MODIFY_EACH_WEAK_END |
| 1359 | } |
| 1360 | |
| 1361 | // MARK: Modify behaviour |
| 1362 | |
| 1363 | FORM (MODIFY_EACH__OTMulti_setDecisionStrategy, U"OTMulti: Set decision strategy", nullptr) { |
| 1364 | CHOICE_ENUM (kOTGrammar_decisionStrategy, decisionStrategy, |
| 1365 | U"Decision strategy", kOTGrammar_decisionStrategy::DEFAULT) |
| 1366 | OK |
| 1367 | FIND_ONE (OTMulti) |
| 1368 | SET_ENUM (decisionStrategy, kOTGrammar_decisionStrategy, my decisionStrategy); |
| 1369 | DO |
| 1370 | MODIFY_EACH (OTMulti) |
| 1371 | my decisionStrategy = decisionStrategy; |
| 1372 | MODIFY_EACH_END |
| 1373 | } |
| 1374 | |
| 1375 | FORM (MODIFY_EACH__OTMulti_setLeak, U"OTGrammar: Set leak", nullptr) { |
| 1376 | REAL (leak, U"Leak", U"0.0") |
| 1377 | OK |
| 1378 | FIND_ONE (OTMulti) |
| 1379 | SET_REAL (leak, my leak) |
| 1380 | DO |
| 1381 | MODIFY_EACH (OTMulti) |
| 1382 | my leak = leak; |
| 1383 | MODIFY_EACH_END |
| 1384 | } |
| 1385 | |
| 1386 | FORM (MODIFY_EACH__OTMulti_setConstraintPlasticity, U"OTMulti: Set constraint plasticity", nullptr) { |
| 1387 | NATURAL (constraintNumber, U"Constraint number", U"1") |
| 1388 | REAL (plasticity, U"Plasticity", U"1.0") |
| 1389 | OK |
| 1390 | DO |
| 1391 | MODIFY_EACH (OTMulti) |
| 1392 | OTMulti_setConstraintPlasticity (me, constraintNumber, plasticity); |
| 1393 | MODIFY_EACH_END |
| 1394 | } |
| 1395 | |
| 1396 | // MARK: Modify structure |
| 1397 | |
| 1398 | FORM (MODIFY_EACH__OTMulti_removeConstraint, U"OTMulti: Remove constraint", nullptr) { |
| 1399 | SENTENCE (constraintName, U"Constraint name", U"") |
| 1400 | OK |
| 1401 | DO |
| 1402 | MODIFY_EACH (OTMulti) |
| 1403 | OTMulti_removeConstraint (me, constraintName); |
| 1404 | MODIFY_EACH_END |
| 1405 | } |
| 1406 | |
| 1407 | // MARK: OTMULTI & PAIRDISTRIBUTION |
| 1408 | |
| 1409 | FORM (MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTMulti_PairDistribution_learn, U"OTMulti & PairDistribution: Learn", nullptr) { |
| 1410 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1411 | OPTIONMENU_ENUM (kOTGrammar_rerankingStrategy, updateRule, |
| 1412 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 1413 | OPTIONMENU (direction, U"Direction", 3) |
| 1414 | OPTION (U"forward") |
| 1415 | OPTION (U"backward") |
| 1416 | OPTION (U"bidirectionally") |
| 1417 | POSITIVE (initialPlasticity, U"Initial plasticity", U"1.0") |
| 1418 | NATURAL (replicationsPerPlasticity, U"Replications per plasticity", U"100000") |
| 1419 | REAL (plasticityDecrement, U"Plasticity decrement", U"0.1") |
| 1420 | NATURAL (numberOfPlasticities, U"Number of plasticities", U"4") |
| 1421 | REAL (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 1422 | INTEGER (storeHistoryEvery, U"Store history every", U"0") |
| 1423 | OK |
| 1424 | DO |
| 1425 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY (OTMulti, PairDistribution, Table) |
| 1426 | OTMulti_PairDistribution_learn (me, you, evaluationNoise, |
| 1427 | updateRule, direction, |
| 1428 | initialPlasticity, replicationsPerPlasticity, plasticityDecrement, numberOfPlasticities, |
| 1429 | relativePlasticitySpreading, storeHistoryEvery, & history |
| 1430 | ); |
| 1431 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY_END |
| 1432 | } |
| 1433 | |
| 1434 | // MARK: OTMULTI & STRINGS |
| 1435 | |
| 1436 | FORM (CONVERT_ONE_WEAK_AND_ONE_TO_ONE__OTMulti_Strings_generateOptimalForms, U"OTGrammar: Inputs to outputs", U"OTGrammar: Inputs to outputs...") { |
| 1437 | REAL (evaluationNoise, U"Evaluation noise", U"2.0") |
| 1438 | OK |
| 1439 | DO |
| 1440 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE (OTMulti, Strings) |
| 1441 | autoStrings result = OTMulti_Strings_generateOptimalForms (me, you, evaluationNoise); |
| 1442 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE_END (my name.get(), U"_out") |
| 1443 | } |
| 1444 | |
| 1445 | // MARK: - NET |
| 1446 | |
| 1447 | // MARK: New |
| 1448 | |
| 1449 | FORM (CREATE_ONE__CreateNetAsDeepBeliefNetwork, U"Create Net as DeepBeliefNetwork", nullptr) { |
| 1450 | WORD (name, U"Name", U"network") |
| 1451 | NATURALVECTOR (numbersOfNodes, U"Numbers of nodes", WHITESPACE_SEPARATED_, U"30 50 20") |
| 1452 | BOOLEAN (inputsAreBinary, U"Inputs are binary", false) |
| 1453 | OK |
| 1454 | DO |
| 1455 | CREATE_ONE |
| 1456 | autoNet result = Net_createAsDeepBeliefNet (numbersOfNodes, inputsAreBinary); |
| 1457 | CREATE_ONE_END (name) |
| 1458 | } |
| 1459 | |
| 1460 | // MARK: Modify |
| 1461 | |
| 1462 | FORM (MODIFY_EACH__Net_spreadUp, U"Net: Spread up", nullptr) { |
| 1463 | CHOICE_ENUM (kLayer_activationType, activationType, |
| 1464 | U"Activation type", kLayer_activationType::STOCHASTIC) |
| 1465 | OK |
| 1466 | DO |
| 1467 | MODIFY_EACH (Net) |
| 1468 | Net_spreadUp (me, activationType); |
| 1469 | MODIFY_EACH_END |
| 1470 | } |
| 1471 | |
| 1472 | FORM (MODIFY_EACH__Net_spreadDown, U"Net: Spread down", nullptr) { |
| 1473 | CHOICE_ENUM (kLayer_activationType, activationType, |
| 1474 | U"Activation type", kLayer_activationType::DETERMINISTIC) |
| 1475 | OK |
| 1476 | DO |
| 1477 | MODIFY_EACH (Net) |
| 1478 | Net_spreadDown (me, activationType); |
| 1479 | MODIFY_EACH_END |
| 1480 | } |
| 1481 | |
| 1482 | DIRECT (MODIFY_EACH__Net_spreadUp_reconstruction) { |
| 1483 | MODIFY_EACH (Net) |
| 1484 | Net_spreadUp_reconstruction (me); |
| 1485 | MODIFY_EACH_END |
| 1486 | } |
| 1487 | |
| 1488 | DIRECT (MODIFY_EACH__Net_spreadDown_reconstruction) { |
| 1489 | MODIFY_EACH (Net) |
| 1490 | Net_spreadDown_reconstruction (me); |
| 1491 | MODIFY_EACH_END |
| 1492 | } |
| 1493 | |
| 1494 | DIRECT (MODIFY_EACH__Net_sampleInput) { |
| 1495 | MODIFY_EACH (Net) |
| 1496 | Net_sampleInput (me); |
| 1497 | MODIFY_EACH_END |
| 1498 | } |
| 1499 | |
| 1500 | DIRECT (MODIFY_EACH__Net_sampleOutput) { |
| 1501 | MODIFY_EACH (Net) |
| 1502 | Net_sampleOutput (me); |
| 1503 | MODIFY_EACH_END |
| 1504 | } |
| 1505 | |
| 1506 | FORM (MODIFY_EACH__Net_update, U"Net: Update", nullptr) { |
| 1507 | POSITIVE (learningRate, U"Learning rate", U"0.001") |
| 1508 | OK |
| 1509 | DO |
| 1510 | MODIFY_EACH (Net) |
| 1511 | Net_update (me, learningRate); |
| 1512 | MODIFY_EACH_END |
| 1513 | } |
| 1514 | |
| 1515 | // MARK: Extract |
| 1516 | |
| 1517 | DIRECT (CONVERT_EACH_TO_ONE__Net_extractInputActivities) { |
| 1518 | CONVERT_EACH_TO_ONE (Net) |
| 1519 | autoMatrix result = Net_extractInputActivities (me); |
| 1520 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_inputActivities") |
| 1521 | } |
| 1522 | |
| 1523 | DIRECT (CONVERT_EACH_TO_ONE__Net_extractOutputActivities) { |
| 1524 | CONVERT_EACH_TO_ONE (Net) |
| 1525 | autoMatrix result = Net_extractOutputActivities (me); |
| 1526 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_outputActivities") |
| 1527 | } |
| 1528 | |
| 1529 | DIRECT (CONVERT_EACH_TO_ONE__Net_extractInputReconstruction) { |
| 1530 | CONVERT_EACH_TO_ONE (Net) |
| 1531 | autoMatrix result = Net_extractInputReconstruction (me); |
| 1532 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_inputReconstruction") |
| 1533 | } |
| 1534 | |
| 1535 | DIRECT (CONVERT_EACH_TO_ONE__Net_extractOutputReconstruction) { |
| 1536 | CONVERT_EACH_TO_ONE (Net) |
| 1537 | autoMatrix result = Net_extractOutputReconstruction (me); |
| 1538 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_outputReconstruction") |
| 1539 | } |
| 1540 | |
| 1541 | FORM (CONVERT_EACH_TO_ONE__Net_extractInputBiases, U"Net: Extract input biases", nullptr) { |
| 1542 | NATURAL (layerNumber, U"Layer number", U"1") |
| 1543 | OK |
| 1544 | DO |
| 1545 | CONVERT_EACH_TO_ONE (Net) |
| 1546 | autoMatrix result = Net_extractInputBiases (me, layerNumber); |
| 1547 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_inputBiases") |
| 1548 | } |
| 1549 | |
| 1550 | FORM (CONVERT_EACH_TO_ONE__Net_extractOutputBiases, U"Net: Extract output biases", nullptr) { |
| 1551 | NATURAL (layerNumber, U"Layer number", U"1") |
| 1552 | OK |
| 1553 | DO |
| 1554 | CONVERT_EACH_TO_ONE (Net) |
| 1555 | autoMatrix result = Net_extractOutputBiases (me, layerNumber); |
| 1556 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_outputBiases") |
| 1557 | } |
| 1558 | |
| 1559 | FORM (CONVERT_EACH_TO_ONE__Net_extractWeights, U"Net: Extract weights", nullptr) { |
| 1560 | NATURAL (layerNumber, U"Layer number", U"1") |
| 1561 | OK |
| 1562 | DO |
| 1563 | CONVERT_EACH_TO_ONE (Net) |
| 1564 | autoMatrix result = Net_extractWeights (me, layerNumber); |
| 1565 | CONVERT_EACH_TO_ONE_END (my name.get(), U"_weights") |
| 1566 | } |
| 1567 | |
| 1568 | FORM (QUERY_ONE_FOR_MATRIX__Net_getWeights, U"Net: Get weigths", nullptr) { |
| 1569 | NATURAL (layerNumber, U"Layer number", U"1") |
| 1570 | OK |
| 1571 | DO |
| 1572 | QUERY_ONE_FOR_MATRIX (Net) |
| 1573 | autoMAT result = Net_getWeights (me, layerNumber); |
| 1574 | QUERY_ONE_FOR_MATRIX_END |
| 1575 | } |
| 1576 | |
| 1577 | // MARK: - NET & PATTERN |
| 1578 | |
| 1579 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_applyToInput, U"Net & PatternList: Apply to input", nullptr) { |
| 1580 | NATURAL (rowNumber, U"Row number", U"1") |
| 1581 | OK |
| 1582 | DO |
| 1583 | MODIFY_FIRST_OF_ONE_AND_ONE (Net, PatternList) |
| 1584 | Net_PatternList_applyToInput (me, you, rowNumber); |
| 1585 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1586 | } |
| 1587 | |
| 1588 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_applyToOutput, U"Net & PatternList: Apply to output", nullptr) { |
| 1589 | NATURAL (rowNumber, U"Row number", U"1") |
| 1590 | OK |
| 1591 | DO |
| 1592 | MODIFY_FIRST_OF_ONE_AND_ONE (Net, PatternList) |
| 1593 | Net_PatternList_applyToOutput (me, you, rowNumber); |
| 1594 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1595 | } |
| 1596 | |
| 1597 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learn, U"Net & PatternList: Learn", nullptr) { |
| 1598 | POSITIVE (learningRate, U"Learning rate", U"0.001") |
| 1599 | OK |
| 1600 | DO |
| 1601 | MODIFY_FIRST_OF_ONE_AND_ONE (Net, PatternList) |
| 1602 | Net_PatternList_learn (me, you, learningRate); |
| 1603 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1604 | } |
| 1605 | |
| 1606 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learnByLayer, U"Net & PatternList: Learn by layer", nullptr) { |
| 1607 | POSITIVE (learningRate, U"Learning rate", U"0.001") |
| 1608 | OK |
| 1609 | DO |
| 1610 | MODIFY_FIRST_OF_ONE_AND_ONE (Net, PatternList) |
| 1611 | Net_PatternList_learnByLayer (me, you, learningRate); |
| 1612 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1613 | } |
| 1614 | |
| 1615 | FORM (MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learn_twoPhases, U"Net & PatternList: Learn (two phases)", nullptr) { |
| 1616 | POSITIVE (learningRate, U"Learning rate", U"0.001") |
| 1617 | OK |
| 1618 | DO |
| 1619 | MODIFY_FIRST_OF_ONE_AND_ONE (Net, PatternList) |
| 1620 | Net_PatternList_learn_twoPhases (me, you, learningRate); |
| 1621 | MODIFY_FIRST_OF_ONE_AND_ONE_END |
| 1622 | } |
| 1623 | |
| 1624 | FORM (CONVERT_ONE_AND_ONE_TO_ONE__Net_PatternList_to_ActivationList, U"Net & PatternList: To ActivationList", nullptr) { |
| 1625 | CHOICE_ENUM (kLayer_activationType, activationType, |
| 1626 | U"Activation type", kLayer_activationType::DETERMINISTIC) |
| 1627 | OK |
| 1628 | DO |
| 1629 | CONVERT_ONE_AND_ONE_TO_ONE (Net, PatternList) |
| 1630 | autoActivationList result = Net_PatternList_to_ActivationList (me, you, activationType); |
| 1631 | CONVERT_ONE_AND_ONE_TO_ONE_END (my name.get(), U"_", your name.get()) |
| 1632 | } |
| 1633 | |
| 1634 | // MARK: - NOULLIGRID |
| 1635 | |
| 1636 | // MARK: View & Edit |
| 1637 | |
| 1638 | DIRECT (EDITOR_ONE_WITH_ONE__NoulliGrid_viewAndEdit) { |
| 1639 | EDITOR_ONE_WITH_ONE (a,NoulliGrid, Sound) // Sound may be null |
| 1640 | autoNoulliGridEditor editor = NoulliGridEditor_create (ID_AND_FULL_NAME, me, you); |
| 1641 | EDITOR_ONE_WITH_ONE_END |
| 1642 | } |
| 1643 | |
| 1644 | FORM (QUERY_ONE_FOR_REAL_VECTOR__NoulliGrid_getAverageProbabilities, U"NoulliGrid: Get average probabilities", nullptr) { |
| 1645 | NATURAL (tierNumber, U"Tier number", U"1") |
| 1646 | REAL (fromTime, U"From time (s)", U"0") |
| 1647 | REAL (toTime, U"To time (s)", U"10.0") |
| 1648 | OK |
| 1649 | DO |
| 1650 | QUERY_ONE_FOR_REAL_VECTOR (NoulliGrid) |
| 1651 | autoVEC result = NoulliGrid_getAverageProbabilities (me, tierNumber, fromTime, toTime); |
| 1652 | QUERY_ONE_FOR_REAL_VECTOR_END |
| 1653 | } |
| 1654 | |
| 1655 | FORM (GRAPHICS_NoulliGrid_paint, U"NoulliGrid: Paint", U"NoulliGrid: Paint...") { |
| 1656 | praat_TimeFunction_RANGE (fromTime, toTime) |
| 1657 | BOOLEAN (garnish, U"Garnish", 1) |
| 1658 | OK |
| 1659 | DO |
| 1660 | GRAPHICS_EACH (NoulliGrid) |
| 1661 | NoulliGrid_paint (me, GRAPHICS, fromTime, toTime, garnish); |
| 1662 | GRAPHICS_EACH_END |
| 1663 | } |
| 1664 | |
| 1665 | // MARK: - CUBEGRID |
| 1666 | |
| 1667 | // MARK: View & Edit |
| 1668 | |
| 1669 | DIRECT (EDITOR_ONE_WITH_ONE__CubeGrid_viewAndEdit) { |
| 1670 | EDITOR_ONE_WITH_ONE (a,CubeGrid, Sound) // Sound may be null |
| 1671 | autoCubeGridEditor editor = CubeGridEditor_create (ID_AND_FULL_NAME, me, you); |
| 1672 | EDITOR_ONE_WITH_ONE_END |
| 1673 | } |
| 1674 | |
| 1675 | FORM (QUERY_ONE_FOR_REAL_VECTOR__CubeGrid_getAverage, U"CubeGrid: Get average", nullptr) { |
| 1676 | NATURAL (tierNumber, U"Tier number", U"1") |
| 1677 | REAL (fromTime, U"From time (s)", U"0") |
| 1678 | REAL (toTime, U"To time (s)", U"10.0") |
| 1679 | OK |
| 1680 | DO |
| 1681 | QUERY_ONE_FOR_REAL_VECTOR (CubeGrid) |
| 1682 | autoVEC result = CubeGrid_getAverages (me, tierNumber, fromTime, toTime); |
| 1683 | QUERY_ONE_FOR_REAL_VECTOR_END |
| 1684 | } |
| 1685 | |
| 1686 | FORM (GRAPHICS_CubeGrid_paint, U"CubeGrid: Paint", U"CubeGrid: Paint...") { |
| 1687 | praat_TimeFunction_RANGE (fromTime, toTime) |
| 1688 | BOOLEAN (garnish, U"Garnish", 1) |
| 1689 | OK |
| 1690 | DO |
| 1691 | GRAPHICS_EACH (CubeGrid) |
| 1692 | CubeGrid_paint (me, GRAPHICS, fromTime, toTime, garnish); |
| 1693 | GRAPHICS_EACH_END |
| 1694 | } |
| 1695 | |
| 1696 | // MARK: - buttons |
| 1697 | |
| 1698 | void praat_uvafon_gram_init (); |
| 1699 | void praat_uvafon_gram_init () { |
| 1700 | Thing_recognizeClassesByName (classNetwork, |
| 1701 | classOTGrammar, classOTHistory, classOTMulti, |
| 1702 | classRBMLayer, classFullyConnectedLayer, classNet, |
| 1703 | classNoulliTier, classNoulliGrid, classCubeGrid |
| 1704 | ); |
| 1705 | Thing_recognizeClassByOtherName (classOTGrammar, U"OTCase"); |
| 1706 | |
| 1707 | structNoulliGridEditor :: f_preferences (); |
| 1708 | structCubeGridEditor :: f_preferences (); |
| 1709 | |
| 1710 | praat_addMenuCommand (U"Objects", U"New", U"Constraint grammars", nullptr, 0, nullptr); |
| 1711 | praat_addMenuCommand (U"Objects", U"New", U"OT learning tutorial", nullptr, GuiMenu_DEPTH_1 | GuiMenu_NO_API, |
| 1712 | HELP__OT_learning_tutorial); |
| 1713 | praat_addMenuCommand (U"Objects", U"New", U"-- tableau grammars --", nullptr, 1, nullptr); |
| 1714 | praat_addMenuCommand (U"Objects", U"New", U"Create NoCoda grammar", nullptr, 1, |
| 1715 | CREATE_ONE__Create_NoCoda_grammar); |
| 1716 | praat_addMenuCommand (U"Objects", U"New", U"Create place assimilation grammar", nullptr, 1, |
| 1717 | CREATE_ONE__Create_NPA_grammar); |
| 1718 | praat_addMenuCommand (U"Objects", U"New", U"Create place assimilation distribution", nullptr, 1, |
| 1719 | CREATE_ONE__Create_NPA_distribution); |
| 1720 | praat_addMenuCommand (U"Objects", U"New", U"Create tongue-root grammar...", nullptr, 1, |
| 1721 | CREATE_ONE__Create_tongue_root_grammar); |
| 1722 | praat_addMenuCommand (U"Objects", U"New", U"Create metrics grammar...", nullptr, 1, |
| 1723 | CREATE_ONE__Create_metrics_grammar); |
| 1724 | praat_addMenuCommand (U"Objects", U"New", U"Create multi-level metrics grammar...", nullptr, 1, |
| 1725 | CREATE_ONE__Create_multi_level_metrics_grammar); |
| 1726 | praat_addAction1 (classOTGrammar, 1, U"Save as headerless spreadsheet file... || Write to headerless spreadsheet file...", nullptr, 0, |
| 1727 | SAVE_ONE__OTGrammar_writeToHeaderlessSpreadsheetFile); // alternative COMPATIBILITY <= 2011 |
| 1728 | |
| 1729 | praat_addAction1 (classOTGrammar, 0, U"OTGrammar help", nullptr, 0, |
| 1730 | HELP__OTGrammar_help); |
| 1731 | praat_addAction1 (classOTGrammar, 0, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 1732 | EDITOR_ONE__OTGrammar_viewAndEdit); |
| 1733 | praat_addAction1 (classOTGrammar, 0, U"Draw", nullptr, 0, nullptr); |
| 1734 | praat_addAction1 (classOTGrammar, 0, U"Draw tableau...", nullptr, 0, |
| 1735 | GRAPHICS_EACH__OTGrammar_drawTableau); |
| 1736 | praat_addAction1 (classOTGrammar, 0, U"Draw tableau (narrowly)...", nullptr, 0, |
| 1737 | GRAPHICS_EACH__OTGrammar_drawTableau_narrowly); |
| 1738 | praat_addAction1 (classOTGrammar, 0, U"Query -", nullptr, 0, nullptr); |
| 1739 | praat_addAction1 (classOTGrammar, 1, U"Get number of constraints", nullptr, 1, |
| 1740 | QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfConstraints); |
| 1741 | praat_addAction1 (classOTGrammar, 1, U"Get constraint...", nullptr, 1, |
| 1742 | QUERY_ONE_FOR_STRING__OTGrammar_getConstraint); |
| 1743 | praat_addAction1 (classOTGrammar, 1, U"Get ranking value...", nullptr, 1, |
| 1744 | QUERY_ONE_FOR_REAL__OTGrammar_getRankingValue); |
| 1745 | praat_addAction1 (classOTGrammar, 1, U"Get disharmony...", nullptr, 1, |
| 1746 | QUERY_ONE_FOR_REAL__OTGrammar_getDisharmony); |
| 1747 | praat_addAction1 (classOTGrammar, 1, U"Get number of tableaus", nullptr, 1, |
| 1748 | QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfTableaus); |
| 1749 | praat_addAction1 (classOTGrammar, 1, U"Get input...", nullptr, 1, |
| 1750 | QUERY_ONE_FOR_STRING__OTGrammar_getInput); |
| 1751 | praat_addAction1 (classOTGrammar, 1, U"Get number of candidates...", nullptr, 1, |
| 1752 | QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfCandidates); |
| 1753 | praat_addAction1 (classOTGrammar, 1, U"Get candidate...", nullptr, 1, |
| 1754 | QUERY_ONE_FOR_STRING__OTGrammar_getCandidate); |
| 1755 | praat_addAction1 (classOTGrammar, 1, U"Get number of violations...", nullptr, 1, |
| 1756 | QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfViolations); |
| 1757 | praat_addAction1 (classOTGrammar, 1, U"Are all outputs distinguishable?", nullptr, 1, |
| 1758 | QUERY_ONE_FOR_BOOLEAN__OTGrammar_areAllOutputsDistinguishable); |
| 1759 | praat_addAction1 (classOTGrammar, 1, U"Tabulate equivalent pairs", nullptr, 1, |
| 1760 | CONVERT_EACH_TO_ONE_OTGrammar_tabulateEquivalentPairs); |
| 1761 | praat_addAction1 (classOTGrammar, 1, U"-- parse --", nullptr, 1, nullptr); |
| 1762 | praat_addAction1 (classOTGrammar, 1, U"Get winner...", nullptr, 1, |
| 1763 | QUERY_ONE_FOR_INTEGER__OTGrammar_getWinner); |
| 1764 | praat_addAction1 (classOTGrammar, 1, U"Compare candidates...", nullptr, 1, |
| 1765 | QUERY_ONE_FOR_INTEGER__OTGrammar_compareCandidates); |
| 1766 | praat_addAction1 (classOTGrammar, 1, U"Get number of optimal candidates...", nullptr, 1, |
| 1767 | QUERY_ONE_FOR_INTEGER__OTGrammar_getNumberOfOptimalCandidates); |
| 1768 | praat_addAction1 (classOTGrammar, 1, U"Is candidate grammatical...", nullptr, 1, |
| 1769 | QUERY_ONE_FOR_BOOLEAN__OTGrammar_isCandidateGrammatical); |
| 1770 | praat_addAction1 (classOTGrammar, 1, U"Is candidate singly grammatical...", nullptr, 1, |
| 1771 | QUERY_ONE_FOR_BOOLEAN__OTGrammar_isCandidateSinglyGrammatical); |
| 1772 | praat_addAction1 (classOTGrammar, 1, U"Get interpretive parse...", nullptr, 1, |
| 1773 | INFO_ONE__OTGrammar_getInterpretiveParse); |
| 1774 | praat_addAction1 (classOTGrammar, 1, U"Is partial output grammatical...", nullptr, 1, |
| 1775 | QUERY_ONE_FOR_BOOLEAN__OTGrammar_isPartialOutputGrammatical); |
| 1776 | praat_addAction1 (classOTGrammar, 1, U"Is partial output singly grammatical...", nullptr, 1, |
| 1777 | QUERY_ONE_FOR_BOOLEAN__OTGrammar_isPartialOutputSinglyGrammatical); |
| 1778 | praat_addAction1 (classOTGrammar, 0, U"Generate inputs...", nullptr, 0, |
| 1779 | CONVERT_EACH_TO_ONE__OTGrammar_generateInputs); |
| 1780 | praat_addAction1 (classOTGrammar, 0, U"Get inputs", nullptr, 0, |
| 1781 | CONVERT_EACH_TO_ONE__OTGrammar_getInputs); |
| 1782 | praat_addAction1 (classOTGrammar, 0, U"Measure typology", nullptr, 0, |
| 1783 | CONVERT_EACH_WEAK_TO_ONE__OTGrammar_measureTypology); |
| 1784 | praat_addAction1 (classOTGrammar, 0, U"Evaluate", nullptr, 0, nullptr); |
| 1785 | praat_addAction1 (classOTGrammar, 0, U"Evaluate...", nullptr, 0, |
| 1786 | MODIFY_EACH__OTGrammar_evaluate); |
| 1787 | praat_addAction1 (classOTGrammar, 0, U"Input to output...", nullptr, 0, |
| 1788 | QUERY_ONE_WEAK_FOR_STRING__OTGrammar_inputToOutput); |
| 1789 | praat_addAction1 (classOTGrammar, 0, U"Input to outputs...", nullptr, 0, |
| 1790 | CONVERT_EACH_WEAK_TO_ONE__OTGrammar_inputToOutputs); |
| 1791 | praat_addAction1 (classOTGrammar, 0, U"To output Distributions...", nullptr, 0, |
| 1792 | CONVERT_EACH_WEAK_TO_ONE__OTGrammar_to_Distributions); |
| 1793 | praat_addAction1 (classOTGrammar, 0, U"To PairDistribution...", nullptr, 0, |
| 1794 | CONVERT_EACH_WEAK_TO_ONE__OTGrammar_to_PairDistribution); |
| 1795 | praat_addAction1 (classOTGrammar, 0, U"Modify ranking -", nullptr, 0, nullptr); |
| 1796 | praat_addAction1 (classOTGrammar, 0, U"Set ranking...", nullptr, 1, |
| 1797 | MODIFY_EACH__OTGrammar_setRanking); |
| 1798 | praat_addAction1 (classOTGrammar, 0, U"Reset all rankings...", nullptr, 1, |
| 1799 | MODIFY_EACH__OTGrammar_resetAllRankings); |
| 1800 | praat_addAction1 (classOTGrammar, 0, U"Reset to random ranking...", nullptr, 1, |
| 1801 | MODIFY_EACH__OTGrammar_resetToRandomRanking); |
| 1802 | praat_addAction1 (classOTGrammar, 0, U"Reset to random total ranking...", nullptr, 1, |
| 1803 | MODIFY_EACH__OTGrammar_resetToRandomTotalRanking); |
| 1804 | praat_addAction1 (classOTGrammar, 0, U"Learn one...", nullptr, 1, |
| 1805 | MODIFY_EACH_WEAK__OTGrammar_learnOne); |
| 1806 | praat_addAction1 (classOTGrammar, 0, U"Learn one from partial output...", nullptr, 1, |
| 1807 | MODIFY_EACH_WEAK__OTGrammar_learnOneFromPartialOutput); |
| 1808 | praat_addAction1 (classOTGrammar, 0, U"Modify behaviour -", nullptr, 0, nullptr); |
| 1809 | praat_addAction1 (classOTGrammar, 1, U"Set decision strategy... || Set harmony computation method...", |
| 1810 | nullptr, 1, MODIFY_EACH__OTGrammar_setDecisionStrategy); |
| 1811 | praat_addAction1 (classOTGrammar, 1, U"Set leak...", nullptr, 1, |
| 1812 | MODIFY_EACH__OTGrammar_setLeak); |
| 1813 | praat_addAction1 (classOTGrammar, 1, U"Set constraint plasticity...", nullptr, 1, |
| 1814 | MODIFY_EACH__OTGrammar_setConstraintPlasticity); |
| 1815 | praat_addAction1 (classOTGrammar, 0, U"Modify structure -", nullptr, 0, nullptr); |
| 1816 | praat_addAction1 (classOTGrammar, 0, U"Remove constraint...", nullptr, 1, |
| 1817 | MODIFY_EACH__OTGrammar_removeConstraint); |
| 1818 | praat_addAction1 (classOTGrammar, 0, U"Remove harmonically bounded candidates...", nullptr, 1, |
| 1819 | MODIFY_EACH__OTGrammar_removeHarmonicallyBoundedCandidates); |
| 1820 | |
| 1821 | praat_TableOfReal_init (classOTHistory); |
| 1822 | |
| 1823 | praat_addAction1 (classOTMulti, 0, U"View & Edit || Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 1824 | EDITOR_ONE__OTMulti_viewAndEdit); |
| 1825 | praat_addAction1 (classOTMulti, 0, U"Draw -", nullptr, 0, nullptr); |
| 1826 | praat_addAction1 (classOTMulti, 0, U"Draw tableau...", nullptr, 1, |
| 1827 | GRAPHICS_EACH__OTMulti_drawTableau); |
| 1828 | praat_addAction1 (classOTMulti, 0, U"Draw tableau (narrowly)...", nullptr, 1, |
| 1829 | GRAPHICS_EACH__OTMulti_drawTableau_narrowly); |
| 1830 | praat_addAction1 (classOTMulti, 0, U"Query -", nullptr, 0, nullptr); |
| 1831 | praat_addAction1 (classOTMulti, 1, U"Get number of constraints", nullptr, 1, |
| 1832 | QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfConstraints); |
| 1833 | praat_addAction1 (classOTMulti, 1, U"Get constraint...", nullptr, 1, |
| 1834 | QUERY_ONE_FOR_STRING__OTMulti_getConstraint); |
| 1835 | praat_addAction1 (classOTMulti, 1, U"Get constraint number...", nullptr, 1, |
| 1836 | QUERY_ONE_FOR_INTEGER__OTMulti_getConstraintIndexFromName); |
| 1837 | praat_addAction1 (classOTMulti, 1, U"Get ranking value...", nullptr, 1, |
| 1838 | QUERY_ONE_FOR_REAL__OTMulti_getRankingValue); |
| 1839 | praat_addAction1 (classOTMulti, 1, U"Get disharmony...", nullptr, 1, |
| 1840 | QUERY_ONE_FOR_REAL__OTMulti_getDisharmony); |
| 1841 | praat_addAction1 (classOTMulti, 1, U"Get number of candidates", nullptr, 1, |
| 1842 | QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfCandidates); |
| 1843 | praat_addAction1 (classOTMulti, 1, U"Get candidate...", nullptr, 1, |
| 1844 | QUERY_ONE_FOR_STRING__OTMulti_getCandidate); |
| 1845 | praat_addAction1 (classOTMulti, 1, U"Get number of violations...", nullptr, 1, |
| 1846 | QUERY_ONE_FOR_INTEGER__OTMulti_getNumberOfViolations); |
| 1847 | praat_addAction1 (classOTMulti, 1, U"-- parse --", nullptr, 1, nullptr); |
| 1848 | praat_addAction1 (classOTMulti, 1, U"Get winner...", nullptr, 1, |
| 1849 | QUERY_ONE_FOR_INTEGER__OTMulti_getWinner); |
| 1850 | praat_addAction1 (classOTMulti, 0, U"Evaluate", nullptr, 0, nullptr); |
| 1851 | praat_addAction1 (classOTMulti, 0, U"Evaluate...", nullptr, 1, |
| 1852 | MODIFY_EACH__OTMulti_evaluate); |
| 1853 | praat_addAction1 (classOTMulti, 0, U"Get output...", nullptr, 1, |
| 1854 | QUERY_ONE_WEAK_FOR_STRING__OTMulti_generateOptimalForm); |
| 1855 | praat_addAction1 (classOTMulti, 0, U"Get outputs...", nullptr, 1, |
| 1856 | CONVERT_EACH_WEAK_TO_ONE__OTMulti_generateOptimalForms); |
| 1857 | praat_addAction1 (classOTMulti, 0, U"To output Distribution...", nullptr, 1, |
| 1858 | CONVERT_EACH_WEAK_TO_ONE__OTMulti_to_Distribution); |
| 1859 | praat_addAction1 (classOTMulti, 0, U"Modify ranking", nullptr, 0, nullptr); |
| 1860 | praat_addAction1 (classOTMulti, 0, U"Set ranking...", nullptr, 0, |
| 1861 | MODIFY_EACH__OTMulti_setRanking); |
| 1862 | praat_addAction1 (classOTMulti, 0, U"Reset all rankings...", nullptr, 0, |
| 1863 | MODIFY_EACH__OTMulti_resetAllRankings); |
| 1864 | praat_addAction1 (classOTMulti, 0, U"Learn one...", nullptr, 0, |
| 1865 | MODIFY_EACH_WEAK__OTMulti_learnOne); |
| 1866 | praat_addAction1 (classOTMulti, 0, U"Modify behaviour -", nullptr, 0, nullptr); |
| 1867 | praat_addAction1 (classOTMulti, 1, U"Set decision strategy...", nullptr, 1, |
| 1868 | MODIFY_EACH__OTMulti_setDecisionStrategy); |
| 1869 | praat_addAction1 (classOTMulti, 1, U"Set leak...", nullptr, 1, |
| 1870 | MODIFY_EACH__OTMulti_setLeak); |
| 1871 | praat_addAction1 (classOTMulti, 1, U"Set constraint plasticity...", nullptr, 1, |
| 1872 | MODIFY_EACH__OTMulti_setConstraintPlasticity); |
| 1873 | praat_addAction1 (classOTMulti, 0, U"Modify structure -", nullptr, 0, nullptr); |
| 1874 | praat_addAction1 (classOTMulti, 0, U"Remove constraint...", nullptr, 1, |
| 1875 | MODIFY_EACH__OTMulti_removeConstraint); |
| 1876 | |
| 1877 | praat_addAction2 (classOTGrammar, 1, classStrings, 1, U"Query -", nullptr, 0, nullptr); |
| 1878 | praat_addAction2 (classOTGrammar, 1, classStrings, 1, U"Are all partial outputs grammatical?", nullptr, 1, |
| 1879 | QUERY_ONE_AND_ONE_FOR_BOOLEAN__OTGrammar_Strings_areAllPartialOutputsGrammatical); |
| 1880 | praat_addAction2 (classOTGrammar, 1, classStrings, 1, U"Are all partial outputs singly grammatical?", nullptr, 1, |
| 1881 | QUERY_ONE_AND_ONE_FOR_BOOLEAN__OTGrammar_Strings_areAllPartialOutputsSinglyGrammatical); |
| 1882 | praat_addAction2 (classOTGrammar, 1, classStrings, 1, U"Inputs to outputs...", nullptr, 0, |
| 1883 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE__OTGrammar_Strings_inputsToOutputs); |
| 1884 | praat_addAction2 (classOTGrammar, 1, classStrings, 1, U"Learn from partial outputs...", nullptr, 0, |
| 1885 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Strings_learnFromPartialOutputs); |
| 1886 | praat_addAction2 (classOTGrammar, 1, classStrings, 2, U"Learn...", nullptr, 0, |
| 1887 | MODIFY_FIRST_OF_ONE_WEAK_AND_TWO__OTGrammar_Stringses_learn); |
| 1888 | praat_addAction2 (classOTGrammar, 1, classStrings, 2, U"Tabulate all correct rankings", nullptr, 0, |
| 1889 | CONVERT_ONE_AND_TWO_TO_ONE__OTGrammar_Stringses_tabulateAllCorrectRankings); |
| 1890 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"Learn from partial outputs...", nullptr, 0, |
| 1891 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs); |
| 1892 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"Learn from partial outputs (rrip)...", nullptr, 0, |
| 1893 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_rrip); |
| 1894 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"Learn from partial outputs (eip)...", nullptr, 0, |
| 1895 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_eip); |
| 1896 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"Learn from partial outputs (wrip)...", nullptr, 0, |
| 1897 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTGrammar_Distributions_learnFromPartialOutputs_wrip); |
| 1898 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"Get fraction correct...", nullptr, 0, |
| 1899 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL__OTGrammar_Distributions_getFractionCorrect); |
| 1900 | praat_addAction2 (classOTGrammar, 1, classDistributions, 1, U"List obligatory rankings...", nullptr, GuiMenu_HIDDEN, |
| 1901 | INFO_ONE_AND_ONE__OTGrammar_Distributions_listObligatoryRankings); |
| 1902 | praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, U"Learn...", nullptr, 0, |
| 1903 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE__OTGrammar_PairDistribution_learn); |
| 1904 | praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, U"Find positive weights...", nullptr, 0, |
| 1905 | MODIFY_FIRST_OF_ONE_AND_ONE__OTGrammar_PairDistribution_findPositiveWeights); |
| 1906 | praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, U"Get fraction correct...", nullptr, 0, |
| 1907 | QUERY_ONE_WEAK_AND_ONE_FOR_REAL__OTGrammar_PairDistribution_getFractionCorrect); |
| 1908 | praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, U"Get minimum number correct...", nullptr, 0, |
| 1909 | QUERY_ONE_WEAK_AND_ONE_FOR_INTEGER__OTGrammar_PairDistribution_getMinimumNumberCorrect); |
| 1910 | praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, U"List obligatory rankings", nullptr, 0, |
| 1911 | INFO_ONE_AND_ONE__OTGrammar_PairDistribution_listObligatoryRankings); |
| 1912 | praat_addAction2 (classOTMulti, 1, classPairDistribution, 1, U"Learn...", nullptr, 0, |
| 1913 | MODIFY_FIRST_OF_ONE_WEAK_AND_ONE_WITH_HISTORY__OTMulti_PairDistribution_learn); |
| 1914 | praat_addAction2 (classOTMulti, 1, classStrings, 1, U"Get outputs...", nullptr, 0, |
| 1915 | CONVERT_ONE_WEAK_AND_ONE_TO_ONE__OTMulti_Strings_generateOptimalForms); |
| 1916 | |
| 1917 | praat_addMenuCommand (U"Objects", U"New", U"Symmetric neural networks", nullptr, 0, nullptr); |
| 1918 | praat_addMenuCommand (U"Objects", U"New", U"Create empty Network...", nullptr, 1, |
| 1919 | CREATE_ONE__Create_empty_Network); |
| 1920 | praat_addMenuCommand (U"Objects", U"New", U"Create rectangular Network...", nullptr, 1, |
| 1921 | CREATE_ONE__Create_rectangular_Network); |
| 1922 | praat_addMenuCommand (U"Objects", U"New", U"Create rectangular Network (vertical)...", nullptr, 1, |
| 1923 | CREATE_ONE__Create_rectangular_Network_vertical); |
| 1924 | praat_addMenuCommand (U"Objects", U"New", U"Create Net as deep belief network...", nullptr, 1, |
| 1925 | CREATE_ONE__CreateNetAsDeepBeliefNetwork); |
| 1926 | |
| 1927 | praat_addAction1 (classNetwork, 0, U"Draw...", nullptr, 0, |
| 1928 | GRAPHICS_EACH__Network_draw); |
| 1929 | praat_addAction1 (classNetwork, 1, U"Tabulate -", nullptr, 0, nullptr); |
| 1930 | praat_addAction1 (classNetwork, 1, U"List nodes...", nullptr, 1, |
| 1931 | INFO_ONE__Network_listNodes); |
| 1932 | praat_addAction1 (classNetwork, 1, U"Nodes down to table...", nullptr, 1, |
| 1933 | CONVERT_EACH_TO_ONE__Network_nodes_downto_Table); |
| 1934 | praat_addAction1 (classNetwork, 0, U"Query -", nullptr, 0, nullptr); |
| 1935 | praat_addAction1 (classNetwork, 1, U"Get activity...", nullptr, 1, |
| 1936 | QUERY_ONE_FOR_REAL__Network_getActivity); |
| 1937 | praat_addAction1 (classNetwork, 1, U"Get activities...", nullptr, 1, |
| 1938 | QUERY_ONE_FOR_REAL_VECTOR__Network_getActivities); |
| 1939 | praat_addAction1 (classNetwork, 1, U"Get weight...", nullptr, 1, |
| 1940 | QUERY_ONE_FOR_REAL__Network_getWeight); |
| 1941 | praat_addAction1 (classNetwork, 0, U"Modify -", nullptr, 0, nullptr); |
| 1942 | praat_addAction1 (classNetwork, 0, U"Add node...", nullptr, 1, |
| 1943 | MODIFY_EACH__Network_addNode); |
| 1944 | praat_addAction1 (classNetwork, 0, U"Add connection...", nullptr, 1, |
| 1945 | MODIFY_EACH__Network_addConnection); |
| 1946 | praat_addAction1 (classNetwork, 0, U"-- activity --", nullptr, 1, nullptr); |
| 1947 | praat_addAction1 (classNetwork, 0, U"Set activity...", nullptr, 1, |
| 1948 | MODIFY_EACH__Network_setActivity); |
| 1949 | praat_addAction1 (classNetwork, 0, U"Set clamping...", nullptr, 1, |
| 1950 | MODIFY_EACH__Network_setClamping); |
| 1951 | praat_addAction1 (classNetwork, 0, U"Zero activities...", nullptr, 1, |
| 1952 | MODIFY_EACH__Network_zeroActivities); |
| 1953 | praat_addAction1 (classNetwork, 0, U"Normalize activities...", nullptr, 1, |
| 1954 | MODIFY_EACH__Network_normalizeActivities); |
| 1955 | praat_addAction1 (classNetwork, 0, U"Formula (activities)...", nullptr, 1, |
| 1956 | MODIFY_EACH_WEAK__Network_formula_activities); |
| 1957 | praat_addAction1 (classNetwork, 0, U"Spread activities...", nullptr, 1, |
| 1958 | MODIFY_EACH__Network_spreadActivities); |
| 1959 | praat_addAction1 (classNetwork, 0, U"Set activity clipping rule...", nullptr, 1, |
| 1960 | MODIFY_EACH__Network_setActivityClippingRule); |
| 1961 | praat_addAction1 (classNetwork, 0, U"Set activity leak...", nullptr, 1, |
| 1962 | MODIFY_EACH__Network_setActivityLeak); |
| 1963 | praat_addAction1 (classNetwork, 0, U"Set shunting...", nullptr, 1, |
| 1964 | MODIFY_EACH__Network_setShunting); |
| 1965 | praat_addAction1 (classNetwork, 0, U"-- weight --", nullptr, 1, nullptr); |
| 1966 | praat_addAction1 (classNetwork, 0, U"Set weight...", nullptr, 1, |
| 1967 | MODIFY_EACH__Network_setWeight); |
| 1968 | praat_addAction1 (classNetwork, 0, U"Update weights", nullptr, 1, |
| 1969 | MODIFY_EACH__Network_updateWeights); |
| 1970 | praat_addAction1 (classNetwork, 0, U"Normalize weights...", nullptr, 1, |
| 1971 | MODIFY_EACH__Network_normalizeWeights); |
| 1972 | praat_addAction1 (classNetwork, 0, U"Set instar...", nullptr, 1, |
| 1973 | MODIFY_EACH__Network_setInstar); |
| 1974 | praat_addAction1 (classNetwork, 0, U"Set outstar...", nullptr, 1, |
| 1975 | MODIFY_EACH__Network_setOutstar); |
| 1976 | praat_addAction1 (classNetwork, 0, U"Set weight leak...", nullptr, 1, |
| 1977 | MODIFY_EACH__Network_setWeightLeak); |
| 1978 | |
| 1979 | praat_addAction1 (classNet, 0, U"Query", nullptr, 0, nullptr); |
| 1980 | praat_addAction1 (classNet, 0, U"Get weights...", nullptr, 0, |
| 1981 | QUERY_ONE_FOR_MATRIX__Net_getWeights); |
| 1982 | praat_addAction1 (classNet, 0, U"Modify", nullptr, 0, nullptr); |
| 1983 | praat_addAction1 (classNet, 0, U"Spread up...", nullptr, 0, |
| 1984 | MODIFY_EACH__Net_spreadUp); |
| 1985 | praat_addAction1 (classNet, 0, U"Spread down...", nullptr, 0, |
| 1986 | MODIFY_EACH__Net_spreadDown); |
| 1987 | praat_addAction1 (classNet, 0, U"Spread up (reconstruction)", nullptr, 0, |
| 1988 | MODIFY_EACH__Net_spreadUp_reconstruction); |
| 1989 | praat_addAction1 (classNet, 0, U"Spread down (reconstruction)", nullptr, 0, |
| 1990 | MODIFY_EACH__Net_spreadDown_reconstruction); |
| 1991 | praat_addAction1 (classNet, 0, U"Sample input", nullptr, 0, |
| 1992 | MODIFY_EACH__Net_sampleInput); |
| 1993 | praat_addAction1 (classNet, 0, U"Sample output", nullptr, 0, |
| 1994 | MODIFY_EACH__Net_sampleOutput); |
| 1995 | praat_addAction1 (classNet, 0, U"Update...", nullptr, 0, |
| 1996 | MODIFY_EACH__Net_update); |
| 1997 | praat_addAction1 (classNet, 0, U"Extract", nullptr, 0, nullptr); |
| 1998 | praat_addAction1 (classNet, 0, U"Extract input activities", nullptr, 0, |
| 1999 | CONVERT_EACH_TO_ONE__Net_extractInputActivities); |
| 2000 | praat_addAction1 (classNet, 0, U"Extract output activities", nullptr, 0, |
| 2001 | CONVERT_EACH_TO_ONE__Net_extractOutputActivities); |
| 2002 | praat_addAction1 (classNet, 0, U"Extract input reconstruction", nullptr, 0, |
| 2003 | CONVERT_EACH_TO_ONE__Net_extractInputReconstruction); |
| 2004 | praat_addAction1 (classNet, 0, U"Extract output reconstruction", nullptr, 0, |
| 2005 | CONVERT_EACH_TO_ONE__Net_extractOutputReconstruction); |
| 2006 | praat_addAction1 (classNet, 0, U"Extract input biases...", nullptr, 0, |
| 2007 | CONVERT_EACH_TO_ONE__Net_extractInputBiases); |
| 2008 | praat_addAction1 (classNet, 0, U"Extract output biases...", nullptr, 0, |
| 2009 | CONVERT_EACH_TO_ONE__Net_extractOutputBiases); |
| 2010 | praat_addAction1 (classNet, 0, U"Extract weights...", nullptr, 0, |
| 2011 | CONVERT_EACH_TO_ONE__Net_extractWeights); |
| 2012 | |
| 2013 | praat_addAction2 (classNet, 1, classPatternList, 1, U"Apply to input...", nullptr, 0, |
| 2014 | MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_applyToInput); |
| 2015 | praat_addAction2 (classNet, 1, classPatternList, 1, U"Apply to output...", nullptr, 0, |
| 2016 | MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_applyToOutput); |
| 2017 | praat_addAction2 (classNet, 1, classPatternList, 1, U"Learn...", nullptr, 0, |
| 2018 | MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learn); |
| 2019 | praat_addAction2 (classNet, 1, classPatternList, 1, U"Learn by layer...", nullptr, 0, |
| 2020 | MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learnByLayer); |
| 2021 | praat_addAction2 (classNet, 1, classPatternList, 1, U"Learn (two phases)...", nullptr, 0, |
| 2022 | MODIFY_FIRST_OF_ONE_AND_ONE__Net_PatternList_learn_twoPhases); |
| 2023 | praat_addAction2 (classNet, 1, classPatternList, 1, U"To ActivationList", nullptr, 0, |
| 2024 | CONVERT_ONE_AND_ONE_TO_ONE__Net_PatternList_to_ActivationList); |
| 2025 | |
| 2026 | praat_addAction1 (classNoulliGrid, 1, U"View & Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 2027 | EDITOR_ONE_WITH_ONE__NoulliGrid_viewAndEdit); |
| 2028 | praat_addAction1 (classNoulliGrid, 0, U"Query -", nullptr, 0, nullptr); |
| 2029 | praat_TimeFunction_query_init (classNoulliGrid); |
| 2030 | praat_addAction1 (classNoulliGrid, 1, U"Get average probabilities...", nullptr, 1, |
| 2031 | QUERY_ONE_FOR_REAL_VECTOR__NoulliGrid_getAverageProbabilities); |
| 2032 | praat_addAction1 (classNoulliGrid, 0, U"Draw -", nullptr, 0, nullptr); |
| 2033 | praat_addAction1 (classNoulliGrid, 0, U"Paint...", nullptr, 1, GRAPHICS_NoulliGrid_paint); |
| 2034 | praat_addAction2 (classNoulliGrid, 1, classSound, 1, U"View & Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 2035 | EDITOR_ONE_WITH_ONE__NoulliGrid_viewAndEdit); |
| 2036 | |
| 2037 | praat_addAction1 (classCubeGrid, 1, U"View & Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 2038 | EDITOR_ONE_WITH_ONE__CubeGrid_viewAndEdit); |
| 2039 | praat_addAction1 (classCubeGrid, 0, U"Query -", nullptr, 0, nullptr); |
| 2040 | praat_TimeFunction_query_init (classCubeGrid); |
| 2041 | praat_addAction1 (classCubeGrid, 1, U"Get average...", nullptr, 1, |
| 2042 | QUERY_ONE_FOR_REAL_VECTOR__CubeGrid_getAverage); |
| 2043 | praat_addAction1 (classCubeGrid, 0, U"Draw -", nullptr, 0, nullptr); |
| 2044 | praat_addAction1 (classCubeGrid, 0, U"Paint...", nullptr, 1, GRAPHICS_CubeGrid_paint); |
| 2045 | praat_addAction2 (classCubeGrid, 1, classSound, 1, U"View & Edit", nullptr, GuiMenu_ATTRACTIVE, |
| 2046 | EDITOR_ONE_WITH_ONE__CubeGrid_viewAndEdit); |
| 2047 | } |
| 2048 | |
| 2049 | /* End of file praat_gram.cpp */ |