Skip to content
Snippets Groups Projects
Commit 2d1ca2ab authored by Franck Dary's avatar Franck Dary
Browse files

Corrected bug when using transitions=tagger

parent b2cfa23e
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,9 @@ class Config : ...@@ -19,6 +19,9 @@ class Config :
self.historyHistory = set() self.historyHistory = set()
self.historyPop = [] self.historyPop = []
def isPredicted(self, colname) :
return colname in self.predicted
def hasCol(self, colname) : def hasCol(self, colname) :
return colname in self.col2index return colname in self.col2index
...@@ -121,7 +124,7 @@ class Config : ...@@ -121,7 +124,7 @@ class Config :
toPrint = [] toPrint = []
for colIndex in range(len(self.lines[index])) : for colIndex in range(len(self.lines[index])) :
value = str(self.getAsFeature(index, self.index2col[colIndex])) value = str(self.getAsFeature(index, self.index2col[colIndex]))
if value == "" : if value == "" or value == "_" :
value = "_" value = "_"
elif self.index2col[colIndex] == "HEAD" and value != "-1": elif self.index2col[colIndex] == "HEAD" and value != "-1":
value = self.getAsFeature(int(value), "ID") value = self.getAsFeature(int(value), "ID")
...@@ -153,6 +156,7 @@ def readConllu(filename, predicted) : ...@@ -153,6 +156,7 @@ def readConllu(filename, predicted) :
if head == "_" : if head == "_" :
continue continue
if head == "0" : if head == "0" :
configs[-1].set(index, "HEAD", -1, False)
continue continue
configs[-1].set(index, "HEAD", id2index[head], False) configs[-1].set(index, "HEAD", id2index[head], False)
configs[-1].goldChilds[int(id2index[head])].append(index) configs[-1].goldChilds[int(id2index[head])].append(index)
......
...@@ -266,7 +266,7 @@ def applyReduce(config) : ...@@ -266,7 +266,7 @@ def applyReduce(config) :
################################################################################ ################################################################################
def applyEOS(config) : def applyEOS(config) :
if not config.hasCol("HEAD") : if not config.hasCol("HEAD") or not config.isPredicted("HEAD") :
return return
rootCandidates = [index for index in config.stack if not config.isMultiword(index) and isEmpty(config.getAsFeature(index, "HEAD"))] rootCandidates = [index for index in config.stack if not config.isMultiword(index) and isEmpty(config.getAsFeature(index, "HEAD"))]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment