From 2d1ca2ab3198968f4d10cae6d8841fa54ab35752 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Wed, 7 Jul 2021 13:42:31 +0200
Subject: [PATCH] Corrected bug when using transitions=tagger

---
 Config.py     | 6 +++++-
 Transition.py | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Config.py b/Config.py
index 92599b6..52c8d23 100644
--- a/Config.py
+++ b/Config.py
@@ -19,6 +19,9 @@ class Config :
     self.historyHistory = set()
     self.historyPop = []
 
+  def isPredicted(self, colname) :
+    return colname in self.predicted
+
   def hasCol(self, colname) :
     return colname in self.col2index
   
@@ -121,7 +124,7 @@ class Config :
       toPrint = []
       for colIndex in range(len(self.lines[index])) :
         value = str(self.getAsFeature(index, self.index2col[colIndex]))
-        if value == "" :
+        if value == "" or value == "_" :
           value = "_"
         elif self.index2col[colIndex] == "HEAD" and value != "-1":
           value = self.getAsFeature(int(value), "ID")
@@ -153,6 +156,7 @@ def readConllu(filename, predicted) :
         if head == "_" :
           continue
         if head == "0" :
+          configs[-1].set(index, "HEAD", -1, False)
           continue
         configs[-1].set(index, "HEAD", id2index[head], False)
         configs[-1].goldChilds[int(id2index[head])].append(index)
diff --git a/Transition.py b/Transition.py
index 7ad6dfb..ca41bcf 100644
--- a/Transition.py
+++ b/Transition.py
@@ -266,7 +266,7 @@ def applyReduce(config) :
 
 ################################################################################
 def applyEOS(config) :
-  if not config.hasCol("HEAD") :
+  if not config.hasCol("HEAD") or not config.isPredicted("HEAD") :
     return
 
   rootCandidates = [index for index in config.stack if not config.isMultiword(index) and isEmpty(config.getAsFeature(index, "HEAD"))]
-- 
GitLab