Skip to content

sumy

3,533 2 24 Apache-2.0
0.11.0 (23 Oct 2022) Oct 20 2013 261.2 thousand (month)

sumy is a Python library for automatic summarization of text documents. It can be used to extract summaries from various input formats such as plaintext, HTML, and URLs. It supports multiple languages and multiple summarization algorithms, including Latent Semantic Analysis (LSA), Luhn, Edmundson, TextRank, and SumBasic.

Example Use


# -*- coding: utf-8 -*-

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 = "english"
SENTENCES_COUNT = 10


if __name__ == "__main__":
    url = "https://en.wikipedia.org/wiki/Automatic_summarization"
    parser = HtmlParser.from_url(url, Tokenizer(LANGUAGE))
    # or for plain text files
    # parser = PlaintextParser.from_file("document.txt", Tokenizer(LANGUAGE))
    # parser = PlaintextParser.from_string("Check this out.", 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)

Alternatives / Similar


1,860 2024.2.26 (9 months ago) Dec 14 2008 compare
3,703 2.0.0 (6 days ago) Jul 17 2019 compare
14,204 0.2.8 (6 years ago) Dec 28 2012 compare
859 0.18.0 (a month ago) Oct 27 2015 compare
2,675 0.8.1 (4 years ago) Jun 30 2011 compare
246 2.0.7 (2 years ago) Dec 11 2020 compare
11,112 1.1.9 (6 years ago) Aug 24 2018 compare

Other Languages

2,565 v1.3.0 (9 months ago) Apr 20 2016 compare
Was this page helpful?