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

added parser strategy

parent 3bef5831
No related branches found
No related tags found
No related merge requests found
...@@ -246,6 +246,91 @@ void Oracle::createDatabase() ...@@ -246,6 +246,91 @@ void Oracle::createDatabase()
return (action == "WRITE b.0 MORPHO " + c.getTape("MORPHO").getRef(0) || c.endOfTapes()) ? 0 : 1; 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( str2oracle.emplace("strategy_tagger,morpho,lemmatizer,parser", std::unique_ptr<Oracle>(new Oracle(
[](Oracle *) [](Oracle *)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment