Skip to main content

Automatic text summarizer

https://api.travis-ci.org/miso-belica/sumy.png?branch=master

Here are some other summarizers:

Installation

Make sure you have Python 2.6+/3.2+ and pip (Windows, Linux) installed. Run simply (preferred way):

$ [sudo] pip install sumy

Or for the fresh version:

$ [sudo] pip install git+git://github.com/miso-belica/sumy.git

Or if you have to:

$ wget https://github.com/miso-belica/sumy/archive/master.zip # download the sources
$ unzip master.zip # extract the downloaded file
$ cd sumy-master/
$ [sudo] python setup.py install # install the package

Usage

Sumy contains command line utility for quick summarization of documents.

$ sumy lex-rank --length=10 --url=http://en.wikipedia.org/wiki/Automatic_summarization # what's summarization?
$ sumy luhn --language=czech --url=http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
$ sumy edmundson --language=czech --length=3% --url=http://cs.wikipedia.org/wiki/Bitva_u_Lipan
$ sumy --help # for more info

Various evaluation methods for some summarization method can be executed by commands below:

$ sumy_eval lex-rank reference_summary.txt --url=http://en.wikipedia.org/wiki/Automatic_summarization
$ sumy_eval lsa reference_summary.txt --language=czech --url=http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
$ sumy_eval edmundson reference_summary.txt --language=czech --url=http://cs.wikipedia.org/wiki/Bitva_u_Lipan
$ sumy_eval --help # for more info

Python API

Or you can use sumy like a library in your project.

# -*- coding: utf8 -*-

from __future__ import absolute_import
from __future__ import division, print_function, unicode_literals

from sumy.parsers.html import HtmlParser
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer as Summarizer
from sumy.nlp.stemmers import Stemmer
from sumy.utils import get_stop_words


LANGUAGE = "czech"
SENTENCES_COUNT = 10


if __name__ == "__main__":
    url = "http://www.zsstritezuct.estranky.cz/clanky/predmety/cteni/jak-naucit-dite-spravne-cist.html"
    parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
    # or for plain text files
    # parser = PlaintextParser.from_file("document.txt", Tokenizer(LANGUAGE))
    stemmer = Stemmer(LANGUAGE)

    summarizer = Summarizer(stemmer)
    summarizer.stop_words = get_stop_words(LANGUAGE)

    for sentence in summarizer(parser.document, SENTENCES_COUNT):
        print(sentence)

Tests

Run tests via

$ nosetests-2.6 && nosetests-3.2 && nosetests-2.7 && nosetests-3.3

Changelog

0.3.0 (2014-06-07)

  • Added possibility to specify format of input document for URL & stdin. Thanks to @Lucas-C.

  • Added possibility to specify custom file with stop-words in CLI. Thanks to @Lucas-C.

  • Added support for French language (added stopwords & stemmer). Thanks to @Lucas-C.

  • Function sumy.utils.get_stop_words raises LookupError instead of ValueError for unknown language.

  • Exception LookupError is raised for unknown language of stemmer instead of falling silently to null_stemmer.

0.2.1 (2014-01-23)

  • Fixed installation of my own readability fork. Added breadability to the dependencies instead of it #8. Thanks to @pratikpoddar.

0.2.0 (2014-01-18)

  • Removed dependency on SciPy #7. Use numpy.linalg.svd implementation. Thanks to Shantanu.

0.1.0 (2013-10-20)

  • First public release.

Metadata

Release files for sumy 0.3.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 sumy 0.3.0
File Size Uploaded
sumy-0.3.0.zip 45.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sumy 0.3.0
File Interpreter ABI Platform
sumy-0.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 87.7 kB

Release files / sumy-0.3.0.zip

Download URL sumy-0.3.0.zip
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f0755f044118fe95a7c5e01dae973a2a894b1a5975b7bb7a7e73e63faad8ab9c
BLAKE2b-256 checksum
How to use checksums
003b0cb489965c06955f8ca42b6922b293fe2ad6449f8be7bf2d12856f083a0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / sumy-0.3.0-py2.py3-none-any.whl

Download URL sumy-0.3.0-py2.py3-none-any.whl
Size 42.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ac5a81e4b169a8d2549dcd1f0b6ca286698825b7f38f4dd7750dbbcf27bff338
BLAKE2b-256 checksum
How to use checksums
9ac27b9fe97308353b62b58b9beea7390f9b42e2080d5b5ab23d591c45ab1b8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.1

3 release files

0.2.0

6 release files

0.1.0

1 release file

0.0.1

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