question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: module 'pytextrank' has no attribute 'TextRank'

See original GitHub issue

Steps 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JasonKesslercommented, Mar 8, 2021

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.

1reaction
JasonKesslercommented, Mar 8, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found