Imane Momayiz
commited on
Commit
·
3c66851
1
Parent(s):
d3f6711
fix: submissions
Browse files
app.py
CHANGED
@@ -73,7 +73,7 @@ def store_submission(api: HfApi, sentence: str, translation: str, translation_fr
|
|
73 |
# )
|
74 |
|
75 |
with scheduler.lock:
|
76 |
-
with
|
77 |
f.write(json.dumps({
|
78 |
"darija": translation_fr,
|
79 |
"eng": translation,
|
@@ -134,27 +134,26 @@ st.session_state.display_new = st.button("New Sentence",
|
|
134 |
# Input field for translation
|
135 |
translation_input_placeholder = st.empty()
|
136 |
|
137 |
-
|
138 |
-
translation_input = st.text_input("Enter translation to english: ",
|
139 |
st.session_state.translation_input)
|
140 |
-
|
141 |
|
142 |
# Input field for translation
|
143 |
translation_input_placeholder_fr = st.empty()
|
144 |
|
145 |
-
|
146 |
-
translation_input_fr = st.text_input(
|
147 |
"Enter translation to darija in latin characters: ",
|
148 |
st.session_state.translation_input_fr
|
149 |
)
|
150 |
-
|
151 |
|
152 |
if st.button("Submit Translation"):
|
153 |
-
if
|
154 |
-
st.warning("Please enter a translation before submitting.")
|
155 |
-
else:
|
156 |
store_submission(api,
|
157 |
st.session_state.sentence,
|
158 |
st.session_state.translation_input,
|
159 |
st.session_state.translation_input_fr
|
160 |
-
)
|
|
|
|
|
|
|
|
73 |
# )
|
74 |
|
75 |
with scheduler.lock:
|
76 |
+
with open(submissions_file, "a") as f:
|
77 |
f.write(json.dumps({
|
78 |
"darija": translation_fr,
|
79 |
"eng": translation,
|
|
|
134 |
# Input field for translation
|
135 |
translation_input_placeholder = st.empty()
|
136 |
|
137 |
+
translation_input = st.text_input("Enter translation to english: ",
|
|
|
138 |
st.session_state.translation_input)
|
139 |
+
st.session_state.translation_input = translation_input
|
140 |
|
141 |
# Input field for translation
|
142 |
translation_input_placeholder_fr = st.empty()
|
143 |
|
144 |
+
translation_input_fr = st.text_input(
|
|
|
145 |
"Enter translation to darija in latin characters: ",
|
146 |
st.session_state.translation_input_fr
|
147 |
)
|
148 |
+
st.session_state.translation_input_fr = translation_input_fr
|
149 |
|
150 |
if st.button("Submit Translation"):
|
151 |
+
if st.session_state.translation_input_fr or st.session_state.translation_input:
|
|
|
|
|
152 |
store_submission(api,
|
153 |
st.session_state.sentence,
|
154 |
st.session_state.translation_input,
|
155 |
st.session_state.translation_input_fr
|
156 |
+
)
|
157 |
+
else:
|
158 |
+
st.warning("Please enter a translation before submitting.")
|
159 |
+
|