Skip to main content

TextRank implementation for text summarization and keyword extraction in Python 3, with optimizations on the similarity function.

Features

  • Text summarization

  • Keyword extraction

Examples

Text summarization:

>>> text = """Automatic summarization is the process of reducing a text document with a \
computer program in order to create a summary that retains the most important points \
of the original document. As the problem of information overload has grown, and as \
the quantity of data has increased, so has interest in automatic summarization. \
Technologies that can make a coherent summary take into account variables such as \
length, writing style and syntax. An example of the use of summarization technology \
is search engines such as Google. Document summarization is another."""

>>> from summa import summarizer
>>> print(summarizer.summarize(text))
'Automatic summarization is the process of reducing a text document with a computer
program in order to create a summary that retains the most important points of the
original document.'

Keyword extraction:

>>> from summa import keywords
>>> print(keywords.keywords(text))
document
summarization
writing
account

Note that line breaks in the input will be used as sentence separators, so be sure to preprocess your text accordingly.

Installation

This software is available in PyPI. It depends on NumPy and Scipy, two Python libraries for scientific computing. Pip will automatically install them along with summa:

pip install summa

For a better performance of keyword extraction, install Pattern.

More examples

  • Command-line usage:

    textrank -t FILE
  • Define length of the summary as a proportion of the text (also available in keywords):

    >>> from summa.summarizer import summarize
    >>> summarize(text, ratio=0.2)
  • Define length of the summary by aproximate number of words (also available in keywords):

    >>> summarize(text, words=50)
  • Define input text language (also available in keywords).

    The available languages are arabic, danish, dutch, english, finnish, french, german, hungarian, italian, norwegian, polish, porter, portuguese, romanian, russian, spanish and swedish:

    >>> summarize(text, language='spanish')
  • Get results as a list (also available in keywords):

    >>> summarize(text, split=True)
    ['Automatic summarization is the process of reducing a text document with a
    computer program in order to create a summary that retains the most important
    points of the original document.']

References

To cite this work:

@article{DBLP:journals/corr/BarriosLAW16,
  author    = {Federico Barrios and
             Federico L{\'{o}}pez and
             Luis Argerich and
             Rosa Wachenchauzer},
  title     = {Variations of the Similarity Function of TextRank for Automated Summarization},
  journal   = {CoRR},
  volume    = {abs/1602.03606},
  year      = {2016},
  url       = {http://arxiv.org/abs/1602.03606},
  archivePrefix = {arXiv},
  eprint    = {1602.03606},
  timestamp = {Wed, 07 Jun 2017 14:40:43 +0200},
  biburl    = {https://dblp.org/rec/bib/journals/corr/BarriosLAW16},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

Summa is open source software released under the The MIT License (MIT).

Copyright (c) 2014 – now Summa NLP.

Release files for summa 1.2.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 summa 1.2.0
File Size Uploaded
summa-1.2.0.tar.gz 54.9 kB Details

Release files / summa-1.2.0.tar.gz

Download URL summa-1.2.0.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6eb60e4e3d3859e7d951f36a3515573becf096ca404ae806a2f1e8fa7a53a0fc
BLAKE2b-256 checksum
How to use checksums
453b1c7dc435d05aef474c4137328400f1e11787b9bffab1f87a3f160c1fef54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.12.4 setuptools/36.2.7 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/2.7.13

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.1.0

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.1

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