Spaces:
Running
Running
BeardedMonster
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -144,9 +144,9 @@ sample_texts = {
|
|
144 |
"Igbo: N'ala Igbo ...": "N'ala Igbo, ọtụtụ ndị mmadụ kwenyere na e nwere mmiri ara na elu-ilu",
|
145 |
"urhobo: Eshare nana ri...":"Eshare nana ri vwo ẹguọnọ rẹ iyono rẹ Aristotle vẹ Plato na",
|
146 |
"Efik: Ke eyo ...":"Ke eyo Jesus ye mme mbet esie, etop emi ama ada ifụre ọsọk mme Jew oro esịt okobụn̄ọde ke ntak idiọkido ke Israel, oro ẹkenyụn̄ ẹdude ke mfụhọ ke itie-ufụn mme nsunsu ido edinam Ido Ukpono Mme Jew eke akpa isua ikie.",
|
147 |
-
"Tell me a story in pidgin": "Tell me a story Pidgin",
|
148 |
"who are you?": "who are you?",
|
149 |
"Speak Yoruba": "Speak Yoruba",
|
|
|
150 |
"Translate 'Often, all Yoruba children...' to Yoruba": "Often, all Yoruba children take pride in speaking the Yoruba language.",
|
151 |
"Classify the sentiment": "Anyi na-echefu oke ike.",
|
152 |
"what is the topic of this text": "Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn",
|
@@ -156,18 +156,33 @@ sample_texts = {
|
|
156 |
}
|
157 |
|
158 |
instruction_wrap = {
|
159 |
-
"Translate 'Often, all Yoruba children...' to Yoruba":"<translate> Often, all Yoruba children take pride in speaking the Yoruba language. <yor>",
|
160 |
"Tell me a story in pidgin": "<prompt> Tell me a story in pidgin <response>:",
|
161 |
-
"
|
|
|
162 |
"who are you?": "<prompt> who are you? <response>:",
|
163 |
"Speak Yoruba": "<prompt> Speak Yoruba <response>:",
|
164 |
-
"
|
165 |
-
"
|
166 |
-
"
|
167 |
-
"
|
168 |
-
'
|
169 |
}
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
# Task options
|
172 |
task_options = {
|
173 |
"select": "{}",
|
@@ -216,7 +231,7 @@ def wrap_text(text, task_value):
|
|
216 |
|
217 |
# Text input
|
218 |
user_input = st.text_area("Enter text below **(PLEASE, FIRST READ ALL INSTRUCTIONS IN THE SIDEBAR CAREFULLY FOR THE BEST EXPERIENCE)**: ", sample_texts[sample_text])
|
219 |
-
user_input = instruction_wrap.get(
|
220 |
print("Final user input: ", user_input)
|
221 |
|
222 |
if st.button("Generate"):
|
@@ -238,7 +253,8 @@ if st.button("Generate"):
|
|
238 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
239 |
|
240 |
|
241 |
-
generated_text = re.split(r"\|(end_f_text|end_of_text|end_ofext|
|
|
|
242 |
print("Generated text: ", generated_text)
|
243 |
|
244 |
if task == "Sentiment Classification":
|
|
|
144 |
"Igbo: N'ala Igbo ...": "N'ala Igbo, ọtụtụ ndị mmadụ kwenyere na e nwere mmiri ara na elu-ilu",
|
145 |
"urhobo: Eshare nana ri...":"Eshare nana ri vwo ẹguọnọ rẹ iyono rẹ Aristotle vẹ Plato na",
|
146 |
"Efik: Ke eyo ...":"Ke eyo Jesus ye mme mbet esie, etop emi ama ada ifụre ọsọk mme Jew oro esịt okobụn̄ọde ke ntak idiọkido ke Israel, oro ẹkenyụn̄ ẹdude ke mfụhọ ke itie-ufụn mme nsunsu ido edinam Ido Ukpono Mme Jew eke akpa isua ikie.",
|
|
|
147 |
"who are you?": "who are you?",
|
148 |
"Speak Yoruba": "Speak Yoruba",
|
149 |
+
"Translate 'how are you?' to Yoruba": "how are you?",
|
150 |
"Translate 'Often, all Yoruba children...' to Yoruba": "Often, all Yoruba children take pride in speaking the Yoruba language.",
|
151 |
"Classify the sentiment": "Anyi na-echefu oke ike.",
|
152 |
"what is the topic of this text": "Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn",
|
|
|
156 |
}
|
157 |
|
158 |
instruction_wrap = {
|
159 |
+
# "Translate 'Often, all Yoruba children...' to Yoruba":"<translate> Often, all Yoruba children take pride in speaking the Yoruba language. <yor>",
|
160 |
"Tell me a story in pidgin": "<prompt> Tell me a story in pidgin <response>:",
|
161 |
+
"how are you?": "<translate> how are you? <yor>:",
|
162 |
+
"Often, all Yoruba children take pride in speaking the Yoruba language.": "<translate> Often, all Yoruba children take pride in speaking the Yoruba language. <yor>",
|
163 |
"who are you?": "<prompt> who are you? <response>:",
|
164 |
"Speak Yoruba": "<prompt> Speak Yoruba <response>:",
|
165 |
+
"Anyi na-echefu oke ike." : "<classify> Anyi na-echefu oke ike. <sentiment>",
|
166 |
+
"Abin mamaki ne aikin da shugabaZn HNajeriya ybake yi. kCiF 39gaba Tda haRkGa sir!": "<clean> Abin mamaki ne aikin da shugabaZn HNajeriya ybake yi. kCiF 39gaba Tda haRkGa sir! <pcm>",
|
167 |
+
"E sun, Alaga, fun ise amalayi ti e n se ni Naijiria. E maa ba a lo, egbon!": "<diacritize> E sun, Alaga, fun ise amalayi ti e n se ni Naijiria. E maa ba a lo, egbon! <yor>",
|
168 |
+
"Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn": "<classify> Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn <topic>",
|
169 |
+
'** Sylvain Itté French ambassador don comot Niger Republic **. Sylvain Itté, di French ambassador for Niger don comot Niamey and currently e dey for flight from Ndjamena to Paris. Sylvain Itté, di French ambassador for Niger don comot Niamey very early dis morning and currently e dey for flight from Ndjamena to Paris.\n\nDi military detain Bazoum and im family for di presidential palace. Niger na former French colony, and France still get 1,500 sojas for di African country.\n\n"France don decide to withdraw dia ambassador. In di next hours our ambassador and several diplomats go return to France," Oga Macron tok.\n\nE add say di military co-operation dey "over" and French troops go leave in "di months to come".\n\n"Dis Sunday we celebrate one new step towards di sovereignty of Niger," di junta tok, for one statement wey AFP news agency quote.\n\nDi decision by Paris dey come afta months of hostility and protest against di presence of French for di kontri, wit regular demonstrations for di capital Niamey.\n\nDi move don scata France operations against Islamist militants for di wider Sahel region and Paris influence for there. But oga Macron tok say "putschists no go hold France hostage,"': '<title> ** Sylvain Itté French ambassador don comot Niger Republic **. Sylvain Itté, di French ambassador for Niger don comot Niamey and currently e dey for flight from Ndjamena to Paris. Sylvain Itté, di French ambassador for Niger don comot Niamey very early dis morning and currently e dey for flight from Ndjamena to Paris.\n\nDi military detain Bazoum and im family for di presidential palace. Niger na former French colony, and France still get 1,500 sojas for di African country.\n\n"France don decide to withdraw dia ambassador. In di next hours our ambassador and several diplomats go return to France," Oga Macron tok.\n\nE add say di military co-operation dey "over" and French troops go leave in "di months to come".\n\n"Dis Sunday we celebrate one new step towards di sovereignty of Niger," di junta tok, for one statement wey AFP news agency quote.\n\nDi decision by Paris dey come afta months of hostility and protest against di presence of French for di kontri, wit regular demonstrations for di capital Niamey.\n\nDi move don scata France operations against Islamist militants for di wider Sahel region and Paris influence for there. But oga Macron tok say "putschists no go hold France hostage," <headline>',
|
170 |
}
|
171 |
|
172 |
+
# instruction_wrap = {
|
173 |
+
# # "Translate 'Often, all Yoruba children...' to Yoruba":"<translate> Often, all Yoruba children take pride in speaking the Yoruba language. <yor>",
|
174 |
+
# "Tell me a story in pidgin": "<prompt> Tell me a story in pidgin <response>:",
|
175 |
+
# "Translate 'how are you?' to Yoruba": "<translate> how are you? <yor>:",
|
176 |
+
# "Translate 'Often, all Yoruba children...' to Yoruba": "<translate> Often, all Yoruba children take pride in speaking the Yoruba language. <yor>",
|
177 |
+
# "who are you?": "<prompt> who are you? <response>:",
|
178 |
+
# "Speak Yoruba": "<prompt> Speak Yoruba <response>:",
|
179 |
+
# "Classify the sentiment" : "<classify> Anyi na-echefu oke ike. <sentiment>",
|
180 |
+
# "clean this text": "<clean> Abin mamaki ne aikin da shugabaZn HNajeriya ybake yi. kCiF 39gaba Tda haRkGa sir! <pcm>",
|
181 |
+
# "diacritize this text: ": "<diacritize> E sun, Alaga, fun ise amalayi ti e n se ni Naijiria. E maa ba a lo, egbon! <yor>",
|
182 |
+
# "what is the topic of this text": "<classify> Africa Free Trade Zone: Kò sí ìdènà láti kó ọjà láti orílẹ̀èdè kan sí òmíràn <topic>",
|
183 |
+
# 'headline of this text': '<title> ** Sylvain Itté French ambassador don comot Niger Republic **. Sylvain Itté, di French ambassador for Niger don comot Niamey and currently e dey for flight from Ndjamena to Paris. Sylvain Itté, di French ambassador for Niger don comot Niamey very early dis morning and currently e dey for flight from Ndjamena to Paris.\n\nDi military detain Bazoum and im family for di presidential palace. Niger na former French colony, and France still get 1,500 sojas for di African country.\n\n"France don decide to withdraw dia ambassador. In di next hours our ambassador and several diplomats go return to France," Oga Macron tok.\n\nE add say di military co-operation dey "over" and French troops go leave in "di months to come".\n\n"Dis Sunday we celebrate one new step towards di sovereignty of Niger," di junta tok, for one statement wey AFP news agency quote.\n\nDi decision by Paris dey come afta months of hostility and protest against di presence of French for di kontri, wit regular demonstrations for di capital Niamey.\n\nDi move don scata France operations against Islamist militants for di wider Sahel region and Paris influence for there. But oga Macron tok say "putschists no go hold France hostage," <headline>',
|
184 |
+
# }
|
185 |
+
|
186 |
# Task options
|
187 |
task_options = {
|
188 |
"select": "{}",
|
|
|
231 |
|
232 |
# Text input
|
233 |
user_input = st.text_area("Enter text below **(PLEASE, FIRST READ ALL INSTRUCTIONS IN THE SIDEBAR CAREFULLY FOR THE BEST EXPERIENCE)**: ", sample_texts[sample_text])
|
234 |
+
user_input = instruction_wrap.get(user_input, user_input)
|
235 |
print("Final user input: ", user_input)
|
236 |
|
237 |
if st.button("Generate"):
|
|
|
253 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
254 |
|
255 |
|
256 |
+
# generated_text = re.split(r"\|(end_f_text|end_of_text|end_ofext|end_of_text_||end_of_te|end_oftext)|:|`", generated_text)[0]
|
257 |
+
generated_text = re.sub(r"\|(end_f_text|end_of_text|end_ofext|end_of_text_|end_of_te|end_o|end_of_tet|end_oftext)|:|`\|", "", generated_text)
|
258 |
print("Generated text: ", generated_text)
|
259 |
|
260 |
if task == "Sentiment Classification":
|