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

Fixed floating word attachement in EOS

parent 0f54d3dd
No related branches found
No related tags found
No related merge requests found
......@@ -595,6 +595,36 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
simpleBufferWrite(c, "GOV", "0", rootIndex-b0);
simpleBufferWrite(c, "LABEL", "root", rootIndex-b0);
// Attaching floating words to new root
int sentenceEnd = b0;
auto & eos = c.getTape(ProgramParameters::sequenceDelimiterTape);
while (sentenceEnd >= 0 && eos[sentenceEnd-b0] != ProgramParameters::sequenceDelimiter)
sentenceEnd--;
int sentenceStart = std::max(0,sentenceEnd-1);
while (sentenceStart >= 0 && eos[sentenceStart-b0] != ProgramParameters::sequenceDelimiter)
sentenceStart--;
sentenceStart++;
if (sentenceEnd < 0)
{
sentenceStart = 0;
sentenceEnd = eos.hypSize()-1;
}
for (int i = sentenceStart; i <= sentenceEnd; i++)
{
if (split(ids.getRef(i-b0), '-').size() > 1)
continue;
if (split(ids.getRef(i-b0), '.').size() > 1)
continue;
if (govs.getHyp(i-b0).empty())
{
simpleBufferWrite(c, "GOV", std::to_string(rootIndex-i), i-b0);
simpleBufferWrite(c, "LABEL", "_", i-b0);
ba.data += "+"+std::to_string(i-b0);
}
}
// Delete the arcs from the previous sentence to the new sentence
for (int i = b0; i > c.stackTop(); i--)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment