From 13c8881d2f27efd11280278a19dac37c08e0079c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Fri, 3 Nov 2017 20:20:59 +0100 Subject: [PATCH] Expose parser's tok2vec model component --- spacy/syntax/nn_parser.pyx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index fc48f2337..acf3d1857 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -753,6 +753,14 @@ cdef class Parser: for doc in docs: hook(doc) + @property + def tok2vec(self): + '''Return the embedding and convolutional layer of the model.''' + if self.model in (None, True, False): + return None + else: + return self.model[0] + @property def postprocesses(self): # Available for subclasses, e.g. to deprojectivize