Skip to content
Python implementation of TextRank for text document NLP parsing and summarization
Branch: master
Clone or download
Pull request Compare This branch is even with DerwenAI:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dat
docs
pytextrank
.gitignore
LICENSE
MANIFEST.in
README.rst
changelog.txt
example.ipynb
requirements.txt
run.sh
scrub.py
setup.py
stage1.py
stage2.py
stage3.py
stage4.py
stop.txt

README.rst

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

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

You can’t perform that action at this time.