From 517f090cbfc5b1c6447ff277bd30e35b5a6785ff Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 17 Oct 2016 00:55:15 +0200 Subject: [PATCH] Use GoldParse in tagger.update --- spacy/tagger.pyx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spacy/tagger.pyx b/spacy/tagger.pyx index 6b895a2ce..b2bc344bb 100644 --- a/spacy/tagger.pyx +++ b/spacy/tagger.pyx @@ -15,6 +15,7 @@ from .tokens.doc cimport Doc from .attrs cimport TAG from .parts_of_speech cimport NO_TAG, ADJ, ADV, ADP, CONJ, DET, NOUN, NUM, PRON from .parts_of_speech cimport VERB, X, PUNCT, EOL, SPACE +from .gold cimport GoldParse from .attrs cimport * @@ -134,6 +135,7 @@ cdef class Tagger: for tag in self.tag_names: self.freqs[TAG][self.vocab.strings[tag]] = 1 self.freqs[TAG][0] = 1 + self.cfg = cfg @property def tag_names(self): @@ -180,11 +182,8 @@ cdef class Tagger: self(doc) yield doc - def update(self, Doc tokens, object gold): - if hasattr(gold, 'tags'): - gold_tag_strs = list(gold.tags) - else: - gold_tag_strs = gold + def update(self, Doc tokens, GoldParse gold): + gold_tag_strs = gold.tags assert len(tokens) == len(gold_tag_strs) for tag in gold_tag_strs: if tag != None and tag not in self.tag_names: