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

Added an error correction oracle for morpho

parent 3905067c
Branches
No related tags found
No related merge requests found
...@@ -129,6 +129,48 @@ void Oracle::createDatabase() ...@@ -129,6 +129,48 @@ void Oracle::createDatabase()
return 0; return 0;
}))); })));
str2oracle.emplace("error_morpho", std::unique_ptr<Oracle>(new Oracle(
[](Oracle *)
{
},
[](Config & c, Oracle *)
{
if (c.getCurrentStateHistory().size() >= 2 && (c.getCurrentStateHistory().back() == "BACK" || c.getCurrentStateHistory()[c.getCurrentStateHistory().size()-2] == "BACK"))
return std::string("EPSILON");
if (c.getCurrentStateHistory().size() < 2)
return std::string("EPSILON");
//return std::string("BACK 1");
auto & morpho = c.getTape("MORPHO");
if (c.head <= 0)
return std::string("EPSILON");
auto & morphoRef = morpho.ref[c.head-1];
auto & morpho0 = morpho[c.head-1];
auto & morpho1 = morpho[c.head];
if (morpho0 == morphoRef)
return std::string("EPSILON");
auto & genre0 = split(morpho0, '|')[0];
auto & genre1 = split(morpho1, '|')[0];
if (genre0 == "g=f" && genre1 == "g=m")
return std::string("BACK 1");
if (genre0 == "g=m" && genre1 == "g=f")
return std::string("BACK 1");
return std::string("EPSILON");
},
[](Config &, Oracle *, const std::string &)
{
return 0;
})));
str2oracle.emplace("tagger", std::unique_ptr<Oracle>(new Oracle( str2oracle.emplace("tagger", 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