From cde0caaba7498980976ab9c257c5d6c5eef31701 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Wed, 9 Oct 2019 17:00:45 +0200
Subject: [PATCH] Fixed arc from one sentence to another

---
 transition_machine/src/ActionBank.cpp | 13 ++++++++++++-
 transition_machine/src/Config.cpp     | 13 +++++++++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/transition_machine/src/ActionBank.cpp b/transition_machine/src/ActionBank.cpp
index 51466c1..1cdfba7 100644
--- a/transition_machine/src/ActionBank.cpp
+++ b/transition_machine/src/ActionBank.cpp
@@ -596,7 +596,18 @@ std::vector<Action::BasicAction> ActionBank::str2sequence(const std::string & na
         simpleBufferWrite(c, "LABEL", "root", rootIndex-b0);
 
         // Delete the arcs from the previous sentence to the new sentence
-        // TODO
+        for (int i = b0; i > c.stackTop(); i--)
+        {
+          try
+          {
+            if (std::stoi(govs[i-b0])+i <= c.stackTop())
+            {
+              simpleBufferWrite(c, "GOV", "", i-b0);
+              simpleBufferWrite(c, "LABEL", "", i-b0);
+            }
+          }
+          catch (std::exception &) {continue;}
+        }
       };
     auto undo = [](Config & c, Action::BasicAction & ba)
       {
diff --git a/transition_machine/src/Config.cpp b/transition_machine/src/Config.cpp
index e38b6b2..fe307c1 100644
--- a/transition_machine/src/Config.cpp
+++ b/transition_machine/src/Config.cpp
@@ -869,16 +869,25 @@ void Config::updateIdsInSequence()
   }
 
   int curId = 1;
+  int digitIndex = 1;
   for (int i = sentenceStart; i <= sentenceEnd; i++)
   {
     auto splited = split(ids.getRef(i-getHead()), '-');
     if (splited.size() == 1)
     {
-      ids.setHyp(i-getHead(), std::to_string(curId++));
-      continue;
+      auto splited2 = split(ids.getRef(i-getHead()), '.');
+      if (splited2.size() == 1)
+      {
+        ids.setHyp(i-getHead(), std::to_string(curId++));
+        digitIndex = 1;
+        continue;
+      }
+      ids.setHyp(i-getHead(), std::to_string(curId)+"."+std::to_string(digitIndex));
+      digitIndex++;
     }
     int multiWordSize = splited.size();
     ids.setHyp(i-getHead(), std::to_string(curId)+"-"+std::to_string(curId+multiWordSize-1));
+    digitIndex = 1;
   }
 }
 
-- 
GitLab