From c34cbafbefff5debafbe8ec6e81604120009593a Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Sat, 22 Feb 2020 23:07:55 +0100
Subject: [PATCH] EOS now delete arcs cross sentences

---
 reading_machine/src/Action.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/reading_machine/src/Action.cpp b/reading_machine/src/Action.cpp
index ecbcff7..6cf1678 100644
--- a/reading_machine/src/Action.cpp
+++ b/reading_machine/src/Action.cpp
@@ -205,6 +205,7 @@ Action Action::setRoot()
   auto apply = [](Config & config, Action & a)
   {
     int rootIndex = -1;
+    int firstSentenceIndex = -1;
 
     for (int i = config.getStack(0); true; --i)
     {
@@ -220,6 +221,8 @@ Action Action::setRoot()
       if (config.getLastNotEmptyHypConst(Config::EOSColName, i) == Config::EOSSymbol1)
         break;
 
+      firstSentenceIndex = i;
+
       if (util::isEmpty(config.getLastNotEmptyHypConst(Config::headColName, i)))
       {
         rootIndex = i;
@@ -253,6 +256,11 @@ Action Action::setRoot()
           config.getFirstEmpty(Config::headColName, i) = std::to_string(rootIndex);
         }
       }
+      else
+      {
+        if (std::stoi(config.getLastNotEmptyHypConst(Config::headColName, i)) < firstSentenceIndex)
+          config.getFirstEmpty(Config::headColName, i) = std::to_string(rootIndex);
+      }
     }
 
   };
-- 
GitLab