Skip to main content

Python impl for TextRank

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 spacy download en_core_web_sm

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.

License

PyTextRank has an Apache 2.0 license, so you can use it for commercial applications. Please let us know if you find this useful, and tell us about use cases, what else you’d like to see integrated, etc.

Here’s a Bibtex entry if you ever need to cite PyTextRank in a research paper:

@Misc{PyTextRank,
author =   {Nathan, Paco},
title =    {PyTextRank, a Python implementation of TextRank for text document NLP parsing and summarization},
howpublished = {\url{https://github.com/ceteri/pytextrank/}},
year = {2016}
}

Kudos

@htmartin @williamsmj @eugenep @mattkohl @vanita5 @HarshGrandeur @mnowotka @kjam @dvsrepo @dimmu @laxatives @SaiThejeshwar

Metadata

Release files for pytextrank 1.2.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.2.1
File Size Uploaded
pytextrank-1.2.1.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytextrank 1.2.1
File Interpreter ABI Platform
pytextrank-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.3 kB

Release files / pytextrank-1.2.1.tar.gz

Download URL pytextrank-1.2.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5370dc8e7e4ff70a0a404ef2025841815713fb8105bbdf05d16c1de6429df2cb
BLAKE2b-256 checksum
How to use checksums
a86fe7b4389b6b44076493a7b7a5dcffc42502c2f9c433552a03911f6e3e9b6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / pytextrank-1.2.1-py3-none-any.whl

Download URL pytextrank-1.2.1-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67ca0feeaed8d83ac09fe8a20ac64f280364c1db26464f8405508cb7a2ad5a1d
BLAKE2b-256 checksum
How to use checksums
b1428a769f6b0655ef9c2dc6a49919ab09f0d7795739b3e95c6b98cb744d3674
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

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

This release

1.2.1 This release

2 release files

1.1.0

1 release file

1.0.1

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