diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp index 09384c10eb4f3bbf66c6f2563a01401805944201..8d886a893fbc1052a767ae90edbd92538199659c 100644 --- a/transition_machine/src/ActionBank.cpp +++ b/transition_machine/src/ActionBank.cpp @@ -186,6 +186,11 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na } else if(std::string(b1) == "MOVE") { + int movement; + if (sscanf(name.c_str(), "MOVE %s %d", b2, &movement) != 2) + invalidNameAndAbort(ERRINFO); + + sequence.emplace_back(moveHead(movement)); } else if(std::string(b1) == "ERROR") { @@ -216,8 +221,6 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na else if(std::string(b1) == "SHIFT") { sequence.emplace_back(pushHead()); - - sequence.emplace_back(moveHead(+1)); } else if(std::string(b1) == "REDUCE") { @@ -322,8 +325,6 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na } sequence.emplace_back(pushHead()); - - sequence.emplace_back(moveHead(+1)); } else if(std::string(b1) == "EOS") { diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp index e93e578243d9bd0d210398895385d1cfad12fa64..b28b0228a08a7129acd504c13cb9bcc71e10b143 100644 --- a/transition_machine/src/Oracle.cpp +++ b/transition_machine/src/Oracle.cpp @@ -253,11 +253,12 @@ void Oracle::createDatabase() [](Config & c, Oracle *) { if (c.pastActions.size() == 0) - return std::string("MOVE signature"); + return std::string("MOVE signature 0"); std::string previousState = noAccentLower(c.pastActions.getElem(0).first); std::string previousAction = noAccentLower(c.pastActions.getElem(0).second.name); std::string newState; + int movement = 0; if (previousState == "signature") newState = "tagger"; @@ -277,14 +278,17 @@ void Oracle::createDatabase() else if (previousState == "parser") { if (split(previousAction, ' ')[0] == "shift" || split(previousAction, ' ')[0] == "right") + { newState = "signature"; + movement = 1; + } else newState = "parser"; } else newState = "unknown("+std::string(ERRINFO)+")("+previousState+")("+previousAction+")"; - return "MOVE " + newState; + return "MOVE " + newState + " " + std::to_string(movement); }, [](Config &, Oracle *, const std::string &) {