Skip to main content

SummaryMaker

A Python command-line tool for text summarization that can process both text files and web articles.

Features

  • Summarize text from local files
  • Extract and summarize content from web URLs
  • Configurable summarization model selection
  • Adjustable summary length
  • Support for multiple text encodings

Installation

From PyPI

pip install summarymaker

Development Installation

git clone https://github.com/hwang2006/summarymaker
cd summarymaker
pip install -e .[dev]

Dependencies

  • Python >= 3.7
  • click>=8.0.0
  • transformers>=4.0.0
  • torch==2.4.0
  • numpy<2.0
  • beautifulsoup4>=4.9.0
  • requests>=2.25.0
  • flask>=2.0.0

Usage

# Summarize a text file
summarymaker --file examples/test.txt

# Summarize content from a URL
summarymaker --url https://example.com

# Customize the model and summary length
summarymaker --file examples/test_article.txt --model facebook/bart-large-cnn --max-length 200

Flask Web Application

To run the Flask web application, use the following command:

  1. Navigate to the src/summarizer/webapp directory.
  2. Run the Flask application:
python app.py
  1. Open your web browser and go to http://127.0.0.1:5000/.
  2. Choose the input type (URL, File, or Text), provide the input, and click "Summarize". Flask GUI

Gradio Web Application

Local Deployment

To run the Gradio web application, use the following command:

  1. Navigate to the src/summarizer/webapp directory.
  2. Run the Gradio application:
python gradio_app.py
  1. Open your web browser and go to http://127.0.0.1:7860/.
  2. This will start a Gradio web server, and you can interact with the summarization application through a web browser. Gradio GUI

Online Deployment on Koyeb

The Gradio web application is deployed on Koyeb, a serverless platform that simplifies hosting and managing applications, allowing quick and scalable deployments. You can try out the SummaryMaker Web application using the following steps:

  1. Open your web browser and go to SummaryMaker on Koyeb
  2. Choose the input type (URL, File, or Text).
  3. Provide the input (URL, upload a file, or enter text directly).
  4. Select a text summarization model (e.g., google/flan-t5-small ) on Hugging Face.
  5. Optionally adjust the maximum summary length.
  6. Click "Summarize" to generate the summary.

Command-Line Options

  • --file: Path to a text file to summarize
  • --url: URL of web content to summarize
  • --model: Name of the transformer model to use (default: t5-small)
  • --max-length: Maximum length of the summary in tokens (default: 180)

Examples

# Basic file summarization
summarymaker --file examples/test.txt

# Web article summarization
summarymaker --url https://en.wikipedia.org/wiki/Seoul

# Custom model and length. 
# Unlike the t5-base model, the facebook/bart-large-cnn model can handle inputs only up to 512 tokens.
summarymaker --file examples/test_article.md --model facebook/bart-large-cnn --max-length 250

# allenai/led-base-16384 is a Longformer Encoder-Decoder (LED) model designed to handle long sequences.
summarymaker --file examples/test_article.md --model allenai/led-base-16384 --max-length 1024

Development

The project follows a standard Python package structure:

  • Source code is located in src/summarizer/
  • Tests are in the tests/ directory
  • Example files can be found in examples/
  • Configuration files include pyproject.toml and setup.py

Project Structure

summarymaker/
├── CHANGELOG.md
├── LICENSE
├── MANIFEST.in
├── README.md
├── assets/
│   ├── flask_gui.png
│   └── gradio_gui.png
├── examples/
│   ├── test.txt
│   ├── test_article.md
│   └── test_article.txt
├── myvenv/
├── pyproject.toml
├── setup.py
├── src/
│   └── summarizer/
│       ├── __init__.py
│       ├── cli.py
│       ├── summarizer.py
│       ├── utils.py
│       └── webapp/
│           ├── app.py
│           ├── gradio_app.py
│           └── templates/
│               └── index.html
└── tests/
    ├── __init__.py
    ├── conftest.py
    ├── test_cli.py
    ├── test_summarizer.py
    └── test_utils.py

Contributing

We welcome contributions from the community! Here's how you can help:

Getting Started

  1. Fork the repository
  2. Create a new branch for your feature (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines for Python code
  • Write tests for new features using pytest
  • Update documentation to reflect any changes
  • Add new examples if introducing new functionality
  • Update the CHANGELOG.md file with your changes

Running Tests

# Install development dependencies
pip install -e .[dev]

# Run tests
pytest tests/

# Run tests with coverage
coverage run -m pytest tests/
coverage report

Documentation

  • Update docstrings for any new functions or classes
  • Keep the README.md updated with new features or changes
  • Add inline comments for complex logic

Code Review Process

  1. Maintainers will review your Pull Request
  2. Address any comments or requested changes
  3. Once approved, your code will be merged
  4. Your contribution will be added to the CHANGELOG.md

For major changes, please open an issue first to discuss what you would like to change. This ensures your time is well spent and your contribution aligns with the project's direction.

License

Copyright (c) 2024 [Soonwook Hwang]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for summarymaker 0.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for summarymaker 0.2.9
File Size Uploaded Provenance
summarymaker-0.2.9.tar.gz 173.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for summarymaker 0.2.9
File Interpreter ABI Platform
summarymaker-0.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 340.1 kB

Release files / summarymaker-0.2.9.tar.gz

Download URL summarymaker-0.2.9.tar.gz
Size 173.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6dad48b79cea5cf0c56de2a64a2cefde941149ad4db4ca8d9cf5da1c5d17de5
BLAKE2b-256 checksum
How to use checksums
1e7327826316f6d811ad4941f6d1ddbbe05a0d5e1cdf0d4f3e01a9c72141545e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release files / summarymaker-0.2.9-py3-none-any.whl

Download URL summarymaker-0.2.9-py3-none-any.whl
Size 166.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1478de8a5615d3b8fc33f01d66792f11f08c00e58073396e279f3f52b54963a
BLAKE2b-256 checksum
How to use checksums
cfdb816a2be3357b4515d4295a8720e4d0ca0961aa180b78e3b7f5bdddf86cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Security for summarymaker 0.2.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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