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

Can't retrieve unregistered extension attribute 'blob'. #19

Open
dsm-72 opened this issue Mar 3, 2022 · 3 comments
Open

Can't retrieve unregistered extension attribute 'blob'. #19

dsm-72 opened this issue Mar 3, 2022 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@dsm-72
Copy link

dsm-72 commented Mar 3, 2022

Copy pasted from tutorial

import spacy
from spacytextblob.spacytextblob import SpacyTextBlob

nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('spacytextblob')
text = 'I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy.'
doc = nlp(text)
doc._.blob.polarity                            # Polarity: -0.125
doc._.blob.subjectivity                        # Subjectivity: 0.9
doc._.blob.sentiment_assessments.assessments   # Assessments: [(['really', 'horrible'], -1.0, 1.0, None), (['worst', '!'], -1.0, 1.0, None), (['really', 'good'], 0.7, 0.6000000000000001, None), (['happy'], 0.8, 1.0, None)]
doc._.blob.ngrams() 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-b84122143817> in <module>
      6 text = 'I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy.'
      7 doc = nlp(text)
----> 8 doc._.blob.polarity                            # Polarity: -0.125
      9 doc._.blob.subjectivity                        # Subjectivity: 0.9
     10 doc._.blob.sentiment_assessments.assessments   # Assessments: [(['really', 'horrible'], -1.0, 1.0, None), (['worst', '!'], -1.0, 1.0, None), (['really', 'good'], 0.7, 0.6000000000000001, None), (['happy'], 0.8, 1.0, None)]

/opt/anaconda/anaconda3/envs/venv/lib/python3.6/site-packages/spacy/tokens/underscore.py in __getattr__(self, name)
     45     def __getattr__(self, name: str) -> Any:
     46         if name not in self._extensions:
---> 47             raise AttributeError(Errors.E046.format(name=name))
     48         default, method, getter, setter = self._extensions[name]
     49         if getter is not None:

AttributeError: [E046] Can't retrieve unregistered extension attribute 'blob'. Did you forget to call the `set_extension` method?
@SamEdwardes
Copy link
Owner

Can you please confirm the version of spacytextblob that you are using? From the command line you can run:

pip list

Note that ._.blob is new as of version 4.0.0 (https://spacytextblob.netlify.app/changelog/).

@SamEdwardes SamEdwardes added the bug Something isn't working label Mar 3, 2022
@SamEdwardes SamEdwardes self-assigned this Mar 3, 2022
@dsm-72
Copy link
Author

dsm-72 commented Mar 4, 2022

@SamEdwardes I just pip installed it so assume latest? but turns out 3.0.1

@SamEdwardes
Copy link
Owner

Ok make sure you are using 4.0.0 and it should work. Does it work after upgrading?

@SamEdwardes SamEdwardes added question Further information is requested and removed bug Something isn't working labels Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants