Spaces:
Runtime error
Runtime error
Commit
·
68fa6b1
1
Parent(s):
104329a
Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ paragraphs = [f"{sentences[i]} {sentences[i + 1]}" if i + 1 < len(sentences) els
|
|
42 |
|
43 |
class SubjectiveTest:
|
44 |
|
45 |
-
def
|
46 |
self.summary = data
|
47 |
self.noOfQues = noOfQues
|
48 |
self.nlp = spacy.load("en_core_web_sm")
|
@@ -109,25 +109,24 @@ for i in questions:
|
|
109 |
Quiz.form_submit_button("Submit")
|
110 |
grade_quiz = st.button("Grade Quiz!")
|
111 |
if grade_quiz:
|
112 |
-
for i in
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
scores.append(f'N/A')
|
131 |
|
132 |
x = 0
|
133 |
new_scores = []
|
@@ -138,13 +137,13 @@ if grade_quiz:
|
|
138 |
x = x + 1
|
139 |
else:
|
140 |
x = x + 1
|
141 |
-
|
142 |
def calculate_average(numbers):
|
143 |
if not numbers:
|
144 |
return 0 # Return 0 for an empty list to avoid division by zero.
|
145 |
-
|
146 |
total = sum(numbers)
|
147 |
average = total / len(numbers)
|
148 |
return average
|
149 |
-
|
150 |
-
st.subheader(f'Your average score for the answers is {calculate_average(scores)}')
|
|
|
42 |
|
43 |
class SubjectiveTest:
|
44 |
|
45 |
+
def __init(self, data, noOfQues):
|
46 |
self.summary = data
|
47 |
self.noOfQues = noOfQues
|
48 |
self.nlp = spacy.load("en_core_web_sm")
|
|
|
109 |
Quiz.form_submit_button("Submit")
|
110 |
grade_quiz = st.button("Grade Quiz!")
|
111 |
if grade_quiz:
|
112 |
+
for i, q in enumerate(questions): # This line was missing the enumeration
|
113 |
+
result = client.predict(
|
114 |
+
f'What would you rate this answer to the question: "{q}" as a percentage? Here is the answer: {ans[i]}. Make sure to write your answer as "Score" and then write your score of the response.',
|
115 |
+
0.9,
|
116 |
+
256,
|
117 |
+
0.9,
|
118 |
+
1.2,
|
119 |
+
api_name="/chat"
|
120 |
+
)
|
121 |
+
print(result)
|
122 |
+
pattern = r'(\d+)%'
|
123 |
+
|
124 |
+
match = re.search(pattern, result)
|
125 |
+
if match:
|
126 |
+
score = match.group(1)
|
127 |
+
scores.append(f'{int(score)}')
|
128 |
+
else:
|
129 |
+
scores.append(f'N/A')
|
|
|
130 |
|
131 |
x = 0
|
132 |
new_scores = []
|
|
|
137 |
x = x + 1
|
138 |
else:
|
139 |
x = x + 1
|
140 |
+
|
141 |
def calculate_average(numbers):
|
142 |
if not numbers:
|
143 |
return 0 # Return 0 for an empty list to avoid division by zero.
|
144 |
+
|
145 |
total = sum(numbers)
|
146 |
average = total / len(numbers)
|
147 |
return average
|
148 |
+
|
149 |
+
st.subheader(f'Your average score for the answers is {calculate_average(scores)}')
|