From 3bef5831fc4b703f95f7ee2d6993167b82390acd Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Fri, 13 Sep 2019 13:10:25 +0200
Subject: [PATCH] Removed movement from shift and right

---
 transition_machine/src/ActionBank.cpp | 9 +++++----
 transition_machine/src/Oracle.cpp     | 8 ++++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp
index 09384c1..8d886a8 100644
--- a/transition_machine/src/ActionBank.cpp
+++ b/transition_machine/src/ActionBank.cpp
@@ -186,6 +186,11 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
   }
   else if(std::string(b1) == "MOVE")
   {
+    int movement;
+    if (sscanf(name.c_str(), "MOVE %s %d", b2, &movement) != 2)
+      invalidNameAndAbort(ERRINFO);
+
+    sequence.emplace_back(moveHead(movement));
   }
   else if(std::string(b1) == "ERROR")
   {
@@ -216,8 +221,6 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
   else if(std::string(b1) == "SHIFT")
   {
     sequence.emplace_back(pushHead());
-
-    sequence.emplace_back(moveHead(+1));
   }
   else if(std::string(b1) == "REDUCE")
   {
@@ -322,8 +325,6 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
     }
 
     sequence.emplace_back(pushHead());
-
-    sequence.emplace_back(moveHead(+1));
   }
   else if(std::string(b1) == "EOS")
   {
diff --git a/transition_machine/src/Oracle.cpp b/transition_machine/src/Oracle.cpp
index e93e578..b28b022 100644
--- a/transition_machine/src/Oracle.cpp
+++ b/transition_machine/src/Oracle.cpp
@@ -253,11 +253,12 @@ void Oracle::createDatabase()
   [](Config & c, Oracle *)
   {
     if (c.pastActions.size() == 0)
-      return std::string("MOVE signature");
+      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";
@@ -277,14 +278,17 @@ void Oracle::createDatabase()
     else if (previousState == "parser")
     {
       if (split(previousAction, ' ')[0] == "shift" || split(previousAction, ' ')[0] == "right")
+      {
         newState = "signature";
+        movement = 1;
+      }
       else
         newState = "parser";
     }
     else
       newState = "unknown("+std::string(ERRINFO)+")("+previousState+")("+previousAction+")";
 
-    return "MOVE " + newState;
+    return "MOVE " + newState + " " + std::to_string(movement);
   },
   [](Config &, Oracle *, const std::string &)
   {
-- 
GitLab