BillBojangeles2000 commited on
Commit
bf2f32a
·
1 Parent(s): 9c331cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -13
app.py CHANGED
@@ -7,6 +7,7 @@ import spacy
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,8 +97,8 @@ question_list = subjective_generator.generate_test("")
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/")
@@ -108,14 +109,6 @@ for i in questions:
108
 
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
121
  result = client.predict(
@@ -133,7 +126,6 @@ if submit_button:
133
  if match:
134
  score = match.group(1)
135
  scores.append(f'{int(score)}')
136
- st.write(f'{int(score)}')
137
  else:
138
  scores.append(f'N/A')
139
 
@@ -145,5 +137,5 @@ if submit_button:
145
  x = x + 1
146
  else:
147
  x = x + 1
148
-
149
- st.subheader(f'Your average score for the answers is {calculate_average(scores)}')
 
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
  questions = []
98
  Quiz = st.form("Quiz")
99
  for i, question in enumerate(question_list):
100
+ if "Explain" not in question and len(tool.check(question)) == 0 and grammar_sense(question) == "Make Sense":
101
+ questions.append(f"{question}")
102
 
103
  scores = []
104
  client = Client("https://billbojangeles2000-zephyr-7b-alpha-chatbot-karki.hf.space/")
 
109
 
110
  submit_button = Quiz.form_submit_button("Submit")
111
 
 
 
 
 
 
 
 
 
112
  if submit_button:
113
  for i, q in enumerate(questions): # This line was missing the enumeration
114
  result = client.predict(
 
126
  if match:
127
  score = match.group(1)
128
  scores.append(f'{int(score)}')
 
129
  else:
130
  scores.append(f'N/A')
131
 
 
137
  x = x + 1
138
  else:
139
  x = x + 1
140
+
141
+ st.subheader(f'Your average score for the answers is {calculate_average(scores)}')