Spacy: AttributeError: 'spacy.tokens.token.Token' object has no attribute 'label_'

Created on 14 Jun 2017  路  9Comments  路  Source: explosion/spaCy

Hi,

I am learning Spacy for named entity extraction for my project. To practice, I am used the code written by Honnibal at https://github.com/explosion/spaCy/issues/665. But I am getting the error reproduced below:

for ent in doc:
... print(ent.text, ent.label_)
...
Traceback (most recent call last):
File "", line 2, in
AttributeError: 'spacy.tokens.token.Token' object has no attribute 'label_'

Please help to resolve the issue.

I am using:

  • Python Version Used: 2.7
  • spaCy Version Used: 1.8.0

Thanks
tellsathish

usage

Most helpful comment

Check out rasa (https://github.com/RasaHQ/rasa_nlu, https://rasa.ai/), an open-source alternative to luis in part build on spacy.

All 9 comments

Have you tried using ent_type_ ? This might also be helpful: https://spacy.io/docs/api/token

I think the snipper of code I gave is wrong -- it should be for ent in doc.ents. Sorry!

@honnibal

Thanks for the correction. It is working now.
@Liebeck , thanks for your response. The link you had provided helped to learn deeper about Spacy.

I am working on use case for automating ticket resolution for our ITSM (IT service management). the first step is to disambiguate words in the tickets we receive. For example "Install MySQL in my system". I want to annotate the text like [Install:Action/MySQL:Software/System:machine] and parse this further to a format I wanted by adding more details about the machine which I will get from Knowledge-base, which is a graph. The parameters will be sent to RPA tool for resolving the request.

I just want to know if I can use my own vocabulary/taxonomy in Spacy for this use case. If yes, can you give me some pointers how to go about it? Meanwhile, I will do my own research with Spacy.

Thanks,
Sathish PV

Your usage scenario reminds me a lot of the current developments on bot frameworks, namely automatically identifying the user intent. For instance, Microsoft offers a trainable intent mechanism inside LUIS (https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-recognize-intent)
I hope this helps ;)

@Liebeck
Thanks so much. I will explore LUIS further.
Can Spacy be used for the use case? Thought?

Thanks
Sathish PV

@satjaydepdar As far as my knowledge about spaCy goes, I'd say that spaCy can definetly be used as a part of what you have planned. I guess some things need to be stacked on top of spaCy. Custom taxonomy should be possible with the custom annotation pipeline components introduced in v2.0 or after you have used spaCy to process your texts.

Check out rasa (https://github.com/RasaHQ/rasa_nlu, https://rasa.ai/), an open-source alternative to luis in part build on spacy.

@Liebeck

I went through the rasa.ai contents. I am getting hope that it will help to solve my use case. I will work on it more this week-end. Thanks for pointing me to the tool.

Thanks
Sathish PV

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.

Was this page helpful?
0 / 5 - 0 ratings