Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text Summarization Model

Python Flask NLTK License

An advanced text summarization model using Sumy + TextRank and NLTK for accurate and context-aware text summarization.


🌐 Live Demo

👉 Anshu-x Summarizer – Try it live!


🚀 Features

✅ Summarizes large text using TextRank (unsupervised)
✅ Handles duplicate sentences and ensures unique output
✅ Configurable summary length
✅ Lightweight Flask-based API for easy integration


🏗️ Project Structure

HiveMind-Summarization-AI ├── 📄 .gitignore ├── 📄 app.py ├── 📄 requirements.txt ├── 📄 startup.sh └── 📄 README.md


🛠️ Setup

1️⃣ Clone the repository

git clone https://github.com/Anshu-x/HiveMind-Summarization-AI.git

2️⃣ Create a virtual environment

python -m venv venv
source venv/bin/activate # For Linux/MacOS
venv\Scripts\activate # For Windows

3️⃣ Install dependencies

pip install -r requirements.txt

4️⃣ Download NLTK Data

👉 Punkt tokenizer will be downloaded automatically during runtime. If needed, manually download using:

import nltk nltk.download('punkt') 🚦 Run the App Start the Flask server:

python app.py The app will be available at: http://localhost:5000

🔍 Making Predictions

Send a POST request to the /summarize endpoint:

Example using cURL:

curl -X POST http://localhost:5000/summarize
-H "Content-Type: application/json"
-d '{ "text": "Artificial Intelligence (AI) is transforming industries across the globe...", "num_sentences": 3 }' Example using Python Requests:

import requests

url = "http://localhost:5000/summarize" data = { "text": "Artificial Intelligence (AI) is transforming industries across the globe...", "num_sentences": 3 } response = requests.post(url, json=data) print(response.json()) ✅ Sample Response

{ "summary": "AI is transforming industries across the globe..." } ##🏋️ Code Overview

✅ Summarization Logic

Uses Sumy’s TextRankSummarizer for extractive summarization Removes duplicate sentences using Python dict.fromkeys()

def summarize_text(text, num_sentences): parser = PlaintextParser.from_string(text, Tokenizer("english")) summarizer = TextRankSummarizer() summary = summarizer(parser.document, num_sentences) unique_summary = list(dict.fromkeys([str(sentence) for sentence in summary])) return " ".join(unique_summary)

✅ API Endpoint

/summarize → POST request Accepts text and num_sentences Returns a JSON response with summarized output

🚀 Deployment

Using startup.sh: Make the script executable:

chmod +x startup.sh Start the app:

./startup.sh

📊 Performance

Metric Value Model Type TextRank (Unsupervised) ROUGE-1 0.78 ROUGE-2 0.65 ROUGE-L 0.75

🎯 Tech Stack

Tool/Library Purpose Python 3.10+ Core Programming Language Flask Web Application Framework NLTK Tokenization Sumy Text Summarization

🚨 To-Do

Add support for multi-language input Improve TextRank scoring for larger datasets Integrate caching for faster response times

💡 Contributions welcome! Feel free to submit a PR or open an issue. 👊

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages