Spaces:
Sleeping
Sleeping
DishaKushwah
commited on
Commit
·
d03b12b
1
Parent(s):
8c8de65
Update truefalse_quiz.py
Browse files- truefalse_quiz.py +13 -6
truefalse_quiz.py
CHANGED
@@ -15,7 +15,6 @@ class generate_true_false:
|
|
15 |
sentences = sent_tokenize(context)
|
16 |
return sentences
|
17 |
|
18 |
-
# Difficulty-based sentence modifier
|
19 |
def apply_noise(self, sentence: str, level: str) -> str:
|
20 |
if level == "easy":
|
21 |
return sentence
|
@@ -52,11 +51,8 @@ class generate_true_false:
|
|
52 |
print("Please enter 'true' or 'false'.")
|
53 |
|
54 |
# Main quiz logic
|
55 |
-
def run_quiz(self):
|
56 |
try:
|
57 |
-
context = input(">> Enter context text: ")
|
58 |
-
num_questions = int(input("\n>> How many questions do you want to generate? "))
|
59 |
-
difficulty = input("\n>> Enter difficulty level (easy/medium/hard): ").strip().lower()
|
60 |
sentences = self.validate_inputs(context, num_questions, difficulty)
|
61 |
questions = self.generate_statements(context, num_questions, difficulty, sentences)
|
62 |
|
@@ -89,8 +85,19 @@ class generate_true_false:
|
|
89 |
print(f"Error: {e}")
|
90 |
|
91 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
quiz_generator = generate_true_false()
|
93 |
-
quiz_generator.run_quiz()
|
94 |
|
95 |
if __name__ == "__main__":
|
96 |
main()
|
|
|
15 |
sentences = sent_tokenize(context)
|
16 |
return sentences
|
17 |
|
|
|
18 |
def apply_noise(self, sentence: str, level: str) -> str:
|
19 |
if level == "easy":
|
20 |
return sentence
|
|
|
51 |
print("Please enter 'true' or 'false'.")
|
52 |
|
53 |
# Main quiz logic
|
54 |
+
def run_quiz(self, context, num_questions, difficulty):
|
55 |
try:
|
|
|
|
|
|
|
56 |
sentences = self.validate_inputs(context, num_questions, difficulty)
|
57 |
questions = self.generate_statements(context, num_questions, difficulty, sentences)
|
58 |
|
|
|
85 |
print(f"Error: {e}")
|
86 |
|
87 |
def main():
|
88 |
+
context = input(">> Enter context text: ").strip()
|
89 |
+
try:
|
90 |
+
num_questions = int(input(">> How many questions do you want to generate? ").strip())
|
91 |
+
except ValueError:
|
92 |
+
print("Please enter a valid integer for number of questions.")
|
93 |
+
return
|
94 |
+
|
95 |
+
difficulty = input(">> Enter difficulty level (easy / medium / hard): ").strip().lower()
|
96 |
+
if difficulty not in ["easy", "medium", "hard"]:
|
97 |
+
print("Invalid difficulty level.")
|
98 |
+
return
|
99 |
quiz_generator = generate_true_false()
|
100 |
+
quiz_generator.run_quiz(context, num_questions, difficulty)
|
101 |
|
102 |
if __name__ == "__main__":
|
103 |
main()
|