Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


β—ˆ SummarAI

AI-Powered Text Summarization Tool

Paste any article. Get a sharp, accurate summary in seconds.
Powered by state-of-the-art NLP β€” completely free, runs locally.


Python Flask HuggingFace PyTorch License Status


🌐 Live Demo β†’ Β Β |Β Β  πŸ“– API Docs Β Β |Β Β  πŸ› Report a Bug



πŸ“Œ Table of Contents


πŸ“– About the Project

SummarAI is a full-stack web application that uses Natural Language Processing (NLP) to automatically summarize long-form text β€” articles, research papers, blog posts, news β€” into concise, readable summaries.

The project implements two distinct summarization approaches:

  • Abstractive β€” uses the facebook/bart-large-cnn transformer model (fine-tuned on 300,000+ CNN/DailyMail articles) to understand the text and write a fresh summary in its own words, just like a human would.
  • Extractive β€” uses a custom-built TF-IDF scoring algorithm to identify and return the most statistically important sentences from the original text.

This was built as a beginner-to-intermediate learning project to understand NLP pipelines, REST API design, and full-stack web development β€” from model inference all the way to a production-ready interface.


✨ Features

Feature Description
🧠 Abstractive Summarization facebook/bart-large-cnn rewrites text in its own words β€” natural, human-sounding output
βœ‚οΈ Extractive Summarization Custom TF-IDF engine selects the most important original sentences
πŸ“ 3 Summary Lengths Short, Medium, Long β€” control exactly how detailed the output is
πŸ“Š Live Statistics Compression ratio, word counts, and method used β€” shown after every summary
πŸ“‹ One-Click Copy Copy the generated summary to clipboard instantly
🎯 Built-in Sample Article Demo article included β€” works immediately with no setup
🌐 Clean REST API JSON API with 3 endpoints β€” can be integrated into any app
πŸ’― 100% Free & Local No paid APIs, no subscriptions, no data sent to the cloud

🌐 Live Demo

πŸš€ The app is deployed and accessible here:

https://summari-84uc.onrender.com

⚠️ Note: The app runs on Render's free tier β€” it may take 30–60 seconds to wake up on first visit.


πŸ› οΈ Tech Stack

Layer Technology Why
Frontend HTML5, CSS3, Vanilla JavaScript Lightweight, no framework overhead
Backend Python 3.10, Flask 3.0 Simple, fast REST API server
AI Model HuggingFace Transformers + BART State-of-the-art abstractive summarization
NLP Algorithm Custom TF-IDF (no libraries) Fast extractive summarization, zero dependencies
Deployment Render Free cloud hosting for Python apps
Testing pytest Unit + integration test coverage

πŸ—‚οΈ Project Structure

Text-Summarizer-Tool/
β”‚
β”œβ”€β”€ πŸ“‚ backend/
β”‚   β”œβ”€β”€ app.py              # Flask app β€” all API routes and server config
β”‚   └── summarizer.py       # Core NLP engine (BART abstractive + TF-IDF extractive)
β”‚
β”œβ”€β”€ πŸ“‚ frontend/
β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   └── index.html      # Main UI β€” single page app
β”‚   └── static/
β”‚       β”œβ”€β”€ css/
β”‚       β”‚   └── style.css   # Dark editorial theme, fully responsive
β”‚       └── js/
β”‚           └── main.js     # UI logic, API calls, state management
β”‚
β”œβ”€β”€ πŸ“‚ tests/
β”‚   └── test_summarizer.py  # 15 unit + integration tests (pytest)
β”‚
β”œβ”€β”€ πŸ“‚ docs/
β”‚   └── API.md              # Full API endpoint reference
β”‚
β”œβ”€β”€ requirements.txt        # All Python dependencies with pinned versions
β”œβ”€β”€ .gitignore              # Excludes venv, cache, model files from Git
β”œβ”€β”€ LICENSE                 # MIT License
└── README.md               # This file

πŸš€ Getting Started

Prerequisites

  • Python 3.10 or higher β€” Download
  • pip (bundled with Python)
  • ~2GB free disk space (for the BART model cache)
  • Git β€” Download

Installation

1. Clone the repository

git clone https://github.com/TUSHARTAMRAKAR/Text-Summarizer-Tool.git
cd Text-Summarizer-Tool

2. Create a virtual environment

python -m venv venv

3. Activate the virtual environment

# Windows
venv\Scripts\activate

# macOS / Linux
source venv/bin/activate

You'll see (venv) at the start of your terminal prompt. βœ…

4. Install dependencies

pip install -r requirements.txt

⚠️ The first run will download the facebook/bart-large-cnn model (~1.6GB).
This only happens once β€” it's cached locally afterwards.

5. Start the server

cd backend
python app.py

6. Open in browser

http://localhost:5000

The app is running. πŸŽ‰


πŸ”Œ API Reference

Full documentation β†’ docs/API.md

Base URL: http://localhost:5000


POST /api/summarize

Summarize a piece of text.

Request body:

{
  "text": "Paste your article text here...",
  "length": "medium",
  "method": "abstractive"
}
Parameter Type Options Default
text string 50 – 50,000 characters required
length string short Β· medium Β· long medium
method string abstractive Β· extractive abstractive

Success response 200:

{
  "success": true,
  "summary": "Artificial intelligence is reshaping industries worldwide...",
  "original_word_count": 500,
  "summary_word_count": 82,
  "compression_ratio": "84%",
  "method_used": "abstractive"
}

Error response 400:

{
  "success": false,
  "error": "Text is too short. Please provide at least 50 characters."
}

GET /api/health

Returns server and model status.

{
  "status": "healthy",
  "model_loaded": true,
  "version": "1.0.0"
}

GET /api/sample

Returns a built-in demo article for testing.


🧠 How It Works

Abstractive Summarization (BART Transformer)

Your Text
    ↓
BART Encoder  β†’  Reads and builds deep understanding of the text
    ↓
BART Decoder  β†’  Generates a brand new summary, word by word
    ↓
Fresh Summary (written in the model's own words)

BART (Bidirectional and Auto-Regressive Transformer) was fine-tuned by Facebook AI on the CNN/DailyMail dataset β€” 300,000+ news articles with human-written summaries. It learns to compress information the same way a journalist would.


Extractive Summarization (TF-IDF)

Your Text
    ↓
Split into individual sentences
    ↓
Score each sentence using TF-IDF weights
(words rare in the document but frequent in the sentence = more important)
    ↓
Rank sentences by score
    ↓
Return top N sentences in original order

TF-IDF = Term Frequency Γ— Inverse Document Frequency. It mathematically identifies which words β€” and therefore which sentences β€” carry the most unique information in the document. No AI model needed, works fully offline, instant results.


πŸ§ͺ Running Tests

# From project root with venv active
python -m pytest tests/ -v

Expected output:

tests/test_summarizer.py::TestExtractive::test_extractive_returns_dict     PASSED
tests/test_summarizer.py::TestExtractive::test_extractive_success_flag     PASSED
tests/test_summarizer.py::TestExtractive::test_extractive_has_summary      PASSED
tests/test_summarizer.py::TestExtractive::test_extractive_method_label     PASSED
tests/test_summarizer.py::TestExtractive::test_extractive_word_counts      PASSED
tests/test_summarizer.py::TestExtractive::test_extractive_short_length     PASSED
tests/test_summarizer.py::TestWordCounting::test_compression_ratio         PASSED
tests/test_summarizer.py::TestEdgeCases::test_handles_multiline_text       PASSED
tests/test_summarizer.py::TestEdgeCases::test_all_length_options           PASSED
tests/test_summarizer.py::TestAPIEndpoints::test_health_endpoint           PASSED
tests/test_summarizer.py::TestAPIEndpoints::test_summarize_endpoint_valid  PASSED
...

15 passed in 3.42s βœ…

πŸ—ΊοΈ Roadmap

  • Abstractive summarization (BART model)
  • Extractive summarization (TF-IDF)
  • 3 summary length options
  • REST API with JSON responses
  • Beautiful responsive web UI
  • Unit + integration test coverage
  • Deployed to Render
  • PDF file upload and summarization
  • Summarize from a URL (paste a link, get a summary)
  • Export summary as .txt / .pdf
  • Multi-language support
  • Summary history (save and revisit past summaries)
  • Browser extension

🀝 Contributing

Contributions are welcome and appreciated!

  1. Fork the repository
  2. Create your feature branch
git checkout -b feature/your-feature-name
  1. Commit your changes using Conventional Commits
git commit -m "feat: add PDF upload support"
  1. Push to your branch
git push origin feature/your-feature-name
  1. Open a Pull Request and describe what you changed and why

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.

You're free to use, copy, modify, and distribute this project, as long as the original license is included.



πŸ‘€ Author

Tushar Tamrakar

GitHub


Built from scratch as a learning project β€” NLP, Flask, full-stack development, and Git workflow.



⭐ Found this useful? Give it a star β€” it helps others discover the project!


Made with ❀️ by Tushar Tamrakar


About

A full-stack NLP text summarization web app built with Python, Flask and HuggingFace

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages