From d123e1ec8fc89d9d4934ec5e535b7ffc37646de9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 11 Oct 2020 17:46:34 +0200 Subject: [PATCH] Add debug to nonproj --- spacy/pipeline/_parser_internals/nonproj.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spacy/pipeline/_parser_internals/nonproj.pyx b/spacy/pipeline/_parser_internals/nonproj.pyx index 82070cd27..a5266fd2a 100644 --- a/spacy/pipeline/_parser_internals/nonproj.pyx +++ b/spacy/pipeline/_parser_internals/nonproj.pyx @@ -165,7 +165,14 @@ def _find_new_head(token, headlabel): # returns the id of the first descendant with the given label # if there is none, return the current head (no change) queue = [token.head] + n_iter = 0 while queue: + n_iter += 1 + if n_iter >= len(token.doc): + print("Infinite loop") + print([(w.i, w.text, w.head.i, w.dep_) for w in token.doc]) + with open("/tmp/doc.bytes", "wb") as file_: + file_.write(token.doc.to_bytes()) next_queue = [] for qtoken in queue: for child in qtoken.children: