chartbeat-labs / textacy

NLP, before and after spaCy
https://textacy.readthedocs.io
Other
2.21k stars 249 forks source link

AttributeError: module 'textacy' has no attribute 'resources' #284

Closed aurora1625 closed 4 years ago

aurora1625 commented 4 years ago

Hi I try to use depechemood, after downloading the resource with

python -m textacy download depeche_mood

Then I try to install it.

rs = textacy.resources.DepecheMood(lang="en", word_rep="lemmapos")

I come across the following behaviour.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-7-72c2e7b4a055> in <module>
----> 1 rs = textacy.resources.DepecheMood(lang="en", word_rep="lemmapos")

AttributeError: module 'textacy' has no attribute 'resources'

environment

{'platform': 'darwin', 'python': '3.7.5 (default, Oct 25 2019, 10:52:18) \n[Clang 4.0.1 (tags/RELEASE_401/final)]', 'spacy': '2.0.16', 'spacy_models': ['en_core_web_lg', 'en_core_web_sm'], 'textacy': '0.9.1'}

Could anyone offer some help?

Thanks!

bdewilde commented 4 years ago

Hi @aurora1625, the resources sub-package isn't imported at the top-level of textacy, so you need to import it specifically:

In [1]: import textacy

In [2]: textacy.resources
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-346557c6846d> in <module>
----> 1 textacy.resources

AttributeError: module 'textacy' has no attribute 'resources'

In [3]: import textacy.resources

In [4]: textacy.resources.DepecheMood()
Out[4]: Resource('depeche_mood')

I'll update the docs if they suggest otherwise.