From b43d29d927bab70fdf54483c8c29078153048fe2 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Thu, 23 Apr 2020 16:14:09 +0200 Subject: [PATCH] Fixed bugs when there was no HEAD col in mcd --- reading_machine/src/BaseConfig.cpp | 19 ++++++++++--------- reading_machine/src/Config.cpp | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/reading_machine/src/BaseConfig.cpp b/reading_machine/src/BaseConfig.cpp index 4997f6e..8ca5ab3 100644 --- a/reading_machine/src/BaseConfig.cpp +++ b/reading_machine/src/BaseConfig.cpp @@ -106,15 +106,16 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename) firstIndexOfSequence = i; id2index[getConst(idColName, i, 0)] = i; } - for (int i = firstIndexOfSequence; i < (int)getNbLines(); ++i) - { - if (!isToken(i)) - continue; - auto & head = get(headColName, i, 0); - if (head == "0") - continue; - head = std::to_string(id2index[head]); - } + if (hasColIndex(headColName)) + for (int i = firstIndexOfSequence; i < (int)getNbLines(); ++i) + { + if (!isToken(i)) + continue; + auto & head = get(headColName, i, 0); + if (head == "0") + continue; + head = std::to_string(id2index[head]); + } } catch(std::exception & e) {util::myThrow(e.what());} continue; diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp index 50e7f61..1ecf072 100644 --- a/reading_machine/src/Config.cpp +++ b/reading_machine/src/Config.cpp @@ -605,8 +605,9 @@ void Config::addMissingColumns() if (curId == 1) firstIndex = index; - if (util::isEmpty(getAsFeature(headColName, index))) - getLastNotEmptyHyp(headColName, index) = (curId == 1) ? "0" : std::to_string(firstIndex); + if (hasColIndex(headColName)) + if (util::isEmpty(getAsFeature(headColName, index))) + getLastNotEmptyHyp(headColName, index) = (curId == 1) ? "0" : std::to_string(firstIndex); } } -- GitLab