From a43b999339a7fa4ad75d8e2f6ab819fda1387960 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Sun, 29 Mar 2020 18:49:08 +0200 Subject: [PATCH] Improved printForDebug --- reading_machine/src/Config.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp index 0429372..6aec0fb 100644 --- a/reading_machine/src/Config.cpp +++ b/reading_machine/src/Config.cpp @@ -149,13 +149,13 @@ void Config::printForDebug(FILE * dest) const toPrint.back().emplace_back(line == (int)wordIndex ? "=>" : ""); for (unsigned int i = 0; i < getNbColumns(); i++) { - auto & colContent = getAsFeature(i, line); + std::string colContent = has(i,line,0) ? getAsFeature(i, line).get() : "?"; std::string toPrintCol = colContent; try { if (getColName(i) == headColName && toPrintCol != "_" && !toPrintCol.empty()) - if (toPrintCol != "0") - toPrintCol = getAsFeature(idColName, std::stoi(toPrintCol)); + if (toPrintCol != "0" && toPrintCol != "?") + toPrintCol = has(0,std::stoi(toPrintCol),0) ? getAsFeature(idColName, std::stoi(toPrintCol)).get() : "?"; } catch(std::exception & e) {util::myThrow(fmt::format("toPrintCol='{}' {}", toPrintCol, e.what()));} toPrint.back().emplace_back(util::shrink(toPrintCol, maxWordLength)); } @@ -219,7 +219,7 @@ void Config::printForDebug(FILE * dest) const Config::String & Config::getLastNotEmpty(int colIndex, int lineIndex) { if (!has(colIndex, lineIndex, 0)) - util::myThrow(fmt::format("asked for line {} but nbLines = {}", lineIndex, getNbLines())); + util::myThrow(fmt::format("asked for line {} but last line = {}", lineIndex, getNbLines()+getFirstLineIndex()-1)); int baseIndex = getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex); for (int i = nbHypothesesMax; i > 0; --i) -- GitLab