Imane Momayiz
commited on
Commit
·
0ecaa8b
1
Parent(s):
ba08cc7
fix: new sentence
Browse files
app.py
CHANGED
@@ -25,6 +25,10 @@ def fetch_sentence(dataset, column_name="darija_ar"):
|
|
25 |
random_sentence_index = random.randint(0, len(dataset) - 1)
|
26 |
random_sentence = dataset[random_sentence_index][column_name]
|
27 |
|
|
|
|
|
|
|
|
|
28 |
return random_sentence
|
29 |
|
30 |
def store_submission(api: HfApi, sentence: str, translation: str, translation_fr: str):
|
@@ -55,8 +59,6 @@ def store_submission(api: HfApi, sentence: str, translation: str, translation_fr
|
|
55 |
# Load the dataset
|
56 |
dataset = load_data(REPO_ID)
|
57 |
|
58 |
-
def generate_new_sentence():
|
59 |
-
return fetch_sentence(dataset)
|
60 |
|
61 |
def main():
|
62 |
|
@@ -93,7 +95,8 @@ def main():
|
|
93 |
|
94 |
# Display new sentence button
|
95 |
st.session_state.display_new = st.button("New Sentence",
|
96 |
-
on_click=
|
|
|
97 |
|
98 |
|
99 |
# Input field for translation
|
|
|
25 |
random_sentence_index = random.randint(0, len(dataset) - 1)
|
26 |
random_sentence = dataset[random_sentence_index][column_name]
|
27 |
|
28 |
+
st.session_state.sentence = random_sentence
|
29 |
+
st.session_state.translation_input = ""
|
30 |
+
st.session_state.translation_input_fr = ""
|
31 |
+
|
32 |
return random_sentence
|
33 |
|
34 |
def store_submission(api: HfApi, sentence: str, translation: str, translation_fr: str):
|
|
|
59 |
# Load the dataset
|
60 |
dataset = load_data(REPO_ID)
|
61 |
|
|
|
|
|
62 |
|
63 |
def main():
|
64 |
|
|
|
95 |
|
96 |
# Display new sentence button
|
97 |
st.session_state.display_new = st.button("New Sentence",
|
98 |
+
on_click=fetch_sentence,
|
99 |
+
args=(dataset,))
|
100 |
|
101 |
|
102 |
# Input field for translation
|