Skip to content
Snippets Groups Projects
Commit 2ebf30b6 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected bug in readTSV

parent c10d0cbf
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,9 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in ...@@ -76,6 +76,9 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
inputHasBeenRead = true; inputHasBeenRead = true;
} }
if (sentences.back().empty())
sentences.pop_back();
std::fclose(file); std::fclose(file);
for (unsigned int i = 0; i < (sentencesIndexes.size() ? sentencesIndexes.size() : sentences.size()); i++) 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 ...@@ -87,7 +90,7 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
int usualNbCol = -1; int usualNbCol = -1;
int nbMultiwords = 0; int nbMultiwords = 0;
std::vector<std::string> pendingComments; std::vector<std::string> pendingComments;
for (std::string line : sentence) for (std::string line : sentence)
{ {
if (line.size() < 3) if (line.size() < 3)
...@@ -117,7 +120,7 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in ...@@ -117,7 +120,7 @@ void BaseConfig::readTSVInput(std::string_view tsvFilename, const std::vector<in
// Ignore empty nodes // Ignore empty nodes
if (hasColIndex(idColName) && splited[getColIndex(idColName)].find('.') != std::string::npos) if (hasColIndex(idColName) && splited[getColIndex(idColName)].find('.') != std::string::npos)
continue; continue;
addLines(1); addLines(1);
get(EOSColName, getNbLines()-1, 0) = EOSSymbol0; get(EOSColName, getNbLines()-1, 0) = EOSSymbol0;
if (nbMultiwords > 0) if (nbMultiwords > 0)
......
...@@ -45,9 +45,6 @@ void Config::resizeLines(unsigned int nbLines) ...@@ -45,9 +45,6 @@ void Config::resizeLines(unsigned int nbLines)
bool Config::has(int colIndex, int lineIndex, int hypothesisIndex) const 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; return colIndex >= 0 && colIndex < (int)getNbColumns() && lineIndex >= (int)getFirstLineIndex() && lineIndex < (int)getFirstLineIndex() + (int)getNbLines() && hypothesisIndex >= 0 && hypothesisIndex < nbHypothesesMax+1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment