This bug was first reported in #658 (comment) and I can reproduce on the latest release.
doc = nlp(u"Employees are recruiting talented staffers from overseas.")
list(doc.noun_chunks) # [Employees, talented staffers]
span = doc[0:4]
list(span.noun_chunks) # ERROR
for sent in doc.sents:
list(sent.noun_chunks) # ERROR
it raises the following exception:
/lib/python2.7/site-packages/spacy/tokens/span.pyx in __get__ (spacy/tokens/span.cpp:7229)()
231 spans = []
232 for start, end, label in self.doc.noun_chunks_iterator(self):
--> 233 spans.append(Span(self, start, end, label=label))
234 for span in spans:
235 yield span
TypeError: Argument 'doc' has incorrect type (expected spacy.tokens.doc.Doc, got spacy.tokens.span.Span)
For resolution (and forgive me for not actually doing the PR myself) I am pretty sure we just need to pass self.doc to the Scan constructor, rather than self:
232 for start, end, label in self.doc.noun_chunks_iterator(self):
233 spans.append(Span(self.doc, start, end, label=label))
# ++++
This bug was first reported in #658 (comment) and I can reproduce on the latest release.
it raises the following exception:
For resolution (and forgive me for not actually doing the PR myself) I am pretty sure we just need to pass
self.docto theScanconstructor, rather thanself: