diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp index 2b08088cceb1c1f082e316744230cc76598595ac..0e2d98a0bd0b4e9c44596e7fefe2cc93753044c3 100644 --- a/transition_machine/src/ActionBank.cpp +++ b/transition_machine/src/ActionBank.cpp @@ -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); diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp index d74dd343ee1e2e4cb0a46cfcbc56c9779ac30262..e1617c25d3a742929ce48a46ae9818368de2f2db 100644 --- a/transition_machine/src/Oracle.cpp +++ b/transition_machine/src/Oracle.cpp @@ -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");