From c6c48345fb7ace43c6bf138cc456e3ce663c195a Mon Sep 17 00:00:00 2001 From: Karmvir Date: Tue, 24 Dec 2024 10:29:50 +0530 Subject: [PATCH] Here completed the issue #93 --- backend/._s2v_old | Bin 0 -> 274 bytes backend/Generator/main.py | 2 +- backend/package-lock.json | 6 ++++++ backend/script.sh | 34 +++++++++++++++++++++++++++------- backend/server.py | 12 ++++++------ 5 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 backend/._s2v_old create mode 100644 backend/package-lock.json diff --git a/backend/._s2v_old b/backend/._s2v_old new file mode 100644 index 0000000000000000000000000000000000000000..79bd48257117331677569bae608e89a04214216b GIT binary patch literal 274 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDI}@dF?R@)?DIG!eitBqRu;46I`dkR6An z4P-h<+=GFEKRG{FFR`E?Csi*uF*ygK@DGp@V_*^!%1?}G5nJ7Nw&G?7Xc>KhnX7+D)YfwgyPcA_-{0Awj6kpKVy literal 0 HcmV?d00001 diff --git a/backend/Generator/main.py b/backend/Generator/main.py index 80e4802..85ddb2a 100644 --- a/backend/Generator/main.py +++ b/backend/Generator/main.py @@ -379,7 +379,7 @@ def process_file(self, file): class QuestionGenerator: """A transformer-based NLP system for generating reading comprehension-style questions from - texts. It can generate full sentence questions, multiple choice questions, or a mix of the + texts. It can generate full sentence questions, multiple choice questions , or a mix of the two styles. To filter out low quality questions, questions are assigned a score and ranked once they have diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..dfb18f1 --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "backend", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/backend/script.sh b/backend/script.sh index 9b54e95..7641d96 100755 --- a/backend/script.sh +++ b/backend/script.sh @@ -6,23 +6,43 @@ REPO_DIR="EduAid" S2V_ARCHIVE="s2v_reddit_2015_md.tar.gz" S2V_DIR="s2v_old" +# Step 1: Set up Python virtual environment if [ ! -d "venv" ]; then - python3 -m venv venv + echo "Creating virtual environment..." + python3 -m venv venv || { echo "Failed to create virtual environment"; exit 1; } fi source venv/bin/activate +# Step 2: Clone repository if it doesn't exist if [ ! -d "$REPO_DIR" ]; then - git clone $REPO_URL + echo "Cloning repository..." + git clone $REPO_URL || { echo "Failed to clone repository"; deactivate; exit 1; } +else + echo "Repository already exists. Skipping clone." fi +# Step 3: Download Sense2Vec archive if not present if [ ! -f "$S2V_ARCHIVE" ]; then - wget $S2V_URL -O $S2V_ARCHIVE + echo "Downloading Sense2Vec model..." + wget $S2V_URL -O $S2V_ARCHIVE || { echo "Failed to download Sense2Vec model"; deactivate; exit 1; } +else + echo "Sense2Vec archive already exists. Skipping download." fi +# Step 4: Extract archive to target directory if [ ! -d "$REPO_DIR/$S2V_DIR" ]; then - mkdir -p $REPO_DIR/$S2V_DIR - tar -xzvf $S2V_ARCHIVE -C $REPO_DIR/$S2V_DIR --strip-components=1 + echo "Extracting Sense2Vec archive..." + mkdir -p "$REPO_DIR/$S2V_DIR" && + tar -xzvf $S2V_ARCHIVE -C "$REPO_DIR/$S2V_DIR" --strip-components=1 || { + echo "Failed to extract Sense2Vec archive"; + deactivate; + exit 1; + } +else + echo "Sense2Vec directory already exists. Skipping extraction." fi -# Deactivate virtual environment after completion -source deactivate \ No newline at end of file +# Deactivate virtual environment +deactivate + +echo "Setup completed successfully." diff --git a/backend/server.py b/backend/server.py index f80ec24..e6dfe37 100644 --- a/backend/server.py +++ b/backend/server.py @@ -376,14 +376,14 @@ def get_shortq_hard(): @app.route("/get_mcq_hard", methods=["POST"]) def get_mcq_hard(): data = request.get_json() - input_text = data.get("input_text", "") - use_mediawiki = data.get("use_mediawiki", 0) - input_text = process_input_text(input_text,use_mediawiki) - input_questions = data.get("input_question", []) + input_text = data.get("input_text", "")#Retreiving the input text + use_mediawiki = data.get("use_mediawiki", 0)#if we want to use wikipedia or not + input_text = process_input_text(input_text,use_mediawiki) #Parsing it into a function so that it can be modifies before use + input_questions = data.get("input_question", [])# Here it specify the number of questions to be generated output = qg.generate( article=input_text, num_questions=input_questions, answer_style="multiple_choice" - ) - return jsonify({"output": output}) + ) # Output of generated question in the form of dictionary + return jsonify({"output": output}) #Here sending the output to the frontend @app.route('/upload', methods=['POST']) def upload_file():