MCPcopy
hub / github.com/miso-belica/sumy

github.com/miso-belica/sumy @v0.12.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.12.0 ↗
530 symbols 2,160 edges 71 files 66 documented · 12%
README

Automatic text summarizer

image GitPod Ready-to-Code

Simple library and command line utility for extracting summary from HTML pages or plain texts. The package also contains simple evaluation framework for text summaries. Implemented summarization methods are described in the documentation. I also maintain a list of alternative implementations of the summarizers in various programming languages.

Is my natural language supported?

There is a good chance it is. But if not it is not too hard to add it.

Installation

Make sure you have Python 3.8+ installed.

Using uv (recommended)

uv is a modern, fast Python package installer and resolver.

$ uv pip install sumy
$ uv pip install git+https://github.com/miso-belica/sumy.git  # for the fresh version

Using pip

$ pip install sumy
$ pip install git+git://github.com/miso-belica/sumy.git  # for the fresh version

For development

If you want to contribute or modify the code:

$ git clone https://github.com/miso-belica/sumy.git
$ cd sumy
$ uv sync               # Install dependencies (dev group included automatically)
$ uv run pytest         # Run tests
$ uv run sumy --help    # Run sumy using uv

Usage

Thanks to some good soul out there, the easiest way to try sumy is in your browser at https://huggingface.co/spaces/issam9/sumy_space

Sumy contains command line utility for quick summarization of documents.

$ sumy lex-rank --length=10 --url=https://en.wikipedia.org/wiki/Automatic_summarization # what's summarization?
$ sumy lex-rank --language=uk --length=30 --url=https://uk.wikipedia.org/wiki/Україна
$ sumy luhn --language=czech --url=https://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
$ sumy edmundson --language=czech --length=3% --url=https://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=https://en.wikipedia.org/wiki/Automatic_summarization
$ sumy_eval lsa reference_summary.txt --language=czech --url=https://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
$ sumy_eval edmundson reference_summary.txt --language=czech --url=https://cs.wikipedia.org/wiki/Bitva_u_Lipan
$ sumy_eval --help # for more info

If you don't want to bother by the installation, you can try it as a container.

$ docker run --rm misobelica/sumy lex-rank --length=10 --url=https://en.wikipedia.org/wiki/Automatic_summarization

Python API

Or you can use sumy like a library in your project. Create file sumy_example.py (don't name it sumy.py) with the code below to test it.

# -*- 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)

Interesting projects using sumy

I found some interesting projects while browsing the internet or sometimes people wrote me an e-mail with questions, and I was curious how they use the sumy :)

  • Learning to generate questions from text - https://github.com/adityasarvaiya/Automatic_Question_Generation
  • Summarize your video to any duration - https://github.com/aswanthkoleri/VideoMash and similar https://github.com/OpenGenus/vidsum
  • Tool for collectively summarizing large discussions - https://github.com/amyxzhang/wikum
  • AutoTL;DR bot for Lemmy uses sumy: https://github.com/RikudouSage/LemmyAutoTldrBot

Core symbols most depended-on inside this repo

build_document
called by 59
tests/utils.py
to_unicode
called by 28
sumy/_compat.py
get_stop_words
called by 16
sumy/utils.py
to_string
called by 16
sumy/_compat.py
_palatalize
called by 16
sumy/nlp/stemmers/czech.py
rate_sentence
called by 15
sumy/summarizers/luhn.py
from_string
called by 15
sumy/parsers/html.py
term_frequency
called by 15
sumy/models/tf.py

Shape

Function 307
Method 185
Class 37
Route 1

Languages

Python100%

Modules by API surface

sumy/nlp/tokenizers.py30 symbols
tests/test_summarizers/test_edmundson.py29 symbols
tests/test_evaluation/test_evaluation_coselection.py20 symbols
tests/test_summarizers/test_luhn_sentence_rating.py19 symbols
sumy/summarizers/edmundson.py19 symbols
sumy/summarizers/sum_basic.py15 symbols
sumy/evaluation/rouge.py15 symbols
tests/test_utils/test_compat.py14 symbols
sumy/utils.py13 symbols
sumy/summarizers/kl.py13 symbols
tests/test_summarizers/test_sum_basic.py12 symbols
sumy/evaluation/__main__.py12 symbols

Dependencies from manifests, versioned

breadability0.1.20 · 1×
docopt-ng0.6.1 · 1×
lxml-html-clean
nltk3.0.2 · 1×
pycountry18.2.23 · 1×
requests2.7.0 · 1×
setuptools65.0.0 · 1×

For agents

$ claude mcp add sumy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact