MCQ Generator: Automate Your Quiz Creation Process
Have you ever wished you could automatically generate multiple-choice questions (MCQs) from your lecture notes, articles, or other textual content? Look no further! Introducing MCQ Generator, a Flask-based web application that leverages Natural Language Processing (NLP) and deep learning to dynamically create quiz questions. This project is perfect for educators, students, and content creators who need a quick way to transform text into interactive quizzes.
Overview
MCQ Generator is designed to process input from various sources—whether it's a URL, manual text, or even a file upload (PDF or TXT)—and generate multiple-choice questions with answer options. It even provides a downloadable PDF of the generated questions, making it easy to share or print quizzes for classroom use.
Key Features
- MCQ Generation: Automatically generates multiple-choice questions by processing input text.
- NLP & Deep Learning: Uses spaCy for NLP processing and a TensorFlow/Keras LSTM model to understand sentence structures.
- File & URL Support: Accepts input via URL, manual text entry, or file uploads (PDF/TXT).
- PDF Download: Allows users to download the generated MCQs as a PDF.
- User-Friendly Interface: Built with Flask and styled using Bootstrap for a clean, responsive design.
Technologies Used
- Flask: Backend framework for building the web application.
- BeautifulSoup & Requests: For web scraping and processing content from URLs.
- PyPDF2: For extracting text from PDF files.
- spaCy: For NLP tasks such as tokenization and sentence segmentation.
- TensorFlow & Keras: To build and run an LSTM model for understanding sentence structures.
- ReportLab: For generating PDFs of the MCQs.
- Bootstrap: For a responsive and user-friendly frontend.
Folder Structure
The project is organized as follows:
your_project_folder/
├── app.py
├── requirements.txt
├── README.md
├── static/
│ └── style.css
└── templates/
├── index.html
├── mcqs.html
└── result.html
Here’s how it works:
Text Preprocessing:
Uses spaCy to break text into sentences and extract nouns.
LSTM-Based Model:
A neural network is built using TensorFlow/Keras.
The model is trained to understand sentence structures.
MCQ Generation:
Extracts a key noun from the text and replaces it with a blank.
Uses spaCy word vectors to find similar words as distractors.
Shuffles answer choices and formats them as MCQs.
Installation
- Clone the repository:
git clone https://github.com/your-username/nlp-mcq-generator.git
cd nlp-mcq-generator
- Install dependencies:
pip install -r requirements.txt
- Download the English spaCy model:
python -m spacy download en_core_web_sm
- Run the application:
python app.py
Generating MCQs
Input Options:
- Enter a URL to scrape text, paste your own text manually, or upload a PDF/TXT file.
Select Number of Questions:
- Choose how many questions you want to generate.
Generate and View:
Click on Generate MCQs to see your questions.
-
You can also view detailed results with correct answers and download the quiz as a PDF.
Screenshot
Conclusion
MCQ Generator offers a seamless way to convert text into engaging multiple-choice questions, making it an ideal tool for educators and learners alike. With its modern Flask-based architecture and robust NLP processing, creating quizzes has never been easier!
🔗 Check out the full project on GitHub:
Happy Coding!
Top comments (0)