AI BASED QUESTION & ANSWER GENERATOR USING PYTHON, NLP, FLASK
People & Blogs
Introduction
In this project, we will explore the development of an AI-based question-and-answer generator that allows professors, teachers, and students to generate questions from a given text. The system can generate both objective and subjective questions, making it particularly useful for exam preparation and generating assessment materials.
Project Overview
The application is designed to input text, typically sourced from educational platforms such as Wikipedia. Users can paste relevant content into an input field, select the type of questions they desire (objective or subjective), and specify the number of questions to be generated.
Key Features
- Input Text: Users provide the text from which questions will be generated.
- Question Types: The application can generate two types of questions—objective and subjective.
- Number of Questions: Users can specify how many questions they want to be generated (e.g., three).
- PDF and CSV Output: Generated questions can be converted and saved in various formats, including PDF and CSV, making it easier for teachers to print and manage their assessment materials.
- Search Functionality: Users can search through generated questions, enhancing usability.
- Pagination Support: For larger sets of questions, pagination is handled automatically.
Generating Questions
When the user inputs text and specifies the question type and number, the application processes the data to generate the questions. For instance, generating three subjective questions from a text about Python might yield queries like "What is Python?" and "Explain the significance of Python in programming."
The algorithm's accuracy can yield varying results. Generally, the system has a reliability of 70% for subjective questions and 80-90% for objective questions, where multiple-choice questions (MCQs) can be formulated effectively from the input text.
Technical Implementation
The system employs Python for its backend, utilizing the Flask web framework for the server-side logic. The Natural Language Toolkit (NLTK) is used for processing text, enabling the application to break down paragraphs into sentences and then into individual words.
Libraries Required
- Flask: A web framework essential for creating web applications.
- NLTK: A library used for natural language processing tasks.
- NumPy: A library for numerical computations, primarily utilized here for calculating cosine similarity between vectors.
Code Structure
- Front-End: An HTML page captures user input for text, questioned type, and number of questions.
- Back-End: Logic that processes the input, generates questions, and handles errors if inappropriate inputs are provided (e.g., mathematical text).
- Output Handling: A mechanism for saving the output in various formats, and a search implementation using Javascript to facilitate easy data access.
Challenges and Limitations
One of the main challenges arises when users submit mathematical texts or code snippets, which the model cannot process effectively. Furthermore, if the provided text is too brief, the application may generate poor-quality questions. Users need to input a well-structured paragraph to ensure meaningful questions.
Conclusion
The AI-based Question and Answer Generator is not only a tool for students to generate study materials but also a valuable resource for educators in constructing their exams. The system's adaptability to create different types of questions from varied text inputs highlights its potential in educational settings.
Keywords
- AI
- Question Generation
- Python
- NLP
- Flask
- Educational Technology
- Objective Questions
- Subjective Questions
- PDF Output
- CSV Output
FAQ
Q1: What types of questions can be generated?
A1: The application can generate both objective and subjective questions based on the input text.
Q2: Can I save generated questions?
A2: Yes, the application allows you to save generated questions in formats such as PDF and CSV.
Q3: How accurate are the generated questions?
A3: The system generally achieves 70% accuracy for subjective questions and 80-90% accuracy for objective questions.
Q4: What libraries do I need to run this application?
A4: You will need Flask, NLTK, and NumPy libraries installed in your Python environment.
Q5: Does the system work with code snippets?
A5: No, the system does not effectively process mathematical texts or code snippets, providing poor results if such inputs are used.