From fe396e89df93a0cf5c98a626fd3f91861a99cfe7 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Thu, 28 Feb 2019 14:17:42 +0100 Subject: [PATCH] Added backtrack Oracle for parser --- transition_machine/src/Oracle.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp index b27b2e2..b660cbc 100644 --- a/transition_machine/src/Oracle.cpp +++ b/transition_machine/src/Oracle.cpp @@ -191,6 +191,37 @@ void Oracle::createDatabase() return 0; }))); + str2oracle.emplace("error_parser", std::unique_ptr<Oracle>(new Oracle( + [](Oracle * oracle) + { + File file(oracle->filename, "r"); + FILE * fd = file.getDescriptor(); + char b1[1024]; + + while (fscanf(fd, "%[^\n]\n", b1) == 1) + oracle->data[b1] = b1; + }, + [](Config & c, Oracle * oracle) + { + if (c.getCurrentStateHistory().size() >= 2 && (c.getCurrentStateHistory().top() == "BACK" || c.getCurrentStateHistory().getElem(1) == "BACK")) + return std::string("EPSILON"); + + if (c.getCurrentStateHistory().size() < 2) + return std::string("EPSILON"); + + if (c.hashHistory.contains(c.computeHash())) + return std::string("EPSILON"); + + if (oracle->data.count("systematic")) + 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( [](Oracle *) { -- GitLab