Skip to content

Mugambi645/text-summarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

text-summarizer

Overview

The Text Summarizer project is a Django-based web application that leverages AI to generate concise summaries of long texts. It uses the Facebook BART model for high-quality text summarization, ensuring that key information is preserved while reducing the overall length of the input text.

Features

  • Web Interface: A user-friendly interface to input text and view summaries.
  • AI-Powered Summarization: Utilizes the transformers library and the BART model for accurate and efficient text summarization.
  • API Support: Provides an API endpoint for programmatic access to the summarization functionality.
  • Customizable Model: Includes a pre-trained model that can be fine-tuned or replaced with other summarization models.

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd text-summarizer
  2. Set up a virtual environment:

    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Apply migrations:

    python manage.py migrate
  5. Start the development server:

    python manage.py runserver
  6. Access the application at http://127.0.0.1:8000/.

Usage

Web Interface

  1. Navigate to the home page.
  2. Paste your text into the input box.
  3. Click "Generate Summary" to view the summarized text.

API

  • Endpoint: /api/summarize/
  • Method: POST
  • Payload: { "text": "Your text here" }
  • Response: { "summary": "Summarized text" }

Example usage

  • Using Curl
curl -X POST "http://localhost:8000/api/v1/summarize/" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Your long text here...",
    "max_length": 150,
    "min_length": 40
  }'
  • Using javascript(fetch Api)
const summarizeText = async (text) => {
  const response = await fetch('/api/v1/summarize/', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      text: text,
      max_length: 150,
      min_length: 40
    })
  });
  
  return await response.json();
};

// Usage
summarizeText("Your long article text...")
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
  • Using Python requests library
import requests

api_url = "http://localhost:8000/api/v1/summarize/"
data = {
    "text": "Your long text here...",
    "max_length": 150,
    "min_length": 40
}

response = requests.post(api_url, json=data)
print(response.json())
  • Check Api status
curl http://localhost:8000/api/v1/status/

Project Structure

  • summarizer/: Contains Django project settings and configurations.
  • text/: Main app for text summarization, including views, templates, and services.
  • my_summarizer_model/: Directory for the pre-trained summarization model.
  • templates/: HTML templates for the web interface.

Model Details

The project uses the facebook/bart-large-cnn model from Hugging Face's Transformers library. The model is downloaded and saved locally for efficient reuse.

License

This project is licensed under the MIT License.

About

Text summarization using BART model

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors