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

Corrected problem where mcd was not propagated in lineByLine mode

parent ab0bfc27
No related branches found
No related tags found
No related merge requests found
...@@ -376,6 +376,7 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename ...@@ -376,6 +376,7 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
char lineBuffer[100000]; char lineBuffer[100000];
bool inputHasBeenRead = false; bool inputHasBeenRead = false;
std::string mcdLine;
sentences.emplace_back(); sentences.emplace_back();
while (!std::feof(file)) while (!std::feof(file))
...@@ -383,9 +384,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename ...@@ -383,9 +384,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
if (lineBuffer != std::fgets(lineBuffer, 100000, file)) if (lineBuffer != std::fgets(lineBuffer, 100000, file))
break; break;
std::string_view line(lineBuffer); std::string line(lineBuffer);
sentences.back().emplace_back(line); sentences.back().emplace_back(line);
if (line.back() == '\n')
line.pop_back();
if (line.size() < 3) if (line.size() < 3)
{ {
if (!inputHasBeenRead) if (!inputHasBeenRead)
...@@ -395,6 +399,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename ...@@ -395,6 +399,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
continue; continue;
} }
if (util::doIfNameMatch(std::regex("(?:(?:\\s|\\t)*)#(?:(?:\\s|\\t)*)global.columns(?:(?:\\s|\\t)*)=(?:(?:\\s|\\t)*)(.+)"), line, [&mcdLine, &line](const auto &)
{
mcdLine = line;
}))
continue;
inputHasBeenRead = true; inputHasBeenRead = true;
} }
...@@ -402,6 +412,10 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename ...@@ -402,6 +412,10 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
sentences.pop_back(); sentences.pop_back();
std::fclose(file); std::fclose(file);
if (not mcdLine.empty())
for (auto & sentence : sentences)
sentence.insert(sentence.begin(), mcdLine);
return sentences; return sentences;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment