AttributeError: module 'pytextrank' has no attribute 'TextRank'
See original GitHub issueSteps to Reproduce
corpus = st.CorpusFromParsedDocuments(
convention_df,
category_col='category',
parsed_col='parse',
feats_from_spacy_doc=st.PyTextRankPhrases()
).build(
).compact(
AssociationCompactor(2000, use_non_text_features=True)
)
Error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
...
~/.local/share/virtualenvs/.../lib/python3.8/site-packages/scattertext/features/PyTextRankPhrases.py in get_doc_metadata(self, doc)
32 import pytextrank
33 phrase_counter = Counter()
---> 34 tr = pytextrank.TextRank()
35 tr.doc = doc
36 phrases = tr.calc_textrank()
AttributeError: module 'pytextrank' has no attribute 'TextRank'
Expected behavior
No error.
Environment
- Scattertext version (e.g., 0.0.2.75): 0.1.0.0
- OS (e.g., Linux): Ubuntu 20.04
- How you installed PyTorch (
conda
,pip
, source):pipenv
- Python version: 3.8
- Any other relevant information: spacy 3.0.1
Additional context
Looks like pytextrank
no longer has the attribute TextRank
. Maybe you should change the code in scattertext/features/PyTextRankPhrases.py
from tr = pytextrank.TextRank()
to spacy pipeline.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Module 'pytextrank' has no attribute 'parse_doc' - Stack Overflow
Implementation of TextRank in Python for use in spaCy pipelines import spacy import pytextrank nlp = spacy.load('en_core_web_sm') tr ...
Read more >pytextrank - PyPI
PyTextRank is a Python implementation of TextRank as a spaCy pipeline extension, for graph-based natural language work -- and related knowledge graph practices....
Read more >Keyword and Sentence Extraction with TextRank (pytextrank)
TextRank is a graph based algorithm for Natural Language Processing that can be used for keyword and sentence extraction.
Read more >Troubleshooting FAQ - pytextrank - derwen.ai
AttributeError : type object 'Language' has no attribute 'factory'¶. This message is a spaCy 2.x error. Somewhere, somehow, a Python environment ...
Read more >textrank python - Code Examples & Solutions For This ...
pip install pytextrank python -m spacy download en_core_web_sm.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just released v0.1.2 which enables Scattertext to work with PTR v3. The results on the convention data set look a little better using the new version.
Thanks for the bug report. I ran into some issues using PyTextRank to parse multiple documents with the same spaCy Language instance. Not sure if these persist in PTR v3, but the easiest thing to do would be to explicitly use an earlier version.