From caf046b22080ab4ec666ce31f4dee0f6ace598f3 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 23 Feb 2015 15:40:17 -0500 Subject: [PATCH] * Hastily add method to apply tags from a list of strings, instead of predicting the tags. --- spacy/en/pos.pyx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spacy/en/pos.pyx b/spacy/en/pos.pyx index 2cfb6519f..1094d5c09 100644 --- a/spacy/en/pos.pyx +++ b/spacy/en/pos.pyx @@ -284,6 +284,16 @@ cdef class EnPosTagger: tokens.is_tagged = True tokens._py_tokens = [None] * tokens.length + def tag_from_strings(self, Tokens tokens, object tag_strs): + cdef int i + for i in range(tokens.length): + tokens.data[i].tag = self.tag_names.index(tag_strs[i]) + self.set_morph(i, tokens.data) + # TODO: Clean this up. + tokens._tag_strings = tuple(self.tag_names) + tokens.is_tagged = True + tokens._py_tokens = [None] * tokens.length + def train(self, Tokens tokens, object gold_tag_strs): cdef int i cdef int loss