Skip to main content

Python implementation of TextRank, based on the Mihalcea 2004 paper.

Modifications to the original algorithm by Rada Mihalcea, et al. include:

  • fixed bug; see Java impl, 2008

  • use of lemmatization instead of stemming

  • verbs included in the graph (but not in the resulting keyphrases)

  • named entity recognition

  • normalized keyphrase ranks used in summarization

The results produced by this implementation are intended more for use as feature vectors in machine learning, not as academic paper summaries.

Inspired by Williams 2016 talk on text summarization.

Example Usage

See PyTextRank wiki

Dependencies and Installation

This code has dependencies on several other Python projects:

To install from PyPi:

pip install pytextrank

To install from this Git repo:

pip install -r requirements.txt

After installation you need to download a language model:

python -m nltk.downloader punkt
python -m nltk.downloader wordnet
python -m textblob.download_corpora
python -m spacy.en.download all

Also, the runtime depends on a local file called stop.txt which contains a list of stopwords. You can override this in the normalize_key_phrases() call.

Kudos

@htmartin @williamsmj @eugenep @mattkohl @vanita5 @HarshGrandeur @mnowotka @kjam

Release files for pytextrank 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytextrank 1.0.1
File Size Uploaded
pytextrank-1.0.1.tar.gz 8.9 kB Details

Release files / pytextrank-1.0.1.tar.gz

Download URL pytextrank-1.0.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ea76f42716a92ab0d30cf1765e5d824d416462b7f54d6ac1381f40270d27362f
BLAKE2b-256 checksum
How to use checksums
80f41753133243756d85fee8afdcc62643552b2ec969e4df62153aeacdf6a6e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.3.0

2 release files

3.2.5

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.0

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.1.0

1 release file

This release

1.0.1 This release

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page