Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unhashable type: 'spacy.tokens.span.Span' #1019

Closed
avissens opened this issue Apr 26, 2017 · 3 comments
Closed

TypeError: unhashable type: 'spacy.tokens.span.Span' #1019

avissens opened this issue Apr 26, 2017 · 3 comments
Labels
enhancement Feature requests and improvements

Comments

@avissens
Copy link

avissens commented Apr 26, 2017

TypeError: unhashable type: 'spacy.tokens.span.Span'

I use nlp(text) to get human names from news articles. I gather all PERSON ents into a list but when I try to manipulate the list I get this error: TypeError: unhashable type: 'spacy.tokens.span.Span'

My code:

text='James Harding, professor at the UCL, and Lucy Smith, a student.'
text=u"{}".format(text)
all_tags = nlp(text)
names=[]
for ent in all_tags.ents:
    if ent.label_=="PERSON":
        names.append(ent)
print names
print type(names)
myset = list(set(names)) #remove duplicates
print(myset)
mynewlist = [ x for x in myset if " " in x ] # remove lonely names
print(mynewlist)

Output:

[James Harding, Lucy Smith]
<type 'list'>

TypeError Traceback (most recent call last)
in ()
8 print names
9 print type(names)
---> 10 myset = list(set(names)) #remove duplicates
11 print(myset)
12 mynewlist = [ x for x in myset if " " in x ] # remove lonely names

TypeError: unhashable type: 'spacy.tokens.span.Span'

Your Environment

Info about spaCy

  • Python version: 2.7.13
  • Platform: Darwin-16.4.0-x86_64-i386-64bit
  • spaCy version: 1.8.1
  • Installed models: en
@honnibal
Copy link
Member

Added, thanks!

@honnibal honnibal added the enhancement Feature requests and improvements label Apr 26, 2017
@avissens
Copy link
Author

I uninstall and install the package again but I get the same error...

@lock
Copy link

lock bot commented May 8, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Feature requests and improvements
Projects
None yet
Development

No branches or pull requests

2 participants