You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example code will fail because defaultdict takes a Callable. You can fix the documentation by changing the inner defaultdict to a Counter object. It would also be nice to include the import statement for VERB so people can quickly see what it is referencing. I'd be happy to update the docs in the proposed way, if you think it would be helpful.
Here's what happens.
def count_parent_verb_by_person(docs):
counts = defaultdict(defaultdict(int))
for doc in docs:
for ent in doc.ents:
if ent.label_ == 'PERSON' and ent.root.head.pos == VERB:
counts[ent.orth_][ent.root.head.lemma_] += 1
return counts
with the error:
<ipython-input-61-8df8d6283e14> in count_parent_verb_by_person(docs)
6
7 def count_parent_verb_by_person(docs):
----> 8 counts = defaultdict(defaultdict(int))
9 for doc in docs:
10 for ent in doc.ents:
TypeError: first argument must be callable or None
spacy version: 1.6.0
Python 3.5.2 :: Continuum Analytics, Inc.
The text was updated successfully, but these errors were encountered:
dmlicht
changed the title
error in Named entities example code
Error in Named Entities Example Code
Mar 15, 2017
The example code will fail because
defaultdict
takes aCallable
. You can fix the documentation by changing the innerdefaultdict
to aCounter
object. It would also be nice to include the import statement for VERB so people can quickly see what it is referencing. I'd be happy to update the docs in the proposed way, if you think it would be helpful.Here's what happens.
with the error:
spacy version: 1.6.0
Python 3.5.2 :: Continuum Analytics, Inc.
The text was updated successfully, but these errors were encountered: