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

Now correctly updating ids of multiwords token

parent a4844d76
No related branches found
No related tags found
No related merge requests found
......@@ -91,6 +91,7 @@ class Config
void popStack();
bool isComment(std::size_t lineIndex) const;
bool isMultiword(std::size_t lineIndex) const;
int getMultiwordSize(std::size_t lineIndex) const;
bool isEmptyNode(std::size_t lineIndex) const;
bool isToken(std::size_t lineIndex) const;
bool moveWordIndex(int relativeMovement);
......
......@@ -287,7 +287,7 @@ Action Action::updateIds()
break;
util::myThrow("The current sentence is too long to be completly held by the data strucure. Consider increasing SubConfig::SpanSize");
}
if (!config.isToken(i))
if (config.isComment(i) || config.isEmptyNode(i))
continue;
if (config.getLastNotEmptyHypConst(Config::EOSColName, i) == Config::EOSSymbol1)
......@@ -301,14 +301,16 @@ Action Action::updateIds()
for (unsigned int i = firstIndexOfSentence, currentId = 1; i <= config.getStack(0); ++i)
{
if (!config.isToken(i))
if (config.isComment(i) || config.isEmptyNode(i))
continue;
if (config.getLastNotEmptyHypConst(Config::EOSColName, i) == Config::EOSSymbol1)
break;
config.getFirstEmpty(Config::idColName, i) = fmt::format("{}", currentId);
++currentId;
if (config.isMultiword(i))
config.getFirstEmpty(Config::idColName, i) = fmt::format("{}-{}", currentId, currentId+config.getMultiwordSize(i));
else
config.getFirstEmpty(Config::idColName, i) = fmt::format("{}", currentId++);
}
};
......
......@@ -334,6 +334,12 @@ bool Config::isMultiword(std::size_t lineIndex) const
return hasColIndex(idColName) && getConst(idColName, lineIndex, 0).get().find('-') != std::string::npos;
}
int Config::getMultiwordSize(std::size_t lineIndex) const
{
auto splited = util::split(getConst(idColName, lineIndex, 0).get(), '-');
return std::stoi(std::string(splited[1])) - std::stoi(std::string(splited[0]));
}
bool Config::isEmptyNode(std::size_t lineIndex) const
{
return hasColIndex(idColName) && getConst(idColName, lineIndex, 0).get().find('.') != std::string::npos;
......
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