Skip to main content

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

Modifications to the original Mihalcea algorithm include:

  • fixed bug; see Java impl, 2008

  • use of lemmatization instead of stemming

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

  • 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.

Dependencies and Installation

This code has dependencies on several other Python projects:

To install:

pip install -r requirements.txt

The runtime depends on a local file called stop.txt which contains a list of stopwords.

Install model

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

Example Usage

See PyTextRank wiki

Kudos

@htmartin @williamsmj @eugenep @mattkohl @HarshGrandeur @mnowotka

Metadata

Release files for pytextrank 1.0

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
File Size Uploaded Provenance
pytextrank-1.0.tar.gz 8.4 kB Without provenance Details

Release files / pytextrank-1.0.tar.gz

Download URL pytextrank-1.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
412ed08fa3982fb0fe1315bb737b753d813bf6ebcd1c81aae6d83d35e557b3f9
BLAKE2b-256 checksum
How to use checksums
94c0053428d01bd01e2047c56651c6ea67fac16945eaed8f150435390beea620
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pytextrank 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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