Git Product home page Git Product logo

stuff's Introduction

Automatic Answer Evaluator with BERT-Based Semantic Analysis

This project implements an automatic answer evaluator that leverages BERT-based semantic analysis, keyword matching, and optical character recognition (OCR) to assess the similarity between a student's answer and a model answer. The system provides an automated and objective evaluation of student responses, even when presented in image format.

Components

1. modelAnswer.py

This module provides the function get_answer_similarity(student_answer, model_answer) that calculates the cosine similarity between BERT embeddings of the student's answer and the model answer. The BERT-based RoBERTa model is employed to encode and compare text segments.

2. keywords.py

This module contains functions related to keyword matching and semantic analysis:

  • checkForKeywords(keywords, student_answer, model_answer): Computes cosine similarity between student answer and model answer after converting them into vectors using CountVectorizer.
  • semanticA(text1, text2, aspect): Performs semantic analysis on two texts combined with a given aspect using a pre-trained BERT-based model.
  • get_synonyms(word): Retrieves synonyms of a given word from the WordNet database.
  • getRelevantSentences(text, word): Extracts sentences from a text containing a given word or its synonyms.
  • compare_sentences(sentences1, sentences2, word): Compares two sets of sentences based on a given word's presence, considering synonyms, and calculates a similarity score.
  • compareTexts(text1, text2, keywords): Compares two texts using relevant sentences for each keyword and returns a total similarity score.

3. preprocess.py

This module provides functions for text preprocessing:

  • get_wordnet_pos(treebank_tag): Converts Penn Treebank POS tags to WordNet POS tags for lemmatization.
  • preprocess_keys(keywords): Preprocesses a list of keywords by converting to lowercase, stripping whitespace, performing part-of-speech tagging, and lemmatizing.
  • preprocess_text(text): Preprocesses input text by tokenizing, removing stop words and punctuation, performing part-of-speech tagging, and lemmatizing.

4. app.py

This script sets up a Flask web application for user interaction. Users can submit model answers, student answers, and keywords for evaluation. It also supports processing student answer images to extract text using OCR and then evaluates the extracted text.

5. getTextFromImage.py

A utility script that uses the Google Cloud Vision API to extract text from images. It takes an image file path, performs OCR, and returns the extracted text content.

Usage

  1. Install the required libraries using pip install transformers nltk scikit-learn google-cloud-vision flask pillow pytesseract.

  2. Configure API credentials: Replace './key.json' in gettextfromimage.py with the path to your Google Cloud Vision API JSON key file.

  3. Import the necessary functions from the modules and use them to process and evaluate student answers.

  4. Run the Flask app using python app.py, and access it through a web browser.

stuff's People

Contributors

yashsrivastava17 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.