diff --git a/spacy/morphology.pyx b/spacy/morphology.pyx index e8b1f3520..442aebd68 100644 --- a/spacy/morphology.pyx +++ b/spacy/morphology.pyx @@ -38,6 +38,8 @@ cdef class Morphology: tag_id = self.reverse_index[self.strings[tag]] else: tag_id = tag + if tag_id >= self.n_tags: + raise ValueError("Unknown tag: %s" % tag) analysis = self._cache.get(tag_id, token.lex.orth) if analysis is NULL: analysis = self.mem.alloc(1, sizeof(MorphAnalysisC)) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 9c3387059..6b14d761c 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -398,7 +398,8 @@ cdef class Doc: self.is_parsed = True elif attr_id == TAG: for i in range(length): - self.vocab.morphology.assign_tag(&tokens[i], values[i]) + self.vocab.morphology.assign_tag(&tokens[i], + self.vocab.strings[values[i]]) if not self.is_tagged and tokens[i].tag != 0: self.is_tagged = True elif attr_id == POS: