From 7907d6ab8c5eb066f380f2bf3551d1d10b9a52fc Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@etu.univ-amu.fr> Date: Wed, 23 Jan 2019 16:14:18 +0100 Subject: [PATCH] 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 --- transition_machine/src/ActionBank.cpp | 13 +++++++++++++ transition_machine/src/Oracle.cpp | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp index 2b08088..0e2d98a 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 d74dd34..e1617c2 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"); -- GitLab