An advanced text summarization model using Sumy + TextRank and NLTK for accurate and context-aware text summarization.
👉 Anshu-x Summarizer – Try it live!
✅ Summarizes large text using TextRank (unsupervised)
✅ Handles duplicate sentences and ensures unique output
✅ Configurable summary length
✅ Lightweight Flask-based API for easy integration
HiveMind-Summarization-AI ├── 📄 .gitignore ├── 📄 app.py ├── 📄 requirements.txt ├── 📄 startup.sh └── 📄 README.md
git clone https://github.com/Anshu-x/HiveMind-Summarization-AI.git
python -m venv venv
source venv/bin/activate # For Linux/MacOS
venv\Scripts\activate # For Windows
pip install -r requirements.txt
👉 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
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
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)
/summarize → POST request Accepts text and num_sentences Returns a JSON response with summarized output
Using startup.sh: Make the script executable:
chmod +x startup.sh Start the app:
./startup.sh
Metric Value Model Type TextRank (Unsupervised) ROUGE-1 0.78 ROUGE-2 0.65 ROUGE-L 0.75
Tool/Library Purpose Python 3.10+ Core Programming Language Flask Web Application Framework NLTK Tokenization Sumy Text Summarization
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. 👊