Spaces:
Runtime error
Runtime error
Commit
·
8bda403
1
Parent(s):
2f3594f
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import spacy
|
|
7 |
import language_tool_python
|
8 |
import streamlit as st
|
9 |
from gradio_client import Client
|
10 |
-
|
11 |
# Initialize LanguageTool
|
12 |
tool = language_tool_python.LanguageToolPublicAPI('en-US')
|
13 |
|
@@ -97,8 +96,8 @@ question_list = subjective_generator.generate_test("")
|
|
97 |
questions = []
|
98 |
Quiz = st.form("Quiz")
|
99 |
for i, question in enumerate(question_list):
|
100 |
-
|
101 |
-
|
102 |
|
103 |
scores = []
|
104 |
client = Client("https://billbojangeles2000-zephyr-7b-alpha-chatbot-karki.hf.space/")
|
@@ -110,15 +109,12 @@ for i in questions:
|
|
110 |
submit_button = Quiz.form_submit_button("Submit")
|
111 |
|
112 |
def calculate_average(numbers):
|
113 |
-
|
114 |
-
if numbers == []:
|
115 |
-
return "has not been calculated. Please finish the quiz to get your score."
|
116 |
numbers = [int(x) for x in numbers if isinstance(x, (int, str))]
|
117 |
|
118 |
|
119 |
total = sum(numbers)
|
120 |
average = total / len(numbers)
|
121 |
-
return
|
122 |
|
123 |
if submit_button:
|
124 |
for i, q in enumerate(questions): # This line was missing the enumeration
|
@@ -148,5 +144,5 @@ if submit_button:
|
|
148 |
x = x + 1
|
149 |
else:
|
150 |
x = x + 1
|
151 |
-
|
152 |
-
st.subheader(f'Your average score for
|
|
|
7 |
import language_tool_python
|
8 |
import streamlit as st
|
9 |
from gradio_client import Client
|
|
|
10 |
# Initialize LanguageTool
|
11 |
tool = language_tool_python.LanguageToolPublicAPI('en-US')
|
12 |
|
|
|
96 |
questions = []
|
97 |
Quiz = st.form("Quiz")
|
98 |
for i, question in enumerate(question_list):
|
99 |
+
if "Explain" not in question and len(tool.check(question)) == 0 and grammar_sense(question) == "Make Sense":
|
100 |
+
questions.append(f"{question}")
|
101 |
|
102 |
scores = []
|
103 |
client = Client("https://billbojangeles2000-zephyr-7b-alpha-chatbot-karki.hf.space/")
|
|
|
109 |
submit_button = Quiz.form_submit_button("Submit")
|
110 |
|
111 |
def calculate_average(numbers):
|
|
|
|
|
|
|
112 |
numbers = [int(x) for x in numbers if isinstance(x, (int, str))]
|
113 |
|
114 |
|
115 |
total = sum(numbers)
|
116 |
average = total / len(numbers)
|
117 |
+
return average
|
118 |
|
119 |
if submit_button:
|
120 |
for i, q in enumerate(questions): # This line was missing the enumeration
|
|
|
144 |
x = x + 1
|
145 |
else:
|
146 |
x = x + 1
|
147 |
+
|
148 |
+
st.subheader(f'Your average score for the answers is {calculate_average(scores)}')
|