Skip to main content

A command-line and web application tool for text summarization

Project description

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

Web Application

  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".

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
summarymaker --file examples/test_article.md --model facebook/bart-large-cnn --max-length 250

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              # Changelog file detailing version history
├── LICENSE                   # License file for your package
├── MANIFEST.in              # Specifies source files to include in the package
├── README.md                # Project description and documentation
├── examples/                # Directory for example files
│   ├── test.txt
│   ├── test_article.md
│   └── test_article.txt
├── myvenv/                  # Virtual environment directory (usually not committed to VCS)
├── pyproject.toml           # Configuration for build tools
├── setup.py                 # Script for installing the package
├── src/                     # Source directory
│   └── summarizer/          # Main package directory
│       ├── __init__.py      # Initializes the package
│       ├── cli.py           # Command-line interface for the package
│       ├── summarizer.py    # Core summarization logic
│       ├── utils.py         # Helper functions
│       └── webapp/          # Web application directory
│           ├── app.py       # Flask web application
│           └── templates/   # HTML templates for the web application
│               └── index.html # Main HTML template
└── tests/                   # Directory for test files
    ├── __init__.py          # Initializes the test package
    ├── conftest.py          # Configuration for pytest
    ├── test_cli.py         # Tests for the CLI
    ├── test_summarizer.py  # Tests for the summarization logic
    └── test_utils.py       # Tests for helper functions

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.

Project details


Download files

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

Source Distribution

summarymaker-0.2.0.tar.gz (163.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

summarymaker-0.2.0-py3-none-any.whl (156.1 kB view details)

Uploaded Python 3

File details

Details for the file summarymaker-0.2.0.tar.gz.

File metadata

  • Download URL: summarymaker-0.2.0.tar.gz
  • Upload date:
  • Size: 163.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for summarymaker-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b6ba9cae9d2d50218b779b411c24f50a837d4a370765ee52b4caa74e34d4ca44
MD5 abc529f586d71a8257911027a473edfd
BLAKE2b-256 c56c7aa2643a191653657b34dd32f1b36b626918f10d9d25eac0e4fecbfbeb06

See more details on using hashes here.

File details

Details for the file summarymaker-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: summarymaker-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 156.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for summarymaker-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19a8312f4288c51ce6a30c2b4b3582e7b8af2c55084eddfae7b58c11f7d3838b
MD5 dfa5c15c364df195f5677c7d372a3387
BLAKE2b-256 0a162525d2e663a0ee19a98f86ee6539f52b1e2da4b032050fbc6f5916b017f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page