Skip to main content

A text summarization and keyword extraction package based on TextRank

Project description

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

Installation

This software 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 danish, dutch, english, finnish, french, german, hungarian, italian, norwegian, porter, portuguese, romanian, russian, spanish, 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
summa-1.1.0.tar.gz (48.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page