| 1 | /* OTGrammarEditor.cpp |
| 2 | * |
| 3 | * Copyright (C) 1997-2005,2007-2020,2022,2024,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 | /* |
| 20 | * a selection of changes: |
| 21 | * pb 2003/05/27 learnOne and learnOneFromPartialOutput |
| 22 | * pb 2008/05/31 ExponentialMaximumEntropy |
| 23 | */ |
| 24 | |
| 25 | #include "OTGrammarEditor.h"cxx . . $ `<file>/gram/OTGrammarEditor.h`/ |
| 26 | #include "EditorM.h"cxx . . $ `<file>/sys/EditorM.h`/ |
| 27 | |
| 28 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (OTGrammarEditor, HyperPage, 0); |
| 29 | |
| 30 | static void menu_cb_evaluatecxx . . $ menu_cb_evaluate(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 31 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Evaluate", nullptr) |
| 32 | REALcxx . . $ `sys/EditorM.h:95:9`! (noise, U"Noise", U"2.0") |
| 33 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 34 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 35 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Evaluate"); |
| 36 | OTGrammar_newDisharmoniescxx . . $ OTGrammar_newDisharmonies(ebbb2d2a494dd028). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), noise); |
| 37 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 38 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 39 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 40 | } |
| 41 | |
| 42 | static void menu_cb_evaluate_noise_2_0cxx . . $ menu_cb_evaluate_noise_2_0(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 43 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Evaluate (noise 2.0)"); |
| 44 | OTGrammar_newDisharmoniescxx . . $ OTGrammar_newDisharmonies(ebbb2d2a494dd028). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), 2.0); |
| 45 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 46 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 47 | } |
| 48 | |
| 49 | static void menu_cb_evaluate_tinyNoisecxx . . $ menu_cb_evaluate_tinyNoise(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 50 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Evaluate (tiny noise)"); |
| 51 | OTGrammar_newDisharmoniescxx . . $ OTGrammar_newDisharmonies(ebbb2d2a494dd028). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), 1e-9); |
| 52 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 53 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 54 | } |
| 55 | |
| 56 | static void menu_cb_evaluate_zeroNoisecxx . . $ menu_cb_evaluate_zeroNoise(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 57 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Evaluate (zero noise)"); |
| 58 | OTGrammar_newDisharmoniescxx . . $ OTGrammar_newDisharmonies(ebbb2d2a494dd028). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), 0.0); |
| 59 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 60 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 61 | } |
| 62 | |
| 63 | static void menu_cb_editConstraintcxx . . $ menu_cb_editConstraint(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 64 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Edit constraint", nullptr) |
| 65 | MUTABLE_COMMENTcxx . . $ `sys/EditorM.h:247:9`! (constraintLabel, U""); |
| 66 | REALcxx . . $ `sys/EditorM.h:95:9`! (rankingValue, U"Ranking value", U"100.0"); |
| 67 | REALcxx . . $ `sys/EditorM.h:95:9`! (disharmony, U"Disharmony", U"100.0"); |
| 68 | REALcxx . . $ `sys/EditorM.h:95:9`! (plasticity, U"Plasticity", U"1.0"); |
| 69 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 70 | if (mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected. < 1 || mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected. > mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> numberOfConstraintscxx . . $ structOTGrammar#numberOfConstraints.) |
| 71 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Select a constraint first."); |
| 72 | OTGrammarConstraintcxx . . $ OTGrammarConstraint# constraint = & mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> indexcxx . . $ structOTGrammar#index. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected.]]; |
| 73 | SET_STRINGcxx . . $ `sys/EditorM.h:477:9`! (constraintLabel, constraint -> name.get()) |
| 74 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (rankingValue, constraint -> ranking) |
| 75 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (disharmony, constraint -> disharmony) |
| 76 | SET_REALcxx . . $ `sys/EditorM.h:462:9`! (plasticity, constraint -> plasticity) |
| 77 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 78 | OTGrammarConstraintcxx . . $ OTGrammarConstraint# constraint = & mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> indexcxx . . $ structOTGrammar#index. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected.]]; |
| 79 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Edit constraint"); |
| 80 | constraint -> rankingcxx . . $ structOTGrammarConstraint#ranking. = rankingValue; |
| 81 | constraint -> disharmonycxx . . $ structOTGrammarConstraint#disharmony. = disharmony; |
| 82 | constraint -> plasticitycxx . . $ structOTGrammarConstraint#plasticity. = plasticity; |
| 83 | OTGrammar_sortcxx . . $ OTGrammar_sort(17bef8f582790df). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).()); |
| 84 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 85 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 86 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 87 | } |
| 88 | |
| 89 | static void menu_cb_learnOnecxx . . $ menu_cb_learnOne(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 90 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Learn one", U"OTGrammar: Learn one...") |
| 91 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"Underlying form:") |
| 92 | SENTENCEcxx . . $ `sys/EditorM.h:195:9`! (inputString, U"Input string", U"") |
| 93 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"Adult surface form:") |
| 94 | SENTENCEcxx . . $ `sys/EditorM.h:195:9`! (outputString, U"Output string", U"") |
| 95 | REALcxx . . $ `sys/EditorM.h:95:9`! (evaluationNoise, U"Evaluation noise", U"2.0") |
| 96 | OPTIONMENU_ENUMcxx . . $ `sys/EditorM.h:426:9`! (kOTGrammar_rerankingStrategy, updateRule, |
| 97 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 98 | REALcxx . . $ `sys/EditorM.h:95:9`! (plasticity, U"Plasticity", U"0.1") |
| 99 | REALcxx . . $ `sys/EditorM.h:95:9`! (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 100 | BOOLEANcxx . . $ `sys/EditorM.h:228:9`! (honourLocalRankings, U"Honour local rankings", true) |
| 101 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 102 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 103 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Learn one"); |
| 104 | OTGrammar_learnOnecxx . . $ OTGrammar_learnOne(ee39fc6cd929bcff). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), inputString, outputString, |
| 105 | evaluationNoise, updateRule, honourLocalRankings, |
| 106 | plasticity, relativePlasticitySpreading, true, true, nullptr); |
| 107 | OTGrammar_sortcxx . . $ OTGrammar_sort(17bef8f582790df). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).()); |
| 108 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 109 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 110 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 111 | } |
| 112 | |
| 113 | static void menu_cb_learnOneFromPartialOutputcxx . . $ menu_cb_learnOneFromPartialOutput(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 114 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Learn one from partial adult output", nullptr) |
| 115 | COMMENTcxx . . $ `sys/EditorM.h:237:9`! (U"Partial adult surface form (e.g. overt form):") |
| 116 | SENTENCEcxx . . $ `sys/EditorM.h:195:9`! (partialOutput, U"Partial output", U"") |
| 117 | REALcxx . . $ `sys/EditorM.h:95:9`! (evaluationNoise, U"Evaluation noise", U"2.0") |
| 118 | OPTIONMENU_ENUMcxx . . $ `sys/EditorM.h:426:9`! (kOTGrammar_rerankingStrategy, updateRule, |
| 119 | U"Update rule", kOTGrammar_rerankingStrategy::SYMMETRIC_ALL) |
| 120 | REALcxx . . $ `sys/EditorM.h:95:9`! (plasticity, U"Plasticity", U"0.1") |
| 121 | REALcxx . . $ `sys/EditorM.h:95:9`! (relativePlasticitySpreading, U"Rel. plasticity spreading", U"0.1") |
| 122 | BOOLEANcxx . . $ `sys/EditorM.h:228:9`! (honourLocalRankings, U"Honour local rankings", true) |
| 123 | NATURALcxx . . $ `sys/EditorM.h:173:9`! (numberOfChews, U"Number of chews", U"1") |
| 124 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 125 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 126 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Learn one from partial output"); |
| 127 | OTGrammar_learnOneFromPartialOutputcxx . . $ OTGrammar_learnOneFromPartialOutput(bf78488c347ea88b). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), partialOutput, |
| 128 | evaluationNoise, updateRule, honourLocalRankings, |
| 129 | plasticity, relativePlasticitySpreading, numberOfChews, true); |
| 130 | OTGrammar_sortcxx . . $ OTGrammar_sort(17bef8f582790df). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).()); |
| 131 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 132 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 133 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 134 | } |
| 135 | |
| 136 | static void menu_cb_removeConstraintcxx . . $ menu_cb_removeConstraint(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 137 | OTGrammarConstraintcxx . . $ OTGrammarConstraint# constraint; |
| 138 | if (mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected. < 1 || mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected. > mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> numberOfConstraintscxx . . $ structOTGrammar#numberOfConstraints.) |
| 139 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Select a constraint first."); |
| 140 | constraint = & mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> indexcxx . . $ structOTGrammar#index. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! selectedcxx . . $ structOTGrammarEditor#selected.]]; |
| 141 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Remove constraint"); |
| 142 | OTGrammar_removeConstraintcxx . . $ OTGrammar_removeConstraint(90425b6eb4fa5279). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), constraint -> namecxx . . $ structOTGrammarConstraint#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 143 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 144 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 145 | } |
| 146 | |
| 147 | static void menu_cb_resetAllRankingscxx . . $ menu_cb_resetAllRankings(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor# me, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { |
| 148 | EDITOR_FORMcxx . . $ `sys/EditorM.h:33:9`! (U"Reset all rankings", nullptr) |
| 149 | REALcxx . . $ `sys/EditorM.h:95:9`! (ranking, U"Ranking", U"100.0") |
| 150 | EDITOR_OKcxx . . $ `sys/EditorM.h:38:9`! |
| 151 | EDITOR_DOcxx . . $ `sys/EditorM.h:43:9`! |
| 152 | Editor_savecxx . . $ Editor_save(ed6f6b1571b749af). (me, U"Reset all rankings"); |
| 153 | OTGrammar_resetcxx . . $ OTGrammar_reset(ebbb2d2a494dd028). (mycxx . . $ `melder/melder.h:44:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(), ranking); |
| 154 | Graphics_updateWscxx . . $ Graphics_updateWs(2d838ed765120c5d). (mycxx . . $ `melder/melder.h:44:9`! graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 155 | Editor_broadcastDataChangedcxx . . $ Editor_broadcastDataChanged(c0154a85f79216c7). (me); |
| 156 | EDITOR_ENDcxx . . $ `sys/EditorM.h:80:9`! |
| 157 | } |
| 158 | |
| 159 | static void menu_cb_OTGrammarEditor_helpcxx . . $ menu_cb_OTGrammarEditor_help(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"OTGrammarEditor"); } |
| 160 | static void menu_cb_OTGrammar_helpcxx . . $ menu_cb_OTGrammar_help(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"OTGrammar"); } |
| 161 | static void menu_cb_OTLearningTutorialcxx . . $ menu_cb_OTLearningTutorial(e5a6fb1191b90ad). (OTGrammarEditorcxx . . $ OTGrammarEditor#, EDITOR_ARGScxx . . $ `sys/EditorM.h:25:9`!) { Melder_helpcxx . . $ Melder_help(ff00d524ab0355ec). (U"OT learning"); } |
| 162 | |
| 163 | void structOTGrammarEditorcxx . . $ structOTGrammarEditor# :: v_createMenuscxx . . $ structOTGrammarEditor#v_createMenus(49f6e7a06ebc5aa8). () { |
| 164 | OTGrammarEditor_Parentcxx . . $ OTGrammarEditor_Parent# :: v_createMenuscxx . . $ structHyperPage#v_createMenus(49f6e7a06ebc5aa8). (); |
| 165 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"-- edit ot --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 166 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Evaluate...", 0, menu_cb_evaluatecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 167 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Evaluate (noise 2.0)", '2', menu_cb_evaluate_noise_2_0cxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 168 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Evaluate (zero noise)", '0', menu_cb_evaluate_zeroNoisecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 169 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Evaluate (tiny noise)", '9', menu_cb_evaluate_tinyNoisecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 170 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Edit constraint...", 'E', menu_cb_editConstraintcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 171 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Reset all rankings...", 'R', menu_cb_resetAllRankingscxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 172 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Learn one...", 0, menu_cb_learnOnecxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 173 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Learn one from partial output...", '1', menu_cb_learnOneFromPartialOutputcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 174 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"-- remove ot --", 0, nullptrcxx . . $ MelderCallback#MelderCallback(fc624d2cd197112).); |
| 175 | Editor_addCommandcxx . . $ Editor_addCommand(d7f2c642863274c0). (this, U"Edit", U"Remove constraint", 0, menu_cb_removeConstraintcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 176 | } |
| 177 | |
| 178 | void structOTGrammarEditorcxx . . $ structOTGrammarEditor# :: v_createMenuItems_helpcxx . . $ structOTGrammarEditor#v_createMenuItems_help(6ea9c8c6ea2f58a9). (EditorMenucxx . . $ EditorMenu# menu) { |
| 179 | OTGrammarEditor_Parentcxx . . $ OTGrammarEditor_Parent# :: v_createMenuItems_helpcxx . . $ structDataGui#v_createMenuItems_help(6ea9c8c6ea2f58a9). (menu); |
| 180 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"OTGrammarEditor help", '?', menu_cb_OTGrammarEditor_helpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 181 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"OTGrammar help", 0, menu_cb_OTGrammar_helpcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 182 | EditorMenu_addCommandcxx . . $ EditorMenu_addCommand(b3c50ad5ffa1d58a). (menu, U"OT learning tutorial", 0, menu_cb_OTLearningTutorialcxx . . $ MelderCallback#MelderCallback(aaa169a015c1cf97).); |
| 183 | } |
| 184 | |
| 185 | static OTGrammarcxx . . $ OTGrammar# drawTableau_otcxx . . $ drawTableau_ot.; |
| 186 | static conststring32cxx . . $ conststring32# drawTableau_inputcxx . . $ drawTableau_input.; |
| 187 | static bool drawTableau_constraintsAreDrawnVerticallycxx . . $ drawTableau_constraintsAreDrawnVertically.; |
| 188 | static void drawTableaucxx . . $ drawTableau(2d838ed765120c5d). (Graphicscxx . . $ Graphics# g) { |
| 189 | OTGrammar_drawTableaucxx . . $ OTGrammar_drawTableau(822cef9b7e8eee15). (drawTableau_otcxx . . $ drawTableau_ot., g, drawTableau_constraintsAreDrawnVerticallycxx . . $ drawTableau_constraintsAreDrawnVertically., drawTableau_inputcxx . . $ drawTableau_input.); |
| 190 | } |
| 191 | |
| 192 | void structOTGrammarEditorcxx . . $ structOTGrammarEditor# :: v_drawcxx . . $ structOTGrammarEditor#v_draw(49f6e7a06ebc5aa8). () { |
| 193 | static char32cxx . . $ char32# text [1000]; |
| 194 | if (ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> decisionStrategycxx . . $ structOTGrammar#decisionStrategy. == kOTGrammar_decisionStrategycxx . . $ kOTGrammar_decisionStrategy#::EXPONENTIAL_HGcxx . . $ kOTGrammar_decisionStrategy#EXPONENTIAL_HG. || |
| 195 | ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> decisionStrategycxx . . $ structOTGrammar#decisionStrategy. == kOTGrammar_decisionStrategycxx . . $ kOTGrammar_decisionStrategy#::EXPONENTIAL_MAXIMUM_ENTROPYcxx . . $ kOTGrammar_decisionStrategy#EXPONENTIAL_MAXIMUM_ENTROPY.) |
| 196 | { |
| 197 | HyperPage_listItemcxx . . $ HyperPage_listItem(9d6e0dd96656f536). (this, U"\t\t %%ranking value\t %disharmony\t %plasticity\t %%e^^disharmony"); |
| 198 | } else { |
| 199 | HyperPage_listItemcxx . . $ HyperPage_listItem(9d6e0dd96656f536). (this, U"\t\t %%ranking value\t %disharmony\t %plasticity"); |
| 200 | } |
| 201 | for (integercxx . . $ integer# icons = 1; icons <= ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> numberOfConstraintscxx . . $ structOTGrammar#numberOfConstraints.; icons ++) { |
| 202 | OTGrammarConstraintcxx . . $ OTGrammarConstraint# constraint = & ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> constraintscxx . . $ structOTGrammar#constraints. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> indexcxx . . $ structOTGrammar#index. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).icons]]; |
| 203 | if (ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> decisionStrategycxx . . $ structOTGrammar#decisionStrategy. == kOTGrammar_decisionStrategycxx . . $ kOTGrammar_decisionStrategy#::EXPONENTIAL_HGcxx . . $ kOTGrammar_decisionStrategy#EXPONENTIAL_HG. || |
| 204 | ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> decisionStrategycxx . . $ structOTGrammar#decisionStrategy. == kOTGrammar_decisionStrategycxx . . $ kOTGrammar_decisionStrategy#::EXPONENTIAL_MAXIMUM_ENTROPYcxx . . $ kOTGrammar_decisionStrategy#EXPONENTIAL_MAXIMUM_ENTROPY.) |
| 205 | { |
| 206 | Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (text,1000, |
| 207 | U"\t", icons == selectedcxx . . $ structOTGrammarEditor#selected. ? U"♠︎ " : U" ", |
| 208 | U"@@", icons, |
| 209 | U"|", constraint -> namecxx . . $ structOTGrammarConstraint#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), |
| 210 | U"@\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> rankingcxx . . $ structOTGrammarConstraint#ranking., 3), |
| 211 | U"\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> disharmonycxx . . $ structOTGrammarConstraint#disharmony., 3), |
| 212 | U"\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> plasticitycxx . . $ structOTGrammarConstraint#plasticity., 6), |
| 213 | U"\t ", Melder_graphicalHalfcxx . . $ Melder_graphicalHalf(f05d861d9dbec9b2). (expcxx . . $ exp(fee4f1d22bc8e617). (constraint -> disharmonycxx . . $ structOTGrammarConstraint#disharmony.))); |
| 214 | } else { |
| 215 | Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (text,1000, |
| 216 | U"\t", icons == selectedcxx . . $ structOTGrammarEditor#selected. ? U"♠︎ " : U" ", |
| 217 | U"@@", icons, |
| 218 | U"|", constraint -> namecxx . . $ structOTGrammarConstraint#name..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), |
| 219 | U"@\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> rankingcxx . . $ structOTGrammarConstraint#ranking., 3), |
| 220 | U"\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> disharmonycxx . . $ structOTGrammarConstraint#disharmony., 3), |
| 221 | U"\t ", Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (constraint -> plasticitycxx . . $ structOTGrammarConstraint#plasticity., 6)); |
| 222 | } |
| 223 | HyperPage_listItemcxx . . $ HyperPage_listItem(9d6e0dd96656f536). (this, text); |
| 224 | } |
| 225 | Graphics_setAtSignIsLinkcxx . . $ Graphics_setAtSignIsLink(b5ae742079ad918c). (graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), false); |
| 226 | for (integercxx . . $ integer# itab = 1; itab <= ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> numberOfTableauscxx . . $ structOTGrammar#numberOfTableaus.; itab ++) { |
| 227 | OTGrammarTableaucxx . . $ OTGrammarTableau# tableau = & ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).() -> tableauscxx . . $ structOTGrammar#tableaus. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).itab]; |
| 228 | double rowHeight = 0.25; |
| 229 | double tableauHeight = rowHeight * (tableau -> numberOfCandidatescxx . . $ structOTGrammarTableau#numberOfCandidates. + 2); |
| 230 | drawTableau_otcxx . . $ drawTableau_ot. = ourcxx . . $ `melder/melder.h:42:9`! otGrammarcxx . . $ structOTGrammarEditor#otGrammar(b226cb465254cd63).(); |
| 231 | drawTableau_inputcxx . . $ drawTableau_input. = tableau -> inputcxx . . $ structOTGrammarTableau#input..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(); |
| 232 | drawTableau_constraintsAreDrawnVerticallycxx . . $ drawTableau_constraintsAreDrawnVertically. = d_constraintsAreDrawnVerticallycxx . . $ structOTGrammarEditor#d_constraintsAreDrawnVertically.; |
| 233 | HyperPage_picturecxx . . $ HyperPage_picture(33f50d1d203ff172). (this, 20, tableauHeight, drawTableaucxx . . $ drawTableau(2d838ed765120c5d).); |
| 234 | } |
| 235 | Graphics_setAtSignIsLinkcxx . . $ Graphics_setAtSignIsLink(b5ae742079ad918c). (graphicscxx . . $ structHyperPage#graphics..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), true); |
| 236 | } |
| 237 | |
| 238 | int structOTGrammarEditorcxx . . $ structOTGrammarEditor# :: v_goToPagecxx . . $ structOTGrammarEditor#v_goToPage(e049ab16a3067c7). (conststring32cxx . . $ conststring32# title) { |
| 239 | if (! title) |
| 240 | return 1; |
| 241 | selectedcxx . . $ structOTGrammarEditor#selected. = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (title); |
| 242 | return 1; |
| 243 | } |
| 244 | |
| 245 | autoOTGrammarEditorcxx . . $ autoOTGrammarEditor# OTGrammarEditor_createcxx . . $ OTGrammarEditor_create(a98b89c745782464). (conststring32cxx . . $ conststring32# title, OTGrammarcxx . . $ OTGrammar# otGrammar) { |
| 246 | try { |
| 247 | autoOTGrammarEditorcxx . . $ autoOTGrammarEditor# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (OTGrammarEditor); |
| 248 | HyperPage_initcxx . . $ HyperPage_init(7b1f2c4aafa3d0ec). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), title, otGrammar); |
| 249 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 250 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 251 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"OTGrammar window not created."); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /* End of file OTGrammarEditor.cpp */ |