| 1 | /* EditDistanceTable.cpp |
| 2 | * |
| 3 | * Copyright (C) 2012-2020,2022 David Weenink, 2025,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. See the GNU |
| 13 | * 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 "EditDistanceTable.h"cxx . . $ `<file>/dwtools/EditDistanceTable.h`/ |
| 20 | |
| 21 | #include "oo_DESTROY.h"cxx . . $ `<file>/sys/oo_DESTROY.h`/ |
| 22 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 23 | #include "oo_COPY.h"cxx . . $ `<file>/sys/oo_COPY.h`/ |
| 24 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 25 | #include "oo_EQUAL.h"cxx . . $ `<file>/sys/oo_EQUAL.h`/ |
| 26 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 27 | #include "oo_CAN_WRITE_AS_ENCODING.h"cxx . . $ `<file>/sys/oo_CAN_WRITE_AS_ENCODING.h`/ |
| 28 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 29 | #include "oo_WRITE_TEXT.h"cxx . . $ `<file>/sys/oo_WRITE_TEXT.h`/ |
| 30 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 31 | #include "oo_WRITE_BINARY.h"cxx . . $ `<file>/sys/oo_WRITE_BINARY.h`/ |
| 32 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 33 | #include "oo_READ_TEXT.h"cxx . . $ `<file>/sys/oo_READ_TEXT.h`/ |
| 34 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 35 | #include "oo_READ_BINARY.h"cxx . . $ `<file>/sys/oo_READ_BINARY.h`/ |
| 36 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 37 | #include "oo_DESCRIPTION.h"cxx . . $ `<file>/sys/oo_DESCRIPTION.h`/ |
| 38 | #include "EditDistanceTable_def.h"cxx . . $ `<file>/dwtools/EditDistanceTable_def.h`/ |
| 39 | |
| 40 | /* |
| 41 | The insertion, deletion and substitution costs are specified in a TableOfReal |
| 42 | 1..n-2 target symbols/alphabet |
| 43 | 1..m-2 source symbols/alphabet |
| 44 | row n-1 and col m-1 specify nomatch symbols |
| 45 | cells [n] [1..m-2] specify insertion costs |
| 46 | cells [1..n-1] [m] specify deletion costs |
| 47 | cell [n-1] [m-1] if nomatch target == nomatch source |
| 48 | cell [n] [m] if nomatch target != nomatch source |
| 49 | */ |
| 50 | |
| 51 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (EditCostsTable, TableOfReal, 0); |
| 52 | |
| 53 | void structEditCostsTable :: v1_info () { |
| 54 | EditCostsTable_Parent :: v1_infocxx . . $ structTableOfReal#v1_info(49f6e7a06ebc5aa8). (); |
| 55 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Target:", numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 2, U" symbols."); |
| 56 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Source:", numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 2, U" symbols."); |
| 57 | } |
| 58 | |
| 59 | bool structEditCostsTable :: v_matchTargetSymbol (conststring32cxx . . $ conststring32# targetSymbol, conststring32cxx . . $ conststring32# symbol) { |
| 60 | return Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (targetSymbol, symbol); |
| 61 | } |
| 62 | |
| 63 | bool structEditCostsTable :: v_matchSourceSymbol (conststring32cxx . . $ conststring32# sourceSymbol, conststring32cxx . . $ conststring32# symbol) { |
| 64 | return Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (sourceSymbol, symbol); |
| 65 | } |
| 66 | |
| 67 | bool structEditCostsTable :: v_matchTargetWithSourceSymbol (conststring32cxx . . $ conststring32# targetSymbol, conststring32cxx . . $ conststring32# sourceSymbol) { |
| 68 | return Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (targetSymbol, sourceSymbol); |
| 69 | } |
| 70 | |
| 71 | autoEditCostsTable EditCostsTable_createcxx . . $ EditCostsTable_create(ffc855aaf21339ed). (integercxx . . $ integer# targetAlphabetSize, integercxx . . $ integer# sourceAlphabetSize) { |
| 72 | try{ |
| 73 | autoEditCostsTable me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (EditCostsTable); |
| 74 | TableOfReal_initcxx . . $ TableOfReal_init(cfadf70b559ed315). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), targetAlphabetSize + 2, sourceAlphabetSize + 2); |
| 75 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 76 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 77 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"EditCostsTable not created."); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | static autoEditCostsTable EditCostsTable_createDefaultcxx . . $ EditCostsTable_createDefault(50cffec8c84f3fb1). () { |
| 82 | try { |
| 83 | autoEditCostsTable me = EditCostsTable_createcxx . . $ EditCostsTable_create(ffc855aaf21339ed). (0, 0); |
| 84 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 0.0; // default substitution cost (nomatch == nomatch) |
| 85 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = 2.0; // default substitution cost (nomatch != nomatch) |
| 86 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).2] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = 1.0; // default insertion cost |
| 87 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).2] = 1.0; // default deletion cost |
| 88 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 89 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 90 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Default EditCostsTable not created."); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | void EditCostsTable_setDefaultCostscxx . . $ EditCostsTable_setDefaultCosts(ee656dafc0cf1553). (EditCostsTable me, double insertionCosts, double deletionCosts, double substitutionCosts) { |
| 95 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] = 0.0; |
| 96 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] = substitutionCosts; |
| 97 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] = deletionCosts; |
| 98 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] = insertionCosts; |
| 99 | } |
| 100 | |
| 101 | integercxx . . $ integer# EditCostsTable_getTargetIndexcxx . . $ EditCostsTable_getTargetIndex(926aef4380384090). (EditCostsTable me, conststring32cxx . . $ conststring32# symbol) { |
| 102 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 2; i ++) |
| 103 | if (mycxx . . $ `melder/melder.h:44:9`! v_matchTargetSymbol (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), symbol)) |
| 104 | return i; |
| 105 | return 0; |
| 106 | } |
| 107 | |
| 108 | integercxx . . $ integer# EditCostsTable_getSourceIndexcxx . . $ EditCostsTable_getSourceIndex(926aef4380384090). (EditCostsTable me, conststring32cxx . . $ conststring32# symbol) { |
| 109 | for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 2; j ++) |
| 110 | if (mycxx . . $ `melder/melder.h:44:9`! v_matchSourceSymbol (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).j].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), symbol)) |
| 111 | return j; |
| 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | void EditCostsTable_setInsertionCostscxx . . $ EditCostsTable_setInsertionCosts(153dee49473c418e). (EditCostsTable me, conststring32cxx . . $ conststring32# targets_string, double cost) { |
| 116 | autoSTRVECcxx . . $ autoSTRVEC# targets = splitByWhitespace_STRVECcxx . . $ splitByWhitespace_STRVEC(d3c03a92d990d008). (targets_string); |
| 117 | for (integercxx . . $ integer# itarget = 1; itarget <= targets.sizecxx . . $ _autostringautovector#size.; itarget ++) { |
| 118 | integercxx . . $ integer# irow = EditCostsTable_getTargetIndexcxx . . $ EditCostsTable_getTargetIndex(926aef4380384090). (me, targets [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).itarget].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 119 | irow = ( irow > 0 ? irow : mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1 ); // nomatch condition to penultimate row |
| 120 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] = cost; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | void EditCostsTable_setDeletionCostscxx . . $ EditCostsTable_setDeletionCosts(153dee49473c418e). (EditCostsTable me, conststring32cxx . . $ conststring32# sources_string, double cost) { |
| 125 | autoSTRVECcxx . . $ autoSTRVEC# sources = splitByWhitespace_STRVECcxx . . $ splitByWhitespace_STRVEC(d3c03a92d990d008). (sources_string); |
| 126 | for (integercxx . . $ integer# isource = 1; isource <= sources.sizecxx . . $ _autostringautovector#size.; isource ++) { |
| 127 | integercxx . . $ integer# icol = EditCostsTable_getSourceIndexcxx . . $ EditCostsTable_getSourceIndex(926aef4380384090). (me, sources [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).isource].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 128 | icol = ( icol > 0 ? icol : mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1 ); // nomatch condition to penultimate column |
| 129 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = cost; |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | void EditCostsTable_setOthersCostscxx . . $ EditCostsTable_setOthersCosts(1a0fa8b55fd2cd2e). (EditCostsTable me, double insertionCost, double deletionCost, double substitutionCost_equal, double substitutionCost_unequal) { |
| 134 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] = insertionCost; |
| 135 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] = deletionCost; |
| 136 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] = substitutionCost_unequal; |
| 137 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] = substitutionCost_equal; |
| 138 | } |
| 139 | |
| 140 | double EditCostsTable_getOthersCostcxx . . $ EditCostsTable_getOthersCost(f899f17700254801). (EditCostsTable me, int costType) { |
| 141 | return ( costType == 1 ? mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] : //insertion |
| 142 | ( costType == 2 ? mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] : // deletion |
| 143 | ( costType == 3 ? mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.] : // equality |
| 144 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1] ) ) ); // inequality |
| 145 | } |
| 146 | |
| 147 | void EditCostsTable_setSubstitutionCostscxx . . $ EditCostsTable_setSubstitutionCosts(e334a315e33a476b). (EditCostsTable me, conststring32cxx . . $ conststring32# targets_string, conststring32cxx . . $ conststring32# sources_string, double cost) { |
| 148 | try { |
| 149 | autoSTRVECcxx . . $ autoSTRVEC# targets = splitByWhitespace_STRVECcxx . . $ splitByWhitespace_STRVEC(d3c03a92d990d008). (targets_string); |
| 150 | autoSTRVECcxx . . $ autoSTRVEC# sources = splitByWhitespace_STRVECcxx . . $ splitByWhitespace_STRVEC(d3c03a92d990d008). (sources_string); |
| 151 | autoINTVECcxx . . $ autoINTVEC# targetIndex = zero_INTVECcxx . . $ zero_INTVEC(dab5d3ef28d6a25). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); // note: this includes zero padding |
| 152 | autoINTVECcxx . . $ autoINTVEC# sourceIndex = zero_INTVECcxx . . $ zero_INTVEC(dab5d3ef28d6a25). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.); // note: this includes zero padding |
| 153 | integercxx . . $ integer# numberOfTargetSymbols = 0; |
| 154 | for (integercxx . . $ integer# itarget = 1; itarget <= targets.sizecxx . . $ _autostringautovector#size.; itarget ++) { |
| 155 | const integercxx . . $ integer# index = EditCostsTable_getTargetIndexcxx . . $ EditCostsTable_getTargetIndex(926aef4380384090). (me, targets [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).itarget].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 156 | if (index > 0) |
| 157 | targetIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ numberOfTargetSymbols] = index; |
| 158 | } |
| 159 | if (numberOfTargetSymbols == 0) |
| 160 | targetIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ numberOfTargetSymbols] = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; |
| 161 | integercxx . . $ integer# numberOfSourceSymbols = 0; |
| 162 | for (integercxx . . $ integer# isource = 1; isource <= sources.sizecxx . . $ _autostringautovector#size.; isource ++) { |
| 163 | const integercxx . . $ integer# index = EditCostsTable_getSourceIndexcxx . . $ EditCostsTable_getSourceIndex(926aef4380384090). (me, sources [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).isource].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 164 | if (index > 0) |
| 165 | sourceIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ numberOfSourceSymbols] = index; |
| 166 | } |
| 167 | if (numberOfSourceSymbols == 0) |
| 168 | sourceIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).++ numberOfSourceSymbols] = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1; |
| 169 | for (integercxx . . $ integer# i = 1; i <= numberOfTargetSymbols; i ++) { |
| 170 | const integercxx . . $ integer# irow = targetIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 171 | for (integercxx . . $ integer# j = 1; j <= numberOfSourceSymbols; j ++) |
| 172 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).sourceIndex [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j]] = cost; |
| 173 | } |
| 174 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 175 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": substitution costs not set."); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | double EditCostsTable_getInsertionCostcxx . . $ EditCostsTable_getInsertionCost(fbdb87be0d9cf51f). (EditCostsTable me, conststring32cxx . . $ conststring32# symbol) { |
| 180 | integercxx . . $ integer# irow = EditCostsTable_getTargetIndexcxx . . $ EditCostsTable_getTargetIndex(926aef4380384090). (me, symbol); |
| 181 | irow = ( irow == 0 ? mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1 : irow ); // others is penultimate row |
| 182 | return mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.]; |
| 183 | } |
| 184 | |
| 185 | double EditCostsTable_getDeletionCostcxx . . $ EditCostsTable_getDeletionCost(fbdb87be0d9cf51f). (EditCostsTable me, conststring32cxx . . $ conststring32# sourceSymbol) { |
| 186 | integercxx . . $ integer# icol = EditCostsTable_getSourceIndexcxx . . $ EditCostsTable_getSourceIndex(926aef4380384090). (me, sourceSymbol); |
| 187 | icol = ( icol == 0 ? mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1 : icol ); // others is penultimate column |
| 188 | return mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]; |
| 189 | } |
| 190 | |
| 191 | double EditCostsTable_getSubstitutionCostcxx . . $ EditCostsTable_getSubstitutionCost(6f9442b9cfe3c120). (EditCostsTable me, conststring32cxx . . $ conststring32# symbol, conststring32cxx . . $ conststring32# replacement) { |
| 192 | integercxx . . $ integer# irow = EditCostsTable_getTargetIndexcxx . . $ EditCostsTable_getTargetIndex(926aef4380384090). (me, symbol); |
| 193 | integercxx . . $ integer# icol = EditCostsTable_getSourceIndexcxx . . $ EditCostsTable_getSourceIndex(926aef4380384090). (me, replacement); |
| 194 | if (irow == 0 && icol == 0) { // nomatch |
| 195 | irow = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 196 | icol = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; |
| 197 | if (mycxx . . $ `melder/melder.h:44:9`! v_matchTargetWithSourceSymbol (symbol, replacement)) { |
| 198 | -- irow; |
| 199 | -- icol; |
| 200 | } |
| 201 | } else { |
| 202 | irow = ( irow == 0 ? mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1 : irow ); |
| 203 | icol = ( icol == 0 ? mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1 : icol ); |
| 204 | } |
| 205 | return mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]; |
| 206 | } |
| 207 | |
| 208 | autoTableOfRealcxx . . $ autoTableOfReal# EditCostsTable_to_TableOfRealcxx . . $ EditCostsTable_to_TableOfReal(af89b4e4b58c938a). (EditCostsTable me) { |
| 209 | try { |
| 210 | autoTableOfRealcxx . . $ autoTableOfReal# thee = TableOfReal_createcxx . . $ TableOfReal_create(e573ed3514e79d3). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 211 | thycxx . . $ `melder/melder.h:45:9`! columnLabelscxx . . $ structTableOfReal#columnLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).() <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 212 | thycxx . . $ `melder/melder.h:45:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).() <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 213 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 214 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 215 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 216 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to TableOfReal."); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | Thing_implementcxx . . $ `sys/Thing.h:65:9`! (EditDistanceTable, TableOfReal, 0); |
| 221 | |
| 222 | void structEditDistanceTable :: v1_info () { |
| 223 | EditDistanceTable_Parent :: v1_infocxx . . $ structTableOfReal#v1_info(49f6e7a06ebc5aa8). (); |
| 224 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Target:", numberOfRowscxx . . $ structTableOfReal#numberOfRows., U" symbols."); |
| 225 | MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Source:", numberOfColumnscxx . . $ structTableOfReal#numberOfColumns., U" symbols."); |
| 226 | } |
| 227 | |
| 228 | autoEditDistanceTable EditDistanceTable_createcxx . . $ EditDistanceTable_create(4d283d556de37bde). (Stringscxx . . $ Strings# target, Stringscxx . . $ Strings# source) { |
| 229 | try { |
| 230 | autoEditDistanceTable me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (EditDistanceTable); |
| 231 | const integercxx . . $ integer# numberOfSourceSymbols = source -> numberOfStringscxx . . $ structStrings#numberOfStrings., numberOfTargetSymbols = target -> numberOfStringscxx . . $ structStrings#numberOfStrings.; |
| 232 | TableOfReal_initcxx . . $ TableOfReal_init(cfadf70b559ed315). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), numberOfTargetSymbols + 1, numberOfSourceSymbols + 1); |
| 233 | TableOfReal_setColumnLabelcxx . . $ TableOfReal_setColumnLabel(7bba53c4f5b398fa). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, U""); |
| 234 | for (integercxx . . $ integer# j = 1; j <= numberOfSourceSymbols; j ++) |
| 235 | mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).j + 1] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (source -> stringscxx . . $ structStrings#strings. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).j].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 236 | TableOfReal_setRowLabelcxx . . $ TableOfReal_setRowLabel(7bba53c4f5b398fa). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 1, U""); |
| 237 | for (integercxx . . $ integer# i = 1; i <= numberOfTargetSymbols; i ++) |
| 238 | mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i + 1] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (target -> stringscxx . . $ structStrings#strings. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).i].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 239 | mycxx . . $ `melder/melder.h:44:9`! path =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <structPairOfInteger> (numberOfTargetSymbols + numberOfSourceSymbols + 1); |
| 240 | mycxx . . $ `melder/melder.h:44:9`! pathLength = mycxx . . $ `melder/melder.h:44:9`! path.sizecxx . . $ autovector#size.; // maintain invariant |
| 241 | mycxx . . $ `melder/melder.h:44:9`! editCostsTable =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). EditCostsTable_createDefaultcxx . . $ EditCostsTable_createDefault(50cffec8c84f3fb1). (); |
| 242 | EditDistanceTable_findPathcxx . . $ EditDistanceTable_findPath(131af2e6037a1b10). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr); |
| 243 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 244 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 245 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"EditDistanceTable not created."); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void EditDistanceTable_setEditCostscxx . . $ EditDistanceTable_setEditCosts(5b836fafd8690370). (EditDistanceTable me, EditCostsTable thee) { |
| 250 | try { |
| 251 | mycxx . . $ `melder/melder.h:44:9`! editCostsTable =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). Data_copycxx . . $ Data_copy(97a542a26794c80e). (thee); |
| 252 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 253 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": edit costs not set."); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | autoEditDistanceTable EditDistanceTable_createFromCharacterStringscxx . . $ EditDistanceTable_createFromCharacterStrings(9971b309185bfbf5). (const char32cxx . . $ char32# chars1 [], const char32cxx . . $ char32# chars2 []) { |
| 258 | try { |
| 259 | autoStringscxx . . $ autoStrings# s1 = Strings_createAsCharacterscxx . . $ Strings_createAsCharacters(9acdfa623bce7965). (chars1); |
| 260 | autoStringscxx . . $ autoStrings# s2 = Strings_createAsCharacterscxx . . $ Strings_createAsCharacters(9acdfa623bce7965). (chars2); |
| 261 | autoEditDistanceTable me = EditDistanceTable_createcxx . . $ EditDistanceTable_create(4d283d556de37bde). (s1.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), s2.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).()); |
| 262 | return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 263 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 264 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"EditDistanceTable not created from character strings."); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | static void NUMrationalizecxx . . $ NUMrationalize(b8a00e6d4f4793ca). (double x, integercxx . . $ integer# *numerator, integercxx . . $ integer# *denominator) { |
| 269 | constexpr double epsilon = 1e-6; |
| 270 | *numerator = 1; |
| 271 | for (*denominator = 1; *denominator <= 100000; (*denominator) ++) { |
| 272 | const double numerator_d = x * *denominator, rounded = roundcxx . . $ round(fee4f1d22bc8e617). (numerator_d); |
| 273 | if (fabscxx . . $ fabs(fee4f1d22bc8e617). (rounded - numerator_d) < epsilon) { |
| 274 | *numerator = (integercxx . . $ integer#) rounded; |
| 275 | return; |
| 276 | } |
| 277 | } |
| 278 | *denominator = 0; /* Failure. */ |
| 279 | } |
| 280 | |
| 281 | static void fixRowscxx . . $ fixRows(b4d9a139774118e8). (TableOfRealcxx . . $ TableOfReal# me, integercxx . . $ integer# *rowmin, integercxx . . $ integer# *rowmax) { |
| 282 | if (*rowmax < *rowmin) { |
| 283 | *rowmin = 1; |
| 284 | *rowmax = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 285 | } else if (*rowmin < 1) { |
| 286 | *rowmin = 1; |
| 287 | } else if (*rowmax > mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.) { |
| 288 | *rowmax = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | static void print4cxx . . $ print4(2747e37c1f5eb8ba). (char *buffer, double value, int iformat, int width, int precision) { |
| 293 | char formatString [40]; |
| 294 | if (iformat == 4) { |
| 295 | integercxx . . $ integer# numerator, denominator; |
| 296 | NUMrationalizecxx . . $ NUMrationalize(b8a00e6d4f4793ca). (value, & numerator, & denominator); |
| 297 | if (numerator == 0) |
| 298 | snprintf (buffer, 40, "0"); |
| 299 | else if (denominator > 1) |
| 300 | snprintf (buffer, 40, "%s/%s", Melder8_integercxx . . $ Melder8_integer(595caefabb192cea). (numerator), Melder8_integercxx . . $ Melder8_integer(595caefabb192cea). (denominator)); |
| 301 | else |
| 302 | snprintf (buffer, 40, "%.7g", value); |
| 303 | } else { |
| 304 | snprintf (formatString, 40, "%%%d.%d%c", width, precision, ( iformat == 1 ? 'f' : ( iformat == 2 ? 'e' : 'g' ) )); |
| 305 | snprintf (buffer, 40, formatString, value); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | static double getMaxRowLabelWidthcxx . . $ getMaxRowLabelWidth(1475cbb7aa26fabc). (TableOfRealcxx . . $ TableOfReal# me, Graphicscxx . . $ Graphics# graphics, integercxx . . $ integer# rowmin, integercxx . . $ integer# rowmax) { |
| 310 | double maxWidth = 0.0; |
| 311 | if (! mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels.) |
| 312 | return 0.0; |
| 313 | fixRowscxx . . $ fixRows(b4d9a139774118e8). (me, & rowmin, & rowmax); |
| 314 | for (integercxx . . $ integer# irow = rowmin; irow <= rowmax; irow ++) { |
| 315 | if (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow] && mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0]) { |
| 316 | const double textWidth = Graphics_textWidth_pscxx . . $ Graphics_textWidth_ps(e28a56f5afea616d). (graphics, mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), true); /* SILIPA is bigger than XIPA */ |
| 317 | if (textWidth > maxWidth) { |
| 318 | maxWidth = textWidth; |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | return maxWidth; |
| 323 | } |
| 324 | |
| 325 | static double getLeftMargincxx . . $ getLeftMargin(f906975acce41a59). (Graphicscxx . . $ Graphics# graphics) { |
| 326 | return Graphics_dxMMtoWCcxx . . $ Graphics_dxMMtoWC(f042c24bcd87f07e). (graphics, 1.0); |
| 327 | } |
| 328 | |
| 329 | static double getLineSpacingcxx . . $ getLineSpacing(f906975acce41a59). (Graphicscxx . . $ Graphics# graphics) { |
| 330 | return Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (graphics, 1.5 * Graphics_inqFontSizecxx . . $ Graphics_inqFontSize(f906975acce41a59). (graphics) * 25.4 / 72.0); |
| 331 | } |
| 332 | |
| 333 | void EditDistanceTable_drawcxx . . $ EditDistanceTable_draw(8a1d0b63098eba91). (EditDistanceTable me, Graphicscxx . . $ Graphics# graphics, int iformat, int precision, double angle) { |
| 334 | const integercxx . . $ integer# rowmin = 1, rowmax = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; |
| 335 | Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (graphics); |
| 336 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (graphics, 0.5, mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. + 0.5, 0.0, 1.0); |
| 337 | const double leftMargin = getLeftMargincxx . . $ getLeftMargin(f906975acce41a59). (graphics); // not earlier! |
| 338 | const double lineSpacing = getLineSpacingcxx . . $ getLineSpacing(f906975acce41a59). (graphics); // not earlier! |
| 339 | const double maxTextWidth = getMaxRowLabelWidthcxx . . $ getMaxRowLabelWidth(1475cbb7aa26fabc). (me, graphics, rowmin, rowmax); |
| 340 | double y = 1.0 + 0.1 * lineSpacing; |
| 341 | autoBOOLMATcxx . . $ autoBOOLMAT# onPath = zero_BOOLMATcxx . . $ zero_BOOLMAT(e9a8779cbc949ca0). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 342 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! pathLength; i ++) { |
| 343 | const structPairOfInteger poi = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 344 | onPath [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).poi.y] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).poi.x] = true; |
| 345 | } |
| 346 | for (integercxx . . $ integer# irow = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; irow > 0; irow --) { |
| 347 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 348 | if (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. && mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow] && mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0]) |
| 349 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, 0.5 - leftMargin, y, mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 350 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 351 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; icol ++) { |
| 352 | char text [40]; |
| 353 | print4cxx . . $ print4(2747e37c1f5eb8ba). (text, mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol], iformat, 0, precision); |
| 354 | Graphics_setBoldcxx . . $ Graphics_setBold(b5ae742079ad918c). (graphics, onPath [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]); |
| 355 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, icol, y, Melder_peek8to32_u (text)); |
| 356 | if (onPath [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]) { |
| 357 | Graphics_rectanglecxx . . $ Graphics_rectangle(72bdb7937dbb13da). (graphics, icol - 0.5, icol + 0.5, y - 0.5 * lineSpacing, y + 0.5 * lineSpacing); |
| 358 | } |
| 359 | } |
| 360 | y -= lineSpacing; |
| 361 | Graphics_setBoldcxx . . $ Graphics_setBold(b5ae742079ad918c). (graphics, false); |
| 362 | } |
| 363 | |
| 364 | double left = 0.5; |
| 365 | if (maxTextWidth > 0.0) left -= maxTextWidth + 2.0 * leftMargin; |
| 366 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (graphics, left, y, mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. + 0.5, y); |
| 367 | |
| 368 | Graphics_setTextRotationcxx . . $ Graphics_setTextRotation(2514a1c07b6be5e2). (graphics, angle); |
| 369 | if (angle < 0.0) { |
| 370 | y -= 0.3 * lineSpacing; |
| 371 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 372 | } else if (angle > 0.0) { |
| 373 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!, Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!); |
| 374 | y -= 0.3 * lineSpacing; |
| 375 | } else { |
| 376 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`!); |
| 377 | } |
| 378 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; icol ++) { |
| 379 | if (mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. && mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol] && mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0]) |
| 380 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, icol, y, mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 381 | } |
| 382 | Graphics_setTextRotationcxx . . $ Graphics_setTextRotation(2514a1c07b6be5e2). (graphics, 0.0); |
| 383 | y -= lineSpacing; |
| 384 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (graphics, 0.5, y, 0.5, 1 + 0.5 * lineSpacing); |
| 385 | Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (graphics); |
| 386 | } |
| 387 | |
| 388 | void EditDistanceTable_drawEditOperationscxx . . $ EditDistanceTable_drawEditOperations(f31b7533fcbdd08c). (EditDistanceTable me, Graphicscxx . . $ Graphics# graphics) { |
| 389 | const conststring32cxx . . $ conststring32# oinsertion = U"i", insertion = U"*", odeletion = U"d", deletion = U"*", osubstitution = U"s", oequal = U""; |
| 390 | Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (graphics, 0.5, mycxx . . $ `melder/melder.h:44:9`! pathLength - 0.5, 0.0, 1.0); // pathLength-1 symbols |
| 391 | const double lineSpacing = getLineSpacingcxx . . $ getLineSpacing(f906975acce41a59). (graphics); |
| 392 | const double ytarget = 1 - lineSpacing, ysource = ytarget - 2 * lineSpacing, yoper = ysource - lineSpacing; |
| 393 | Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (graphics, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment#::CENTREcxx . . $ kGraphics_horizontalAlignment#CENTRE., Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!); |
| 394 | for (integercxx . . $ integer# i = 2; i <= mycxx . . $ `melder/melder.h:44:9`! pathLength; i ++) { |
| 395 | const structPairOfInteger p = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], p1 = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i - 1]; |
| 396 | const double x = i - 1; |
| 397 | if (p.x == p1.x) { // insertion |
| 398 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, x, ytarget, mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.y].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 399 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, x, ysource, deletion); |
| 400 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, x, yoper, oinsertion); |
| 401 | } else if (p.y == p1.y) { // deletion |
| 402 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, x, ytarget, insertion); |
| 403 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, x, ysource, mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.x].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 404 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, x, yoper, odeletion); |
| 405 | } else { // substitution ? |
| 406 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, x, ytarget, mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.y].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 407 | Graphics_textcxx . . $ Graphics_text(bd267f534253e388). (graphics, x, ysource, mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.x].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 408 | Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (graphics, x, yoper, ( Melder_equcxx . . $ `melder/melder_str32.h:124:9`! (mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.y].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).p.x].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) ? oequal : osubstitution )); |
| 409 | } |
| 410 | Graphics_linecxx . . $ Graphics_line(72bdb7937dbb13da). (graphics, x, ysource + lineSpacing, x, ytarget - 0.1 * lineSpacing); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | void EditDistanceTable_setDefaultCostscxx . . $ EditDistanceTable_setDefaultCosts(3e96d30eecc5450e). (EditDistanceTable me, double insertionCosts, double deletionCosts, double substitutionCosts) { |
| 415 | EditCostsTable_setDefaultCostscxx . . $ EditCostsTable_setDefaultCosts(ee656dafc0cf1553). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), insertionCosts, deletionCosts, substitutionCosts); |
| 416 | EditDistanceTable_findPathcxx . . $ EditDistanceTable_findPath(131af2e6037a1b10). (me, nullptr); |
| 417 | } |
| 418 | |
| 419 | autoTableOfRealcxx . . $ autoTableOfReal# EditDistanceTable_to_TableOfReal_directionscxx . . $ EditDistanceTable_to_TableOfReal_directions(dbff689baef0b330). (EditDistanceTable me) { |
| 420 | autoTableOfRealcxx . . $ autoTableOfReal# torcxx . . $ autoSomeThing#autoSomeThing(49f6e7a06ebc5aa8).; |
| 421 | EditDistanceTable_findPathcxx . . $ EditDistanceTable_findPath(131af2e6037a1b10). (me, & tor); |
| 422 | return torcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 423 | } |
| 424 | |
| 425 | void EditDistanceTable_findPathcxx . . $ EditDistanceTable_findPath(131af2e6037a1b10). (EditDistanceTable me, autoTableOfRealcxx . . $ autoTableOfReal# *out_directions) { |
| 426 | try { |
| 427 | /* |
| 428 | What do we have to do to source to get target? |
| 429 | The origin [1] [1] is in the bottom-left corner. |
| 430 | Target vertical, source horizontal. |
| 431 | Going in the vertical direction is a deletion, horizontal is insertion, diagonal is substitution. |
| 432 | */ |
| 433 | const integercxx . . $ integer# numberOfSources = mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1, numberOfTargets = mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. - 1; |
| 434 | autoINTMATcxx . . $ autoINTMAT# psi = zero_INTMATcxx . . $ zero_INTMAT(4cdd710bd00a100c). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 435 | autoMATcxx . . $ autoMAT# delta = zero_MATcxx . . $ zero_MAT(3d09731056d2b97d). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 436 | |
| 437 | for (integercxx . . $ integer# icol = 2; icol <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; icol ++) { |
| 438 | delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol - 1] + EditCostsTable_getDeletionCostcxx . . $ EditCostsTable_getDeletionCost(fbdb87be0d9cf51f). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 439 | psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = WARPING_fromLeftcxx . . $ `dwtools/EditDistanceTable.h:24:9`!; |
| 440 | } |
| 441 | for (integercxx . . $ integer# irow = 2; irow <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; irow ++) { |
| 442 | delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] + EditCostsTable_getInsertionCostcxx . . $ EditCostsTable_getInsertionCost(fbdb87be0d9cf51f). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 443 | psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1] = WARPING_fromBelowcxx . . $ `dwtools/EditDistanceTable.h:25:9`!; |
| 444 | } |
| 445 | for (integercxx . . $ integer# icol = 2; icol <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; icol ++) { |
| 446 | for (integercxx . . $ integer# irow = 2; irow <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; irow ++) { |
| 447 | // the substitution, deletion and insertion costs. |
| 448 | const double left = delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol - 1] + |
| 449 | EditCostsTable_getInsertionCostcxx . . $ EditCostsTable_getInsertionCost(fbdb87be0d9cf51f). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 450 | const double bottom = delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] + |
| 451 | EditCostsTable_getDeletionCostcxx . . $ EditCostsTable_getDeletionCost(fbdb87be0d9cf51f). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); |
| 452 | double mindist = delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow - 1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol - 1] + |
| 453 | EditCostsTable_getSubstitutionCostcxx . . $ EditCostsTable_getSubstitutionCost(6f9442b9cfe3c120). (mycxx . . $ `melder/melder.h:44:9`! editCostsTable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).irow].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).icol].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); // diag |
| 454 | psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = WARPING_fromDiagcxx . . $ `dwtools/EditDistanceTable.h:26:9`!; |
| 455 | if (bottom < mindist) { |
| 456 | mindist = bottom; |
| 457 | psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = WARPING_fromBelowcxx . . $ `dwtools/EditDistanceTable.h:25:9`!; |
| 458 | } |
| 459 | if (left < mindist) { |
| 460 | mindist = left; |
| 461 | psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = WARPING_fromLeftcxx . . $ `dwtools/EditDistanceTable.h:24:9`!; |
| 462 | } |
| 463 | delta [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = mindist; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | /* |
| 468 | Reset the path to its maximum length, clearing it to zero. |
| 469 | */ |
| 470 | mycxx . . $ `melder/melder.h:44:9`! path. resizecxx . . $ autovector#resize(d91e89fbd57cd1). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows. + mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns. - 1); |
| 471 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! path.sizecxx . . $ autovector#size.; i ++) |
| 472 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. x = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. y = 0; |
| 473 | mycxx . . $ `melder/melder.h:44:9`! pathLength = mycxx . . $ `melder/melder.h:44:9`! path.sizecxx . . $ autovector#size.; // maintain invariant |
| 474 | |
| 475 | /* |
| 476 | Compute the shortest path. |
| 477 | */ |
| 478 | integercxx . . $ integer# iy = numberOfTargets, ix = numberOfSources; |
| 479 | integercxx . . $ integer# index = mycxx . . $ `melder/melder.h:44:9`! pathLength; |
| 480 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).index]. x = ix; |
| 481 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).index]. y = iy; |
| 482 | while (! (ix == 0 && iy == 0)) { |
| 483 | Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ix >= 0 && iy >= 0); |
| 484 | if (psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1 + iy] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1 + ix] == WARPING_fromLeftcxx . . $ `dwtools/EditDistanceTable.h:24:9`!) { |
| 485 | ix --; |
| 486 | } else if (psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1 + iy] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1 + ix] == WARPING_fromBelowcxx . . $ `dwtools/EditDistanceTable.h:25:9`!) { |
| 487 | iy --; |
| 488 | } else { // WARPING_fromDiag |
| 489 | ix --; |
| 490 | iy --; |
| 491 | } |
| 492 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).-- index]. x = ix; |
| 493 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).index]. y = iy; |
| 494 | } |
| 495 | if (index > 1) { |
| 496 | integercxx . . $ integer# k = 1; |
| 497 | for (integercxx . . $ integer# i = index; i <= mycxx . . $ `melder/melder.h:44:9`! pathLength; i ++) { |
| 498 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).k ++] = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]; |
| 499 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. x = mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. y = 0; |
| 500 | } |
| 501 | mycxx . . $ `melder/melder.h:44:9`! path. resizecxx . . $ autovector#resize(d91e89fbd57cd1). (k - 1); |
| 502 | mycxx . . $ `melder/melder.h:44:9`! pathLength = mycxx . . $ `melder/melder.h:44:9`! path.sizecxx . . $ autovector#size.; // maintain invariant |
| 503 | } |
| 504 | |
| 505 | /* |
| 506 | Shift by 1. |
| 507 | */ |
| 508 | for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! pathLength; i ++) { |
| 509 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. x ++; |
| 510 | mycxx . . $ `melder/melder.h:44:9`! path [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]. y ++; |
| 511 | } |
| 512 | |
| 513 | mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). deltacxx . . $ constmatrixview#constmatrixview(c98a2930b9469e58)..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 514 | |
| 515 | if (out_directions) { |
| 516 | autoTableOfRealcxx . . $ autoTableOfReal# him = EditDistanceTable_to_TableOfRealcxx . . $ EditDistanceTable_to_TableOfReal(dbff689baef0b330). (me); |
| 517 | for (integercxx . . $ integer# irow = 1; irow <= mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows.; irow ++) |
| 518 | for (integercxx . . $ integer# icol = 1; icol <= mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.; icol ++) |
| 519 | hiscxx . . $ `melder/melder.h:47:9`! datacxx . . $ structTableOfReal#data. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] = double (psi [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol]); |
| 520 | *out_directions =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). him.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); |
| 521 | } |
| 522 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 523 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": minimum path not found."); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | autoTableOfRealcxx . . $ autoTableOfReal# EditDistanceTable_to_TableOfRealcxx . . $ EditDistanceTable_to_TableOfReal(dbff689baef0b330). (EditDistanceTable me) { |
| 528 | try { |
| 529 | autoTableOfRealcxx . . $ autoTableOfReal# thee = TableOfReal_createcxx . . $ TableOfReal_create(e573ed3514e79d3). (mycxx . . $ `melder/melder.h:44:9`! numberOfRowscxx . . $ structTableOfReal#numberOfRows., mycxx . . $ `melder/melder.h:44:9`! numberOfColumnscxx . . $ structTableOfReal#numberOfColumns.); |
| 530 | thycxx . . $ `melder/melder.h:45:9`! columnLabelscxx . . $ structTableOfReal#columnLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).() <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! columnLabelscxx . . $ structTableOfReal#columnLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 531 | thycxx . . $ `melder/melder.h:45:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).() <<=cxx . . $ `operator<<=`(5bcbc9f49fd394e1). mycxx . . $ `melder/melder.h:44:9`! rowLabelscxx . . $ structTableOfReal#rowLabels..allcxx . . $ _autostringautovector#all(58997016dad794db).(); |
| 532 | thycxx . . $ `melder/melder.h:45:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). mycxx . . $ `melder/melder.h:44:9`! datacxx . . $ structTableOfReal#data..allcxx . . $ automatrix#all(2114117ba8ed4224).(); |
| 533 | return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).; |
| 534 | } catch (MelderErrorcxx . . $ MelderError#) { |
| 535 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no TableOfReal created."); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | /* End of file EditDistanceTable.cpp */ |