Skip to main content

A text summarization tool using GloVe embeddings and PageRank algorithm

Project description

Text Summarizer

A Python-based text summarization tool that uses GloVe word embeddings and PageRank algorithm to generate extractive summaries of documents.

Features

  • Extractive Summarization: Uses sentence similarity and PageRank to identify the most important sentences
  • GloVe Embeddings: Leverages pre-trained GloVe word vectors for semantic similarity calculation
  • Multiple Input Methods: Support for single documents, CSV files, or interactive creation
  • GUI Interface: User-friendly Tkinter-based graphical interface
  • Command Line Interface: Scriptable command-line tool for automation
  • Batch Processing: Process multiple documents at once

Installation

Prerequisites

  • Python 3.8 or higher
  • Required packages (automatically installed): pandas, numpy, nltk, scikit-learn, networkx

Install from PyPI

pip install text-summarizer-aweebtaku

Note: This package includes the GloVe word embeddings file (~400MB), so the installation may take some time.

Install from Source

  1. Clone the repository:
git clone https://github.com/AWeebTaku/Summarizer.git
cd Summarizer
  1. Install the package:
pip install -e .

Note: The GloVe word embeddings are included in the package, so no additional download is required.

Usage

Command Line Interface

# Summarize a CSV file
text-summarizer-aweebtaku --csv-file data/tennis.csv --article-id 1

# Interactive mode
text-summarizer-aweebtaku

Graphical User Interface

# Launch GUI (easiest way)
text-summarizer-aweebtaku --gui

# Or use the dedicated GUI command
text-summarizer-gui

Python API

from text_summarizer import TextSummarizer
import pandas as pd

# Initialize summarizer
summarizer = TextSummarizer(glove_path='glove.6B.100d.txt')

# Load data
df = pd.DataFrame([{'article_id': 1, 'article_text': 'Your text here...'}])

# Run summarization
scored_sentences = summarizer.run_summarization(df)

# Get summary for article ID 1
article_text, summary = summarizer.summarize_article(scored_sentences, 1, df)
print(summary)

Data Format

Input data should be in CSV format with columns:

  • article_id: Unique identifier for each document
  • article_text: The full text of the document

Example:

article_id,article_text
1,"This is the first article. It contains multiple sentences..."
2,"This is the second article. It also has several sentences..."

Algorithm

The summarization process follows these steps:

  1. Sentence Tokenization: Split documents into individual sentences
  2. Text Cleaning: Remove punctuation, convert to lowercase, remove stopwords
  3. Sentence Vectorization: Convert sentences to vectors using GloVe embeddings
  4. Similarity Calculation: Compute cosine similarity between all sentence pairs
  5. PageRank Scoring: Apply PageRank algorithm to identify important sentences
  6. Summary Extraction: Select top-ranked sentences in original order

Configuration

  • glove_path: Path to GloVe embeddings file (default: 'glove.6B.100d.txt/glove.6B.100d.txt')
  • num_sentences: Number of sentences in summary (default: 5)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Citation

If you use this tool in your research, please cite:

@software{text_summarizer,
  title = {Text Summarizer},
  author = {Your Name},
  url = {https://github.com/AWeebTaku/Summarizer},
  year = {2024}
}

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

text_summarizer_aweebtaku-1.0.2.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

text_summarizer_aweebtaku-1.0.2-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file text_summarizer_aweebtaku-1.0.2.tar.gz.

File metadata

File hashes

Hashes for text_summarizer_aweebtaku-1.0.2.tar.gz
Algorithm Hash digest
SHA256 36064b4d88a617acc20a05c8c1e5e25d8195756b98091d6620234c1bf3c912a5
MD5 2f58aa16047fc99ab998de7a397e156b
BLAKE2b-256 f062f500cab4a78a044fa1200b767a2a6d761c9f756e7afb644a5ad38bfa76e3

See more details on using hashes here.

File details

Details for the file text_summarizer_aweebtaku-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for text_summarizer_aweebtaku-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 85a190001bcd0c196f570370f3f2172bb8ab73757a709c82fb72c1fe2e42e0c3
MD5 97cf7b67befaa1c5f8569366d412b75a
BLAKE2b-256 25702e38f59989d592638b3fd86dd02750a3e1c0325bfb9b5ad4f06471498180

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