mirror of https://github.com/explosion/spaCy.git
* Add cycle-checking code in gold.pyx
This commit is contained in:
parent
839e5038b7
commit
46fb24e9fd
|
@ -242,6 +242,16 @@ cdef class GoldParse:
|
|||
self.heads[w2] = None
|
||||
self.labels[w2] = ''
|
||||
|
||||
# Check there are no cycles in the dependencies, i.e. we are a tree
|
||||
for w in range(self.length):
|
||||
seen = set([w])
|
||||
head = w
|
||||
while self.heads[head] != head and self.heads[head] != None:
|
||||
head = self.heads[head]
|
||||
if head in seen:
|
||||
raise Exception("Cycle found: %s" % seen)
|
||||
seen.add(head)
|
||||
|
||||
self.brackets = {}
|
||||
for (gold_start, gold_end, label_str) in brackets:
|
||||
start = self.gold_to_cand[gold_start]
|
||||
|
|
Loading…
Reference in New Issue