Skip to content
sakship2005Public

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

πŸ“š NCERT NLP Learning Platform

A full-stack AI-powered learning platform for NCERT textbooks, built as a mini project for NLP evaluation. Upload any NCERT PDF (English or Hindi), and the platform automatically extracts chapters, runs a complete NLP pipeline, and powers an interactive learning dashboard.


🧠 Project Overview

This platform combines classical NLP techniques with modern language models to create an end-to-end educational tool for Indian school students. The backend processes NCERT PDFs through a multi-stage NLP pipeline and exposes a REST API consumed by a React dashboard.


✨ Features

Feature Description NLP Technique
πŸ“€ PDF Upload Upload full textbooks or chapter-wise PDFs PyMuPDF + Tesseract OCR
πŸ“ Hybrid Summarizer Chapter summaries in English, Hindi, Marathi MBart-50 + Extractive NLP
πŸ“š Difficult Words Vocabulary detection with definitions & translations NLTK POS tagging + WordNet
☁️ Word Cloud Concept-weighted visual map of chapter themes TF-IDF + Noun phrase extraction
πŸ”¬ Chapter NLP Analysis Named entities, topics, and key concepts spaCy NER + LDA Topic Modeling
🎯 Quiz Generator MCQ, True/False, Fill-in-blanks, Multi-select NLP pipeline + Gemini 2.5 Flash
πŸ“Ί Recommendations Educational video links matched to chapter concepts Concept extraction + YouTube API
πŸ’¬ RAG Chat Ask questions grounded in NCERT chapter text FAISS + RoBERTa QA model
πŸ” Semantic Search Find relevant passages across chapters Sentence Transformers + FAISS

πŸ—οΈ System Architecture

NCERT PDF
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Document Processing           β”‚
β”‚  PyMuPDF extraction β†’ OCR fallback      β”‚
β”‚  Chapter detection β†’ Text cleaning      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           NLP Pipeline                  β”‚
β”‚  Language detection (Devanagari ratio)  β”‚
β”‚  Tokenization β†’ Sentence segmentation   β”‚
β”‚  TF-IDF keywords β†’ spaCy NER           β”‚
β”‚  LDA topic modeling β†’ Concept extract   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Vector Store (FAISS)          β”‚
β”‚  Sentence-BERT embeddings               β”‚
β”‚  Cosine similarity search               β”‚
β”‚  Overlapping chunk retrieval            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           FastAPI REST Backend          β”‚
β”‚  SQLite + SQLAlchemy async ORM          β”‚
β”‚  Async endpoints with uvicorn           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           React Frontend                β”‚
β”‚  Vite + React 18 dashboard              β”‚
β”‚  11-section learning interface          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”¬ NLP Techniques Used

Text Preprocessing

  • Unicode normalization and PDF artifact removal
  • Language detection via Devanagari character ratio analysis
  • Sentence segmentation using NLTK sent_tokenize
  • Word tokenization with NLTK and spaCy

Keyword & Concept Extraction

  • TF-IDF (scikit-learn TfidfVectorizer) for high-importance term extraction
  • Noun phrase chunking using spaCy dependency parsing
  • Named Entity Recognition with spaCy en_core_web_sm model
  • LDA Topic Modeling (sklearn LatentDirichletAllocation) for thematic clustering

Summarization

  • Extractive summarization for English: sentence ranking by TF-IDF keyword density
  • Abstractive summarization for Hindi: fine-tuned MBart-50 multilingual model
  • Language-aware routing: detects source language and selects appropriate pipeline

Semantic Search & RAG

  • Sentence embeddings: all-MiniLM-L6-v2 via sentence-transformers
  • Vector indexing: FAISS IndexFlatIP (inner product = cosine similarity on normalized vectors)
  • Overlapping chunking: 5-sentence chunks with 1-sentence overlap for context continuity
  • Extractive QA: deepset/roberta-base-squad2 for answer span extraction

Quiz Generation

  • NLP pipeline extracts key concepts, entities, and important sentences
  • Gemini 2.5 Flash formats these into structured exam questions
  • JSON validation and sanitization ensures well-formed question objects

Vocabulary Detection

  • POS tagging with NLTK averaged perceptron tagger
  • Syllable complexity scoring for difficulty ranking
  • WordNet synset lookup for definitions, synonyms, and examples
  • Translation enrichment: Hindi and Marathi meanings via Groq

πŸ› οΈ Tech Stack

Backend

Layer Technology
Framework FastAPI 0.111 + Uvicorn
Database SQLite + SQLAlchemy 2.0 (async)
PDF Processing PyMuPDF, pdfplumber
OCR Tesseract + pytesseract
Core NLP NLTK 3.8, spaCy 3.8
ML / Embeddings scikit-learn, sentence-transformers
Vector Search FAISS CPU
Transformers HuggingFace Transformers, PyTorch
Summarization MBart-50 (fine-tuned Hindi)
QA Model deepset/roberta-base-squad2
Quiz Generation Gemini 2.5 Flash (google-genai)
Vocabulary AI Groq (Hindi meanings)

Frontend

Layer Technology
Framework React 18 + Vite
Routing React Router v6
Charts Recharts
Animations Framer Motion
API Client Fetch API (custom client)

πŸ“ Project Structure

ncert/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                        # FastAPI app entry point
β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”œβ”€β”€ .env                           # API keys
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ database.py                # SQLAlchemy async engine
β”‚   β”‚   └── models.py                  # Book, Chapter ORM models
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ books.py                   # Book CRUD endpoints
β”‚   β”‚   β”œβ”€β”€ upload.py                  # PDF upload endpoints
β”‚   β”‚   β”œβ”€β”€ nlp.py                     # All NLP feature endpoints
β”‚   β”‚   └── search.py                  # Semantic search endpoint
β”‚   └── nlp_engine/
β”‚       β”œβ”€β”€ pipeline.py                # Text analysis pipeline
β”‚       β”œβ”€β”€ preprocessing/
β”‚       β”‚   β”œβ”€β”€ cleaner.py             # Text cleaning
β”‚       β”‚   β”œβ”€β”€ tokenizer.py           # Sentence/word tokenization
β”‚       β”‚   └── language.py            # Language detection
β”‚       β”œβ”€β”€ document/
β”‚       β”‚   β”œβ”€β”€ processor.py           # PDF processing orchestrator
β”‚       β”‚   β”œβ”€β”€ pdf_extractor.py       # PyMuPDF text extraction
β”‚       β”‚   β”œβ”€β”€ ocr.py                 # Tesseract OCR fallback
β”‚       β”‚   β”œβ”€β”€ chapter_detector.py    # Chapter boundary detection
β”‚       β”‚   └── database_saver.py      # Persist processed chapters
β”‚       β”œβ”€β”€ analysis/
β”‚       β”‚   β”œβ”€β”€ keywords.py            # TF-IDF keyword extraction
β”‚       β”‚   β”œβ”€β”€ concepts.py            # Noun phrase / concept mining
β”‚       β”‚   β”œβ”€β”€ entities.py            # spaCy NER
β”‚       β”‚   β”œβ”€β”€ topics.py              # LDA topic modeling
β”‚       β”‚   β”œβ”€β”€ vocabulary.py          # Difficult word detection
β”‚       β”‚   β”œβ”€β”€ summarizer.py          # Extractive summarization
β”‚       β”‚   β”œβ”€β”€ recommendations.py     # Video recommendations
β”‚       β”‚   β”œβ”€β”€ similarity.py          # TF-IDF + semantic similarity
β”‚       β”‚   └── wordcloud_generator.py # Word cloud generation
β”‚       β”œβ”€β”€ generation/
β”‚       β”‚   β”œβ”€β”€ hindi_summarizer.py    # MBart-50 Hindi summarizer
β”‚       β”‚   β”œβ”€β”€ summarizer.py          # Summarizer module router
β”‚       β”‚   β”œβ”€β”€ quiz_generator.py      # Gemini quiz generation
β”‚       β”‚   β”œβ”€β”€ question_generator.py  # T5 question generation
β”‚       β”‚   └── answer_generator.py    # RoBERTa QA + translation
β”‚       └── retrieval/
β”‚           β”œβ”€β”€ embeddings.py          # Sentence-BERT embeddings
β”‚           β”œβ”€β”€ chunking.py            # Overlapping text chunking
β”‚           β”œβ”€β”€ vector_store.py        # FAISS vector index
β”‚           └── chapter_retriever.py   # Build chapter FAISS store
└── frontend/
    └── src/
        β”œβ”€β”€ api/
        β”‚   └── Client.js              # API client
        └── components/
            └── ncert/
                β”œβ”€β”€ NcertDashboard.jsx
                β”œβ”€β”€ Sidebar.jsx
                β”œβ”€β”€ UploadSection.jsx
                β”œβ”€β”€ OverviewSection.jsx
                β”œβ”€β”€ SummarySection.jsx
                β”œβ”€β”€ DifficultWordsSection.jsx
                β”œβ”€β”€ KeywordsSection.jsx
                β”œβ”€β”€ ChapterAnalysisSection.jsx
                β”œβ”€β”€ QuizSection.jsx
                β”œβ”€β”€ RecommendationsSection.jsx
                β”œβ”€β”€ ChatSection.jsx
                β”œβ”€β”€ SemanticSearchSection.jsx
                └── ChaptersSection.jsx

πŸš€ Setup & Installation

Prerequisites

Backend Setup

# 1. Clone the repository
git clone https://github.com/sakship2005/ncert.git
cd ncert/backend

# 2. Create virtual environment
python -m venv venv
venv\Scripts\activate        # Windows
# source venv/bin/activate   # macOS/Linux

# 3. Install dependencies
pip install -r requirements.txt
pip install pytesseract pillow google-genai

# 4. Download NLP models
python -m spacy download en_core_web_sm
python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('wordnet'); nltk.download('averaged_perceptron_tagger')"

# 5. Create .env file

Create backend/.env:

GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama-3.3-70b-versatile
# 6. Run the backend
uvicorn main:app --reload --port 8000

Backend runs at http://localhost:8000 Swagger docs at http://localhost:8000/docs

Frontend Setup

cd ../frontend

# Install dependencies
npm install

# Run development server
npm run dev

Frontend runs at http://localhost:5173


πŸ“‘ API Endpoints

Method Endpoint Description
GET /books List all uploaded textbooks
POST /books/create Create a book entry
POST /books/upload/full Upload a full textbook PDF
POST /books/upload/chapter Upload a single chapter PDF
GET /books/{book_id}/chapters List chapters for a book
POST /nlp/summarize Generate chapter summary
POST /nlp/difficult-words Extract vocabulary
POST /nlp/chapter-analysis NER + topics + concepts
POST /nlp/generate-quiz Generate interactive quiz
POST /nlp/recommendations Educational resource recommendations
POST /nlp/ask RAG question answering
POST /search Semantic search across chunks

πŸ”‘ Environment Variables

Variable Required Description
GEMINI_API_KEY βœ… Yes Google AI Studio key for quiz generation
GROQ_API_KEY ⚠️ Optional Groq key for Hindi vocabulary meanings
GROQ_MODEL ⚠️ Optional Groq model name (default: llama-3.3-70b-versatile)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages