From ca320afe86c1580c558ba8c23f79e2f09538e2f3 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 13 May 2015 21:20:47 +0200 Subject: [PATCH] * Add docstring for ents attribute --- spacy/tokens.pyx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spacy/tokens.pyx b/spacy/tokens.pyx index 3d90abb8b..348d02068 100644 --- a/spacy/tokens.pyx +++ b/spacy/tokens.pyx @@ -143,7 +143,17 @@ cdef class Tokens: @property def ents(self): - """Yields named-entity Span objects.""" + """Yields named-entity Span objects. + + Iterate over the span to get individual Token objects, or access the label: + + >>> from spacy.en import English + >>> nlp = English() + >>> tokens = nlp(u'Mr. Best flew to New York on Saturday morning.') + >>> ents = list(tokens.ents) + >>> ents[0].label, ents[0].label_, ''.join(t.orth_ for t in ents[0]) + (112504, u'PERSON', u'Best ') + """ cdef int i cdef const TokenC* token cdef int start = -1