diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp index b28b0228a08a7129acd504c13cb9bcc71e10b143..7dc8bfbcdd41b84ed6bf59945ca9a3092cc15210 100644 --- a/transition_machine/src/Oracle.cpp +++ b/transition_machine/src/Oracle.cpp @@ -246,6 +246,91 @@ void Oracle::createDatabase() return (action == "WRITE b.0 MORPHO " + c.getTape("MORPHO").getRef(0) || c.endOfTapes()) ? 0 : 1; }))); + str2oracle.emplace("strategy_morpho", std::unique_ptr<Oracle>(new Oracle( + [](Oracle *) + { + }, + [](Config &, Oracle *) + { + return std::string("MOVE morpho 1"); + }, + [](Config &, Oracle *, const std::string &) + { + return 0; + }))); + + str2oracle.emplace("strategy_tagger", std::unique_ptr<Oracle>(new Oracle( + [](Oracle *) + { + }, + [](Config & c, Oracle *) + { + if (c.pastActions.size() == 0) + 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"; + else if (previousState == "tagger") + { + newState = "signature"; + movement = 1; + } + + return "MOVE " + newState + " " + std::to_string(movement); + }, + [](Config &, Oracle *, const std::string &) + { + return 0; + }))); + + str2oracle.emplace("strategy_parser", std::unique_ptr<Oracle>(new Oracle( + [](Oracle *) + { + }, + [](Config & c, Oracle *) + { + if (c.pastActions.size() == 0) + 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 = "parser"; + else if (previousState == "parser") + { + newState = "parser"; + if (split(previousAction, ' ')[0] == "shift" || split(previousAction, ' ')[0] == "right") + { + movement = 1; + newState = "signature"; + } + } + else if (previousState == "error_parser") + { + newState = "parser"; + std::string previousParserAction = noAccentLower(c.pastActions.getElem(1).second.name); + if (split(previousParserAction, ' ')[0] == "shift" || split(previousParserAction, ' ')[0] == "right") + { + newState = "signature"; + movement = 1; + } + } + + return "MOVE " + newState + " " + std::to_string(movement); + }, + [](Config &, Oracle *, const std::string &) + { + return 0; + }))); + str2oracle.emplace("strategy_tagger,morpho,lemmatizer,parser", std::unique_ptr<Oracle>(new Oracle( [](Oracle *) {