From 2ebf30b6981b7b5d0a0880e1abb69898efa1bf07 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Tue, 16 Feb 2021 21:29:41 +0100
Subject: [PATCH] Corrected bug in readTSV

---
 reading_machine/src/BaseConfig.cpp | 7 +++++--
 reading_machine/src/Config.cpp     | 3 ---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/reading_machine/src/BaseConfig.cpp b/reading_machine/src/BaseConfig.cpp
index 3b511e6..69905a8 100644
--- a/reading_machine/src/BaseConfig.cpp
+++ b/reading_machine/src/BaseConfig.cpp
@@ -76,6 +76,9 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
     inputHasBeenRead = true;
   }
 
+  if (sentences.back().empty())
+    sentences.pop_back();
+
   std::fclose(file);
 
   for (unsigned int i = 0; i < (sentencesIndexes.size() ? sentencesIndexes.size() : sentences.size()); i++)
@@ -87,7 +90,7 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
     int usualNbCol = -1;
     int nbMultiwords = 0;
     std::vector<std::string> pendingComments;
-  
+
     for (std::string line : sentence)
     {
       if (line.size() < 3)
@@ -117,7 +120,7 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
       // Ignore empty nodes
       if (hasColIndex(idColName) && splited[getColIndex(idColName)].find('.') != std::string::npos)
         continue;
-  
+
       addLines(1);
       get(EOSColName, getNbLines()-1, 0) = EOSSymbol0;
       if (nbMultiwords > 0)
diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp
index 3268d77..8e08ddb 100644
--- a/reading_machine/src/Config.cpp
+++ b/reading_machine/src/Config.cpp
@@ -45,9 +45,6 @@ void Config::resizeLines(unsigned int nbLines)
 
 bool Config::has(int colIndex, int lineIndex, int hypothesisIndex) const
 {
-//  fmt::print(stderr, "line index = {}\n", lineIndex);
-//  fmt::print(stderr, "first line index = {}\n", getFirstLineIndex());
-//  fmt::print(stderr, "nbLines = {}\n", getNbLines());
   return colIndex >= 0 && colIndex < (int)getNbColumns() && lineIndex >= (int)getFirstLineIndex() && lineIndex < (int)getFirstLineIndex() + (int)getNbLines() && hypothesisIndex >= 0 && hypothesisIndex < nbHypothesesMax+1;
 }
 
-- 
GitLab