From 2e0104ac81a2ccbea745ed19b8dc053a9ef2ff27 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 15 Oct 2015 03:47:45 +1100 Subject: [PATCH] * Fix token.conjuncts --- spacy/tokens/token.pyx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index bb2bbdf89..1f672ee35 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -250,20 +250,14 @@ cdef class Token: def __get__(self): """Get a list of conjoined words.""" cdef Token word - conjs = [self] + conjuncts = [] if self.c.pos != CONJ and self.c.pos != PUNCT: - seen_conj = False for word in self.rights: - if word.c.pos == CONJ: - seen_conj = True - elif seen_conj and word.c.pos == self.c.pos: - conjs.append(word) - if seen_conj: - return conjs - elif self is not self.head and self in self.head.conjuncts: - return self.head.conjuncts - else: - return [] + if word.dep_ == 'conj': + yield word + yield from word.conjuncts + conjuncts.append(word) + conjuncts.extend(word.conjuncts) property ent_type: def __get__(self):