Commit a45d405b authored by Franck Dary's avatar Franck Dary
Browse files

Corrected problem where mcd was not propagated in lineByLine mode

parent ab0bfc27
......@@ -376,6 +376,7 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
char lineBuffer[100000];
bool inputHasBeenRead = false;
std::string mcdLine;
sentences.emplace_back();
while (!std::feof(file))
......@@ -383,9 +384,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
if (lineBuffer != std::fgets(lineBuffer, 100000, file))
break;
std::string_view line(lineBuffer);
std::string line(lineBuffer);
sentences.back().emplace_back(line);
if (line.back() == '\n')
line.pop_back();
if (line.size() < 3)
{
if (!inputHasBeenRead)
......@@ -395,6 +399,12 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
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;
}
......@@ -402,6 +412,10 @@ std::vector<std::vector<std::string>> util::readTSV(std::string_view tsvFilename
sentences.pop_back();
std::fclose(file);
if (not mcdLine.empty())
for (auto & sentence : sentences)
sentence.insert(sentence.begin(), mcdLine);
return sentences;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment