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

Changed the way BACK works : to avoid loops. Changed the way EOS works : if...

Changed the way BACK works : to avoid loops. Changed the way EOS works : if the dependency graph is cyclic, chose arbitrarily a root in the stack
parent 65d61656
No related branches found
No related tags found
No related merge requests found
......@@ -370,6 +370,19 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
ba.data += "+"+s-b0;
}
}
}
if (rootIndex == -1)
{
if (c.stackEmpty())
{
c.printForDebug(stderr);
fprintf(stderr, "ERROR (%s) : no suitable candidate for root. Aborting.\n", ERRINFO);
exit(1);
}
rootIndex = c.stackGetElem(c.stackSize()-1);
}
simpleBufferWrite(c, "GOV", "0", rootIndex-b0);
......
......@@ -98,9 +98,23 @@ void Oracle::createDatabase()
[](Oracle *)
{
},
[](Config &, Oracle *)
[](Config & c, Oracle *)
{
if (choiceWithProbability(0.05))
if (c.getCurrentStateHistory().size() >= 2 && (c.getCurrentStateHistory().back() == "BACK" || c.getCurrentStateHistory()[c.getCurrentStateHistory().size()-2] == "BACK"))
return std::string("EPSILON");
auto & pos = c.getTape("POS");
if (c.head > 0 && pos[c.head-1] != pos.ref[c.head-1] && pos[c.head-1] == "det" && pos[c.head] == "prorel")
return std::string("BACK 1");
if (c.head > 0 && pos[c.head-1] != pos.ref[c.head-1] && pos[c.head-1] == "det" && pos[c.head] == "prep")
return std::string("BACK 1");
if (c.head > 0 && pos[c.head-1] != pos.ref[c.head-1] && pos[c.head-1] == "nc" && pos[c.head] == "nc")
return std::string("BACK 1");
if (c.head > 0 && pos[c.head-1] != pos.ref[c.head-1] && pos[c.head-1] == "nc" && pos[c.head] == "prep")
return std::string("BACK 1");
return std::string("EPSILON");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment