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

Added strategy

parent ebaa33ab
No related branches found
No related tags found
No related merge requests found
...@@ -144,6 +144,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na ...@@ -144,6 +144,9 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
else if(std::string(b1) == "EPSILON") else if(std::string(b1) == "EPSILON")
{ {
} }
else if(std::string(b1) == "MOVE")
{
}
else if(std::string(b1) == "ERROR") else if(std::string(b1) == "ERROR")
{ {
auto apply = [](Config &, Action::BasicAction &) auto apply = [](Config &, Action::BasicAction &)
......
...@@ -246,6 +246,51 @@ void Oracle::createDatabase() ...@@ -246,6 +246,51 @@ 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_tagger,morpho,lemmatizer,parser", std::unique_ptr<Oracle>(new Oracle(
[](Oracle *)
{
},
[](Config & c, Oracle *)
{
if (c.pastActions.size() == 0)
return std::string("MOVE signature");
std::string previousState = noAccentLower(c.pastActions.getElem(0).first);
std::string previousAction = noAccentLower(c.pastActions.getElem(0).second.name);
std::string newState;
if (previousState == "signature")
newState = "tagger";
else if (previousState == "tagger")
newState = "morpho";
else if (previousState == "morpho")
newState = "lemmatizer_lookup";
else if (previousState == "lemmatizer_lookup")
{
if (previousAction == "notfound")
newState = "lemmatizer_rules";
else
newState = "parser";
}
else if (previousState == "lemmatizer_rules")
newState = "parser";
else if (previousState == "parser")
{
if (split(previousAction, ' ')[0] == "shift" || split(previousAction, ' ')[0] == "right")
newState = "signature";
else
newState = "parser";
}
else
newState = "unknown("+std::string(ERRINFO)+")("+previousState+")("+previousAction+")";
return "MOVE " + newState;
},
[](Config &, Oracle *, const std::string &)
{
return 0;
})));
str2oracle.emplace("signature", std::unique_ptr<Oracle>(new Oracle( str2oracle.emplace("signature", std::unique_ptr<Oracle>(new Oracle(
[](Oracle * oracle) [](Oracle * oracle)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment