From 52fc33800141eace96f574f488e3697bbdeb5447 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 28 Oct 2015 10:43:22 +1100 Subject: [PATCH] * Set is_parsed and is_tagged attrs when loading annotations into Doc, re Issue #152 --- spacy/tokens/doc.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 93be3e363..1626ebfc6 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -388,9 +388,13 @@ cdef class Doc: tokens[i + values[i]].l_kids += 1 elif values[i] < 0: tokens[i + values[i]].r_kids += 1 + if not self.is_parsed and tokens[i].head != 0: + self.is_parsed = True elif attr_id == TAG: for i in range(length): tokens[i].tag = values[i] + if not self.is_tagged and tokens[i].tag != 0: + self.is_tagged = True elif attr_id == POS: for i in range(length): tokens[i].pos = values[i]