fathima-ai01/contract-simplifier
0
title: Contract Language Simplifier emoji: ๐ colorFrom: blue colorTo: green sdk: docker pinned: false license: mit short_description: AI tool that simplifies legal contract language ---
Contract Language Simplifier
AI-powered tool that transforms complex legal documents into plain, easy-to-understand English.
๐ Milestone 4 Completed โ Multi-level Simplification, Key Term Highlighting & Admin Dashboard
Date: March 7, 2026
๐ ๏ธ Tech Stack
โจ Features โ All Milestones
๐ต Milestone 1 โ User Authentication
- โ Registration โ Secure signup with name, email, phone & password validation
- โ Login / Logout โ bcrypt password hashing, secure session management
- โ Dashboard โ View and manage all uploaded documents
๐ต Milestone 2 โ NLP & Readability Analysis
- โ Text Preprocessing โ Cleaning, sentence segmentation (SpaCy), tokenization (NLTK)
- โ Readability Scores โ Flesch-Kincaid Grade Level & Gunning Fog Index
- โ Word Complexity Heatmap โ Visual difficulty map directly on the text:
- ๐ด Complex (3+ syllables)
- ๐ก Medium (7+ chars)
- ๐ข Simple vocabulary
๐ต Milestone 3 โ AI Model Integration (FLAN-T5)
- โ Text Simplification โ FLAN-T5 model rewrites legal text in plain English
- โ Adjustable Level โ Interactive slider (1โ100) dynamically maps to model prompt intensity
- โ Hybrid Summarization โ AI summary with NLTK extractive fallback
- โ Readability Bar Chart โ Live JS bar chart showing grade drop after simplification
- โ
Document Upload โ Supports
.txtfile uploads up to 50 MB
๐ข Milestone 4 โ NEW: Advanced Features
1. Multi-level Simplification Mode
- โ Three distinct modes selectable via large card buttons:
- ๐ Basic โ Minimal changes, preserves legal structure
- ๐ Intermediate โ Balanced (default) โ replaces jargon with everyday language
- ๐ Advanced โ Maximum simplification, suitable for anyone
- โ
The selected mode is sent to the backend API (
simplification_modefield) - โ A mode badge appears on the simplified text card after processing
- โ Processing metrics displayed: time, grade reduction, original/simplified word count
2. Key Term Highlighting & Legal Glossary
- โ 80+ legal terms detected automatically in uploaded documents
- โ Detected terms are highlighted in amber in the Original Text pane
- โ Hover tooltips show plain-English definitions instantly
- โ Searchable Legal Terms Glossary panel โ collapsible, with live search filter
- โ Custom glossary terms (added by admin) are merged into results
- โ
API endpoint:
POST /api/highlight_terms
3. Admin Dashboard (/admin)
- โ Sidebar navigation with 4 tabs: | Tab | What it shows | |---|---| | ๐ Overview | Stat cards (total requests, avg time, avg grade reduction, docs, users) + mode breakdown bar chart + 7-day daily activity chart | | ๐ Requests | Paginated table of every simplification log (date, document, mode, level, grades, time) | | ๐ Document Review | All documents across all users โ click any row to open inline correction editor, save corrected simplified text | | ๐ Glossary Management | Add / delete custom legal term definitions that merge into highlighting results |
- โ All simplification requests are automatically logged to MongoDB
- โ Admin access: first registered user automatically becomes admin
- โ
One-time setup endpoint
POST /api/setup-adminfor existing users
๐ Project Structure
contract-language-simplifier/
โโโ app.py # Main Flask app โ all routes & logic
โโโ models.py # MongoDB models:
โ # User, Document, SimplificationLog, GlossaryTerm
โโโ requirements.txt # All Python dependencies
โโโ .env # Environment config (not in repo)
โ
โโโ nlp/
โ โโโ model.py # FLAN-T5 simplification & summarization
โ โโโ legal_terms.py # 80+ term glossary, highlighting & tooltip HTML โ NEW
โ โโโ readability.py # Flesch-Kincaid & Gunning Fog scoring
โ โโโ preprocessing.py # SpaCy/NLTK text cleaning pipeline
โ โโโ chunking.py # Large document chunking for FLAN-T5
โ
โโโ templates/
โ โโโ view_document.html # Document viewer โ mode cards, highlighted text,
โ โ # glossary panel, metrics, bar chart โ REDESIGNED
โ โโโ admin.html # Admin dashboard with 4 tabs โ NEW
โ โโโ dashboard.html # User dashboard
โ โโโ login.html # Login page
โ โโโ register.html # Registration page
โ
โโโ static/
โโโ css/
โ โโโ style.css # Dashboard styles
โ โโโ auth.css # Login/Register styles
โโโ js/ # Frontend logic๐ Setup Instructions
Prerequisites
- Python 3.8+
- MongoDB installed and running locally (or MongoDB Atlas URI)
Step 1: Clone Repository
git clone https://github.com/Fathima-Parli/contract-language-simplifier
cd contract-language-simplifierStep 2: Create Virtual Environment
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activateStep 3: Install Dependencies
pip install -r requirements.txt
python -m spacy download en_core_web_smStep 4: Configure Environment
Create a .env file in the project root:
SECRET_KEY=your_secret_key_here
MONGODB_URI=mongodb://localhost:27017/contract_simplifierStep 5: Run Application
python app.pyOpen your browser at http://localhost:8000
๐ API Endpoints
Auth
Documents
Admin (๐ Admin only)
๐ Admin Access
The first user to register is automatically granted admin privileges.
Already registered before admin was added? Run this in the browser console while logged in:
fetch('/api/setup-admin', {method:'POST'})
.then(r=>r.json())
.then(d=>{ alert(d.message); if(d.redirect) window.location=d.redirect; })๐ธ UI Overview
๐ฆ Dependencies
flask==3.0.0
flask-cors==4.0.0
flask-session==0.6.0
pymongo==4.6.1
python-dotenv==1.0.0
bcrypt==4.1.2
email-validator==2.1.0
transformers
torch
spacy
nltk
textstat======= --- title: Contract Simplifier emoji: ๐ colorFrom: red colorTo: gray sdk: docker pinned: false license: mit short_description: AI tool simplify complex legal contract language using NLP ---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
