Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,8 +28,6 @@ ipa_features = {
|
|
28 |
'j': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '+', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'voice': '+'},
|
29 |
'w': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'voice': '+'}
|
30 |
}
|
31 |
-
|
32 |
-
|
33 |
# Variables to keep track of progress
|
34 |
score = 0
|
35 |
attempts = 0
|
@@ -46,8 +44,9 @@ def start_quiz():
|
|
46 |
completed_symbols = set()
|
47 |
current_symbol, remaining_features = select_new_symbol()
|
48 |
current_feature = remaining_features.pop(0)
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
# Function to select a new symbol that hasn't been completed yet
|
53 |
def select_new_symbol():
|
@@ -83,16 +82,18 @@ def load_next():
|
|
83 |
global current_symbol, remaining_features, current_feature
|
84 |
if remaining_features:
|
85 |
current_feature = remaining_features.pop(0)
|
86 |
-
|
87 |
-
|
|
|
88 |
else:
|
89 |
current_symbol, remaining_features = select_new_symbol()
|
90 |
if current_symbol:
|
91 |
current_feature = remaining_features.pop(0)
|
92 |
-
|
93 |
-
|
|
|
94 |
else:
|
95 |
-
return "You've completed all symbols!", ""
|
96 |
|
97 |
# Gradio Interface
|
98 |
with gr.Blocks() as quiz_app:
|
@@ -103,10 +104,14 @@ with gr.Blocks() as quiz_app:
|
|
103 |
score_text = gr.Markdown()
|
104 |
attempts_text = gr.Markdown()
|
105 |
|
106 |
-
# Answer Buttons in a row
|
107 |
with gr.Row():
|
108 |
-
positive_button = gr.Button(
|
109 |
-
negative_button = gr.Button(
|
|
|
|
|
|
|
|
|
110 |
|
111 |
# Feedback Display below the answer buttons
|
112 |
feedback_area = gr.Markdown()
|
@@ -115,10 +120,10 @@ with gr.Blocks() as quiz_app:
|
|
115 |
next_button = gr.Button("Next Feature/Symbol")
|
116 |
|
117 |
# Set up button actions
|
118 |
-
start_button.click(start_quiz, outputs=[question_text, feedback_area, score_text, attempts_text])
|
119 |
positive_button.click(lambda: check_answer('+'), outputs=[feedback_area, score_text, attempts_text, question_text])
|
120 |
negative_button.click(lambda: check_answer('-'), outputs=[feedback_area, score_text, attempts_text, question_text])
|
121 |
-
next_button.click(load_next, outputs=[question_text, feedback_area])
|
122 |
|
123 |
# Launch the app
|
124 |
-
quiz_app.launch()
|
|
|
28 |
'j': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '+', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'voice': '+'},
|
29 |
'w': {'syllabic': '-', 'consonantal': '-', 'sonorant': '+', 'coronal': '-', 'anterior': '-', 'continuant': '+', 'nasal': '-', 'strident': '-', 'lateral': '-', 'delayed release': '-', 'voice': '+'}
|
30 |
}
|
|
|
|
|
31 |
# Variables to keep track of progress
|
32 |
score = 0
|
33 |
attempts = 0
|
|
|
44 |
completed_symbols = set()
|
45 |
current_symbol, remaining_features = select_new_symbol()
|
46 |
current_feature = remaining_features.pop(0)
|
47 |
+
question = (f"Practicing with /{current_symbol}/ sound. "
|
48 |
+
f"Does the '{current_feature}' feature of /{current_symbol}/ have a positive or negative value?")
|
49 |
+
return question, "", f"Score: {score}", f"Attempts: {attempts}", f"[+{current_feature}]", f"[-{current_feature}]"
|
50 |
|
51 |
# Function to select a new symbol that hasn't been completed yet
|
52 |
def select_new_symbol():
|
|
|
82 |
global current_symbol, remaining_features, current_feature
|
83 |
if remaining_features:
|
84 |
current_feature = remaining_features.pop(0)
|
85 |
+
question = (f"Practicing with /{current_symbol}/ sound. "
|
86 |
+
f"Does the '{current_feature}' feature of /{current_symbol}/ have a positive or negative value?")
|
87 |
+
return question, "", f"[+{current_feature}]", f"[-{current_feature}]"
|
88 |
else:
|
89 |
current_symbol, remaining_features = select_new_symbol()
|
90 |
if current_symbol:
|
91 |
current_feature = remaining_features.pop(0)
|
92 |
+
question = (f"Practicing with /{current_symbol}/ sound. "
|
93 |
+
f"Does the '{current_feature}' feature of /{current_symbol}/ have a positive or negative value?")
|
94 |
+
return question, "", f"[+{current_feature}]", f"[-{current_feature}]"
|
95 |
else:
|
96 |
+
return "You've completed all symbols!", "", "", ""
|
97 |
|
98 |
# Gradio Interface
|
99 |
with gr.Blocks() as quiz_app:
|
|
|
104 |
score_text = gr.Markdown()
|
105 |
attempts_text = gr.Markdown()
|
106 |
|
107 |
+
# Answer Buttons in a row with dynamic labels
|
108 |
with gr.Row():
|
109 |
+
positive_button = gr.Button("+Feature")
|
110 |
+
negative_button = gr.Button("-Feature")
|
111 |
+
|
112 |
+
# Dynamic labels for the answer buttons
|
113 |
+
positive_label = gr.Markdown(value="")
|
114 |
+
negative_label = gr.Markdown(value="")
|
115 |
|
116 |
# Feedback Display below the answer buttons
|
117 |
feedback_area = gr.Markdown()
|
|
|
120 |
next_button = gr.Button("Next Feature/Symbol")
|
121 |
|
122 |
# Set up button actions
|
123 |
+
start_button.click(start_quiz, outputs=[question_text, feedback_area, score_text, attempts_text, positive_label, negative_label])
|
124 |
positive_button.click(lambda: check_answer('+'), outputs=[feedback_area, score_text, attempts_text, question_text])
|
125 |
negative_button.click(lambda: check_answer('-'), outputs=[feedback_area, score_text, attempts_text, question_text])
|
126 |
+
next_button.click(load_next, outputs=[question_text, feedback_area, positive_label, negative_label])
|
127 |
|
128 |
# Launch the app
|
129 |
+
quiz_app.launch()
|