Spaces:
Sleeping
Sleeping
=
commited on
Commit
·
b83a10b
1
Parent(s):
6044374
added new sentences elaboration to augment
Browse files
app.py
CHANGED
@@ -52,7 +52,6 @@ def add_word_to_text():
|
|
52 |
|
53 |
st.session_state.input_text += word
|
54 |
|
55 |
-
st.write(sp_wolof_words.loc[0, 'french'])
|
56 |
# Dropdown for introducing wolof special characters
|
57 |
if translation_type == "Wolof ➡️ French":
|
58 |
|
@@ -63,10 +62,6 @@ if translation_type == "Wolof ➡️ French":
|
|
63 |
# Dropdown for the model version
|
64 |
version = st.sidebar.selectbox("Model version", options=["Version ☝️", "Version ✌️"])
|
65 |
|
66 |
-
# Recuperate the number of sentences to provide
|
67 |
-
number = st.sidebar.number_input("Give the number of sentences that you want to provide", min_value = 1,
|
68 |
-
max_value = 100)
|
69 |
-
|
70 |
# Recuperate the number of sentences to provide
|
71 |
temperature = st.sidebar.slider("How randomly need you the translated sentences to be from 0% to 100%", min_value = 0,
|
72 |
max_value = 100)
|
|
|
52 |
|
53 |
st.session_state.input_text += word
|
54 |
|
|
|
55 |
# Dropdown for introducing wolof special characters
|
56 |
if translation_type == "Wolof ➡️ French":
|
57 |
|
|
|
62 |
# Dropdown for the model version
|
63 |
version = st.sidebar.selectbox("Model version", options=["Version ☝️", "Version ✌️"])
|
64 |
|
|
|
|
|
|
|
|
|
65 |
# Recuperate the number of sentences to provide
|
66 |
temperature = st.sidebar.slider("How randomly need you the translated sentences to be from 0% to 100%", min_value = 0,
|
67 |
max_value = 100)
|
pages/page_1.py
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
|
3 |
-
st.markdown("Page 1")
|
|
|
|
|
|
|
|
pages/provide_sentences.py
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
st.markdown("Provide your own 🤗 sentences")
|
5 |
+
|
6 |
+
# recuperate the already saved sentences (for the moment french/wolof)
|
7 |
+
sentences_ = pd.read_csv('wolof-translate/wolof_translate/data/sentences/wolof_french.csv')
|
8 |
+
|
9 |
+
sentences = sentences_.copy()
|
10 |
+
|
11 |
+
# add special characters from Wolof
|
12 |
+
sp_wolof_chars = pd.read_csv('wolof-translate/wolof_translate/data/wolof_writing/wolof_special_chars.csv')
|
13 |
+
|
14 |
+
# add definitions
|
15 |
+
sp_wolof_words = pd.read_csv('wolof-translate/wolof_translate/data/wolof_writing/definitions.csv')
|
16 |
+
|
17 |
+
# initialize the input texts
|
18 |
+
st.title("Provide sentences below ⤵️")
|
19 |
+
|
20 |
+
st.markdown("""---""")
|
21 |
+
|
22 |
+
# create three columns
|
23 |
+
left, right = st.columns(2)
|
24 |
+
|
25 |
+
left.header("French")
|
26 |
+
left.text_input(sentences.columns.tolist()[0], key = "left_sentence")
|
27 |
+
|
28 |
+
right.header("Wolof")
|
29 |
+
right.text_input(sentences.columns.tolist()[1], key = "right_sentence")
|
30 |
+
|
31 |
+
# let us add a callback functions to change the input text
|
32 |
+
def add_symbol_to_text():
|
33 |
+
|
34 |
+
st.session_state.right_sentence += st.session_state.symbol
|
35 |
+
|
36 |
+
def add_word_to_text():
|
37 |
+
|
38 |
+
word = st.session_state.word.split('/')[0].strip()
|
39 |
+
|
40 |
+
st.session_state.right_sentence += word
|
41 |
+
|
42 |
+
# let us create a callback which permit us to add sentences inside a DataFrame
|
43 |
+
def add_new_sentences():
|
44 |
+
|
45 |
+
global sentences
|
46 |
+
|
47 |
+
sentence_1 = st.session_state.left_sentence.strip()
|
48 |
+
|
49 |
+
sentence_2 = st.session_state.right_sentence.strip()
|
50 |
+
|
51 |
+
if sentence_1 == '' or sentence_2 == '':
|
52 |
+
|
53 |
+
st.warning("You didn't provide a sentence ! Please provide before submitting.", icon= "🚨")
|
54 |
+
|
55 |
+
else:
|
56 |
+
|
57 |
+
if not sentences.empty > 0:
|
58 |
+
|
59 |
+
sentences = pd.concat((sentences, pd.DataFrame({sentences.columns.tolist()[0]: [sentence_1],
|
60 |
+
sentences.columns.tolist()[1]: [sentence_2]})))
|
61 |
+
|
62 |
+
else:
|
63 |
+
|
64 |
+
sentences = pd.DataFrame({sentences.columns.tolist()[0]: [sentence_1],
|
65 |
+
sentences.columns.tolist()[1]: [sentence_2]})
|
66 |
+
## save the result
|
67 |
+
sentences.to_csv('wolof-translate/wolof_translate/data/sentences/wolof_french.csv', index=False)
|
68 |
+
|
69 |
+
# recuperate the already saved sentences (for the moment french/wolof)
|
70 |
+
sentences = pd.read_csv('wolof-translate/wolof_translate/data/sentences/wolof_french.csv')
|
71 |
+
|
72 |
+
# clean the inputs' contents
|
73 |
+
|
74 |
+
def delete_line():
|
75 |
+
|
76 |
+
number = st.session_state.line
|
77 |
+
|
78 |
+
if number > len(sentences) - 1:
|
79 |
+
|
80 |
+
st.warning("The line that you provided does not exist !")
|
81 |
+
|
82 |
+
else:
|
83 |
+
|
84 |
+
deleted = pd.read_csv('wolof-translate/wolof_translate/data/sentences/deleted_lines.csv')
|
85 |
+
|
86 |
+
if not deleted.empty:
|
87 |
+
|
88 |
+
deleted = pd.concat((deleted, pd.DataFrame({sentences.columns.tolist()[0]: [sentences.loc[number, sentences.columns.tolist()[0]]],
|
89 |
+
sentences.columns.tolist()[1]: sentences.loc[number, sentences.columns.tolist()[1]]})))
|
90 |
+
|
91 |
+
else:
|
92 |
+
|
93 |
+
deleted = pd.DataFrame({sentences.columns.tolist()[0]: [sentences.loc[number, sentences.columns.tolist()[0]]],
|
94 |
+
sentences.columns.tolist()[1]: sentences.loc[number, sentences.columns.tolist()[1]]})
|
95 |
+
|
96 |
+
sentences.drop(index = number, inplace=True)
|
97 |
+
|
98 |
+
## save the result
|
99 |
+
sentences.to_csv('wolof-translate/wolof_translate/data/sentences/wolof_french.csv', index=False)
|
100 |
+
|
101 |
+
deleted.to_csv('wolof-translate/wolof_translate/data/sentences/deleted_lines.csv', index=False)
|
102 |
+
|
103 |
+
symbol = st.sidebar.selectbox("Wolof characters", key="symbol", options = sp_wolof_chars['wolof_special_chars'], on_change=add_symbol_to_text)
|
104 |
+
|
105 |
+
word = st.sidebar.selectbox("Wolof words/Definitions", key="word", options = [sp_wolof_words.loc[i, 'wolof']+" / "+sp_wolof_words.loc[i, 'french'] for i in range(sp_wolof_words.shape[0])], on_change=add_word_to_text)
|
106 |
+
|
107 |
+
|
108 |
+
# add a submit button to add new sentences
|
109 |
+
st.button('Submit', 'submit_button', on_click=add_new_sentences)
|
110 |
+
|
111 |
+
st.markdown("""---""")
|
112 |
+
|
113 |
+
number = st.number_input("Provide line to delete", key="line", min_value=0)
|
114 |
+
|
115 |
+
st.button("Delete", 'delete_button', on_click=delete_line)
|
116 |
+
|
117 |
+
# add data frame
|
118 |
+
st.dataframe(sentences, width=900)
|
119 |
+
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
|
128 |
+
|
wolof-translate/wolof_translate/data/sentences/deleted_lines.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
french,wolof
|
2 |
+
dkfsjfkdsf,dkfjskfjds
|
3 |
+
Je part jouer,dkfjskfjds
|
wolof-translate/wolof_translate/data/sentences/wolof_french.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
french,wolof
|
2 |
+
Comment allez-vous ?,Naka ógen def
|
3 |
+
Je part jouer.,Mangui foowi.
|