abdullahmubeen10 commited on
Commit
75419ed
·
verified ·
1 Parent(s): 592dffd

Upload 5 files

Browse files
.streamlit/config.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [theme]
2
+ base="light"
3
+ primaryColor="#29B4E8"
Demo.py ADDED
@@ -0,0 +1,671 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import sparknlp
3
+ import os
4
+
5
+ from sparknlp.base import *
6
+ from sparknlp.common import *
7
+ from sparknlp.annotator import *
8
+ from pyspark.ml import Pipeline
9
+ from sparknlp.pretrained import PretrainedPipeline
10
+
11
+ # Page Configuration
12
+ st.set_page_config(
13
+ layout="wide",
14
+ initial_sidebar_state="auto"
15
+ )
16
+
17
+ # Custom CSS for Styling
18
+ st.markdown("""
19
+ <style>
20
+ .main-title {
21
+ font-size: 36px;
22
+ color: #4A90E2;
23
+ font-weight: bold;
24
+ text-align: center;
25
+ }
26
+ .section {
27
+ background-color: #f9f9f9;
28
+ padding: 10px;
29
+ border-radius: 10px;
30
+ margin-top: 10px;
31
+ }
32
+ .section p, .section ul {
33
+ color: #666666;
34
+ }
35
+ </style>
36
+ """, unsafe_allow_html=True)
37
+
38
+ # Initialize Spark NLP
39
+ @st.cache_resource
40
+ def init_spark():
41
+ return sparknlp.start()
42
+
43
+ # Create a Spark NLP Pipeline for MarianTransformer
44
+ @st.cache_resource
45
+ def create_pipeline(model_name, fr, to):
46
+ documentAssembler = DocumentAssembler() \
47
+ .setInputCol("text") \
48
+ .setOutputCol("documents")
49
+
50
+ m2m100 = M2M100Transformer.pretrained(model_name,"xx") \
51
+ .setInputCols(["documents"]) \
52
+ .setMaxOutputLength(50) \
53
+ .setOutputCol("generation") \
54
+ .setSrcLang(fr) \
55
+ .setTgtLang(to)
56
+
57
+ pipeline = Pipeline().setStages([documentAssembler, m2m100])
58
+ return pipeline
59
+
60
+ # Process the Input Text Through the Pipeline
61
+ def fit_data(pipeline, text):
62
+ data = spark.createDataFrame([[text]]).toDF("text")
63
+ result = pipeline.fit(data).transform(data)
64
+ return result.select('generation.result').collect()
65
+
66
+ # Title and Subtitle
67
+ title = 'Multilingual Text Translation with Spark NLP and MarianMT'
68
+ sub_title = """
69
+ The MarianTransformer is a powerful, state-of-the-art machine translation model based on the Transformer architecture. Developed by the MarianMT project, this annotator supports over 1,000 translation directions, making it one of the most versatile tools for multilingual natural language processing. Integrated within Spark NLP, the MarianTransformer Annotator allows for scalable and efficient text translation, leveraging the parallel processing capabilities of Apache Spark. Whether you're translating large documents or handling multiple languages simultaneously, this tool ensures high-quality translations with minimal latency.
70
+ """
71
+
72
+ st.markdown(f'<div class="main-title">{title}</div>', unsafe_allow_html=True)
73
+ st.markdown(f'<div class="section"><p>{sub_title}</p></div>', unsafe_allow_html=True)
74
+
75
+ # Placeholder for language_map
76
+ language_map = {
77
+ "Afrikaans": {
78
+ "af": [
79
+ "Ek het 'n lang stap langs die strand geneem, terwyl die son stadig onder die horison gesak het, en ek het gedink aan al die herinneringe wat ek hier oor die jare opgebou het.",
80
+ "Die voëls het begin sing en die golwe het rustig geklap, wat alles 'n gevoel van vrede en rustigheid gegee het."
81
+ ]
82
+ },
83
+ "Amharic": {
84
+ "am": [
85
+ "እንደ ምሳሌ እንዲሆን እንዲሁ በጣም በረከት አለኝ፣ በሚሊካ እንደምንም የአስተያየት እና ከፍተኛ የተወሰነ ተጠቃሚ አለኝ።",
86
+ "በከፊል ወይም በተመሳሳይ አጠቃቀም ሲኖረው የተለያዩ ባህላዊ እና ባህላዊ ባህሎች አሉ።"
87
+ ]
88
+ },
89
+ "Arabic": {
90
+ "ar": [
91
+ "لقد أخذت نزهة طويلة على طول الشاطئ، بينما كانت الشمس تغرب ببطء تحت الأفق، وفكرت في جميع الذكريات التي بنيتها هنا على مر السنين.",
92
+ "بدأت الطيور في الغناء وهدأت الأمواج، مما أعطى كل شيء شعورًا بالسلام والهدوء."
93
+ ]
94
+ },
95
+ "Asturian": {
96
+ "ast": [
97
+ "Fui a dar una llarga vuelta pola praia mentres el sol se ponía lentamente a lo llargo del horizontu, pensando en tolos recuerdos que acumulé aquí al llargos años.",
98
+ "Los pajaros empezaron a cantar y les ondas calmaron, dando a tolo un sentimento de paz y tranquilidá."
99
+ ]
100
+ },
101
+ "Azerbaijani": {
102
+ "az": [
103
+ "Uzun bir vaxt çimərlikdə gəzdikdən sonra, günəş yavaşca üufqın altına batarkən, burada illər ərzində topladığım xatirələri düşündüm.",
104
+ "Quşlar mahnı oxumağa başladılar və dalğalar sakitləşdi, hər şeyə sülh və sakitlik hissi verdi."
105
+ ]
106
+ },
107
+ "Bashkir": {
108
+ "ba": [
109
+ "Мин оҙон сәйәхәт яһаным, ҡояш әкрен генә горизонт аҫтына төшкәндә, бында йылдар буйы туплаған хәтирәләрем тураһында уйландым.",
110
+ "Ҡоштар йырҙарын башланы һәм тулҡындар тынысланды, бөтә нәмә тыныслыҡ һәм покой тойғоһо бирҙе."
111
+ ]
112
+ },
113
+ "Belarusian": {
114
+ "be": [
115
+ "Я прайшоў доўгі шлях па пляжы, пакуль сонца павольна захоўвалася за гарызонтам, і падумаў пра ўсе ўспаміны, якія я назапасіў тут на працягу гадоў.",
116
+ "Птушкі пачалі спяваць, і хвалі супакоіліся, надаўшы ўсім адчуванне спакою і супакою."
117
+ ]
118
+ },
119
+ "Bulgarian": {
120
+ "bg": [
121
+ "Направих дълга разходка по плажа, докато слънцето бавно се скриваше под хоризонта, и помислих за всички спомени, които съм натрупал тук през годините.",
122
+ "Птиците започнаха да пеят, а вълните се успокоиха, придавайки на всичко чувство на мир и спокойствие."
123
+ ]
124
+ },
125
+ "Bengali": {
126
+ "bn": [
127
+ "আমি সৈকতে একটি দীর্ঘ হাঁটা দিয়েছি, সূর্য ধীরে ধীরে দিগন্তের নিচে অস্ত যাওয়ার সময়, এবং আমি মনে করেছি সমস্ত স্মৃতি যা আমি এখানে বছরের পর বছর ধরে সংগ্রহ করেছি।",
128
+ "পাখিরা গান গাওয়া শুরু করলো এবং তরঙ্গগুলি শান্ত হলো, সবকিছুকে শান্তি এবং প্রশান্তির অনুভূতি প্রদান করলো।"
129
+ ]
130
+ },
131
+ "Breton": {
132
+ "br": [
133
+ "Me zo bet e-barzh ur ballade hir war ar mor, pa varo an heol a-raog an horizon, ha me oar mat an holl kounoudegezhioù em eus savet amañ e-pad ar bloavezhioù.",
134
+ "Ar birdenn a zo bet o singiñ hag ar mor a zo bet peogwir, o kinnig ur sentadurezh en ur stad pe den a zo dreist."
135
+ ]
136
+ },
137
+ "Bosnian": {
138
+ "bs": [
139
+ "Prošao sam dugu šetnju plažom dok je sunce polako zalazilo iza horizonta, razmišljajući o svim uspomenama koje sam ovdje prikupio tokom godina.",
140
+ "Ptice su počele pjevati, a valovi su se smirili, dajući svemu osjećaj mira i tišine."
141
+ ]
142
+ },
143
+ "Catalan": {
144
+ "ca": [
145
+ "He fet una llarga passejada per la platja mentre el sol es ponia lentament sota l'horitzó i he pensat en tots els records que he acumulat aquí al llarg dels anys.",
146
+ "Els ocells van començar a cantar i les ones es van calmar, donant a tot un sentiment de pau i tranquil·litat."
147
+ ]
148
+ },
149
+ "Cebuano": {
150
+ "ceb": [
151
+ "Naghimo ako ug taas nga lakaw sa baybayon samtang ang adlaw hinay nga nagbutang sa ubos sa pahalipay ug naghunahuna sa tanan nga mga handumanan nga akong natipon dinhi sa miaging mga tuig.",
152
+ "Nagsugod ang mga langgam sa pagkanta ug ang mga balud nahimong kalmado, nga naghatag sa tanan ug pagbati sa kalinaw ug kalma."
153
+ ]
154
+ },
155
+ "Czech": {
156
+ "cs": [
157
+ "Šel jsem na dlouhou procházku po pláži, zatímco slunce pomalu zapadalo za obzor, a přemýšlel jsem o všech vzpomínkách, které jsem zde za léta nasbíral.",
158
+ "Ptáci začali zpívat a vlny se uklidnily, což dalo všemu pocit míru a klidu."
159
+ ]
160
+ },
161
+ "Welsh": {
162
+ "cy": [
163
+ "Arhosais i daith hir ar y traeth, wrth i'r haul fynd yn araf o dan y gorwel, ac fe feddyliais am yr holl atgofion sydd gennyf yma dros y blynyddoedd.",
164
+ "Dechreuodd yr adar ganu ac aeth y tonnau yn dawel, gan roi teimlad o heddwch a chytgord i bopeth."
165
+ ]
166
+ },
167
+ "Danish": {
168
+ "da": [
169
+ "Jeg tog en lang gåtur langs stranden, mens solen langsomt gik ned under horisonten, og jeg tænkte på alle de minder, jeg havde samlet her gennem årene.",
170
+ "Fuglene begyndte at synge, og bølgerne blev rolige, hvilket gav alt en følelse af fred og ro."
171
+ ]
172
+ },
173
+ "German": {
174
+ "de": [
175
+ "Ich habe einen langen Spaziergang am Strand gemacht, während die Sonne langsam unter den Horizont sank, und ich habe an all die Erinnerungen gedacht, die ich hier im Laufe der Jahre gesammelt habe.",
176
+ "Die Vögel begannen zu singen und die Wellen wurden ruhig, was allem ein Gefühl von Frieden und Ruhe verlieh."
177
+ ]
178
+ },
179
+ "Greek": {
180
+ "el": [
181
+ "Έκανα μια μακρά βόλτα κατά μήκος της παραλίας, ενώ ο ήλιος έδυε αργά κάτω από τον ορίζοντ��, και σκέφτηκα όλες τις αναμνήσεις που είχα συγκεντρώσει εδώ με τα χρόνια.",
182
+ "Τα πουλιά άρχισαν να τραγουδούν και τα κύματα ηρέμησαν, δίνοντας σε όλα μια αίσθηση ειρήνης και ηρεμίας."
183
+ ]
184
+ },
185
+ "English": {
186
+ "en": [
187
+ "I took a long walk along the beach while the sun slowly set below the horizon, and I thought about all the memories I have built up here over the years.",
188
+ "The birds started to sing and the waves calmed down, giving everything a sense of peace and tranquility."
189
+ ]
190
+ },
191
+ "Spanish": {
192
+ "es": [
193
+ "Hice una larga caminata por la playa mientras el sol se ponía lentamente en el horizonte, y pensé en todos los recuerdos que he acumulado aquí a lo largo de los años.",
194
+ "Los pájaros empezaron a cantar y las olas se calmaron, dando a todo una sensación de paz y tranquilidad."
195
+ ]
196
+ },
197
+ "Estonian": {
198
+ "et": [
199
+ "Ma tegin pika jalutuskäigu mööda randa, kui päike aeglaselt horisondi alla vajus, ja mõtlesin kõigile mälestustele, mida olen siin aastate jooksul kogunud.",
200
+ "Linnud hakkasid laulma ja lained rahunesid, andes kõikidele rahu ja rahu tunde."
201
+ ]
202
+ },
203
+ "Persian": {
204
+ "fa": [
205
+ "من پیاده‌روی طولانی‌ای در کنار ساحل انجام دادم، در حالی که خورشید به آرامی زیر افق فرو می‌رفت و به تمام خاطراتی که در طول سال‌ها در اینجا جمع کرده بودم فکر می‌کردم.",
206
+ "پرندگان شروع به خواندن کردند و امواج آرام شدند و به همه چیز احساسی از آرامش و سکون بخشید."
207
+ ]
208
+ },
209
+ "Fulah": {
210
+ "ff": [
211
+ "Miɗo waawi lannuɗo fow e hoore maɓɓe e ndiyam, e jooni miɗo feƴƴi haɓre fow ɗiɗi so miɗo miɗo woodi.",
212
+ "Awaayi no a waɗi e ndiyam e yaarɓe honto, haɓre fow mo adii eɗɗam e wuro no puɓɓe ɗum."
213
+ ]
214
+ },
215
+ "Finnish": {
216
+ "fi": [
217
+ "Tein pitkän kävelylenkin rannalla, kun aurinko hiljalleen laski horisontin alle, ja ajattelin kaikkia muistoja, joita olen kerännyt tänne vuosien varrella.",
218
+ "Linnut alkoivat laulaa ja aallot rauhoittuivat, antaen kaikille rauhan ja rauhallisuuden tunteen."
219
+ ]
220
+ },
221
+ "French": {
222
+ "fr": [
223
+ "J'ai fait une longue promenade le long de la plage tandis que le soleil se couchait lentement sous l'horizon, et j'ai pensé à tous les souvenirs que j'ai accumulés ici au fil des ans.",
224
+ "Les oiseaux ont commencé à chanter et les vagues se sont calmées, donnant à tout un sentiment de paix et de tranquillité."
225
+ ]
226
+ },
227
+ "Western Frisian": {
228
+ "fy": [
229
+ "Ik makke in lange kuier oan 'e kust, wylst de sinne stadichoan ûnder de horizonto sakke, en ik tocht oan alle oantinkens dy't ik hjir oer de jierren hinne opboud hie.",
230
+ "De fûgels begongen te sjongen en de golven kalmeerden, wat alles in gefoel fan frede en rêst joech."
231
+ ]
232
+ },
233
+ "Irish": {
234
+ "ga": [
235
+ "Rinne mé ar shiúl long ag an trá, agus an grian ag dul síos go mall faoi na hardáin, agus shíl mé faoi na cuimhní atá bailithe agam anseo thar na blianta.",
236
+ "Thosaigh na héin ag canadh agus d'éirigh na tonnta socair, ag tabhairt tuiscint síochána agus suaimhnis do gach rud."
237
+ ]
238
+ },
239
+ "Gaelic": {
240
+ "gd": [
241
+ "Ghabh mi turas fada air a' chladach, fhad 's a bha an grian a' dol fodha gu socair fo na h-oidhche, agus choinnich mi ri na cuimhneachain uile a thog mi an seo thairis air na bliadhnaichean.",
242
+ "Thòisich na h-eòin a' seinn agus thàinig na tonnan gu sìth, a' toirt faireachdainn sìthe agus socair do gach rud."
243
+ ]
244
+ },
245
+ "Galician": {
246
+ "gl": [
247
+ "Dei unha longa volta pola praia mentres o sol se poñía lentamente no horizonte, e pensaba en todos os recordos que acumulei aquí ao longo dos anos.",
248
+ "Os paxaros comezaron a cantar e as ondas tranquilizáronse, dando a todo unha sensación de paz e tranquilidade."
249
+ ]
250
+ },
251
+ "Gujarati": {
252
+ "gu": [
253
+ "હું બીચ પર લાંબી ફરાળ કરવા ગયો હતો, જ્યારે સૂર્ય ધીમે ધીમે હરિઝોન નીચે જઈ રહ્યો હતો, અને મેં અહીં વર્ષો દરમ્યાન જમા કરેલી તમામ યાદોને વિચાર્યું.",
254
+ "પક્ષીઓ ગાવા શરૂ થઈ ગઈ અને તરંગો શાંત થયા, બધાને શાંતિ અને શાંતિનો અનુભવ આપવામાં આવ્યો."
255
+ ]
256
+ },
257
+ "Hausa": {
258
+ "ha": [
259
+ "Na yi tafiya mai tsawo a bakin teku yayin da rana ke saukowa a hankali a ƙarƙashin ƙasa, na kuma yi tunani akan dukkan tunanin da na tara a nan tsawon shekaru.",
260
+ "Tsuntsaye sun fara waka kuma gungun ruwa ya kwantar da hankali, yana ba wa dukkan abubuwan jin dadin zaman lafiya da kwanciyar hankali."
261
+ ]
262
+ },
263
+ "Hebrew": {
264
+ "he": [
265
+ "הלכתי לטיול ארוך לאורך החוף, בעוד השמש שוקעת לאט מתחת לאופק, וחשבתי על כל הזיכרונות שאספתי כאן במהלך השנים.",
266
+ "הציפורים החלו לשיר והגלים נרגעו, מה שנתן לכל דבר תחושת שלום ושלווה."
267
+ ]
268
+ },
269
+ "Hindi": {
270
+ "hi": [
271
+ "मैं समुद्र तट पर एक लंबी सैर पर गया, जबकि सूरज धीरे-धीरे क्षितिज के नीचे ढल रहा था, और मैंने उन सभी यादों के बारे में सोचा जो मैंने यहां वर्षों के दौरान संकलित की हैं।",
272
+ "पक्षी गाने लगे और लहरें शांत हो गईं, जिससे सबको शांति और शांति का अहसास हुआ।"
273
+ ]
274
+ },
275
+ "Croatian": {
276
+ "hr": [
277
+ "Prošao sam dugu šetnju plažom dok je sunce polako zalazilo iza horizonta i razmišljao o svim uspomenama koje sam prikupio ovdje tijekom godina.",
278
+ "Ptice su počele pjevati, a valovi su se smirili, dajući svemu osjećaj mira i spokojstva."
279
+ ]
280
+ },
281
+ "Haitian": {
282
+ "ht": [
283
+ "Mwen te fè yon long mache sou plaj la pandan solèy la t ap desann dousman anba orizon an, epi mwen te panse sou tout souvni mwen te kolekte isit la pandan ane yo.",
284
+ "Zwazo yo te kòmanse chante epi vag yo te kalme, sa te bay tout bagay yon sans de lapè ak kalm."
285
+ ]
286
+ },
287
+ "Hungarian": {
288
+ "hu": [
289
+ "Hosszú sétát tettem a tengerparton, miközben a nap lassan lement a horizont alá, és arra gondoltam, milyen emlékeket gyűjtöttem itt az évek során.",
290
+ "A madarak énekelni kezdtek, és a hullámok lecsillapodtak, így mindennek megadva a béke és nyugalom érzését."
291
+ ]
292
+ },
293
+ "Armenian": {
294
+ "hy": [
295
+ "Ես երկար քայլում էի ծովափին, երբ արևը դանդաղ իջնում էր հորիզոնից ներքև, և մտածեցի բոլոր այն հիշողությունների մասին, որոնք հավաքել էի այստեղ տարիների ընթացքում:",
296
+ "Թռչունները սկսեցին երգել, իսկ ալիքները հանդարտվեցին, բոլորին խաղաղության և հանգստության զգացողություն պարգևելով:"
297
+ ]
298
+ },
299
+ "Indonesian": {
300
+ "id": [
301
+ "Saya melakukan perjalanan panjang di pantai sementara matahari perlahan tenggelam di bawah cakrawala, dan saya memikirkan semua kenangan yang telah saya kumpulkan di sini selama bertahun-tahun.",
302
+ "Burung-burung mulai bernyanyi dan ombak mereda, memberikan rasa damai dan ketenangan pada segala sesuatu."
303
+ ]
304
+ },
305
+ "Igbo": {
306
+ "ig": [
307
+ "M mere ogologo njem n’akụkụ osimiri mgbe anyanwụ na-apụ apụ na ala nke oke osimiri, na-echebara echiche banyere ihe niile m chepụtara ebe a n’ime ọtụtụ afọ.",
308
+ "Ndị nnụnụ malitere ịkụ egwu ma ụdị ụsọ ahụ nwayọọ, na-enye ihe niile mmetụta nke udo na ịdị jụụ."
309
+ ]
310
+ },
311
+ "Iloko": {
312
+ "ilo": [
313
+ "Nangrugiak iti maysa a nabanglo nga panaglakay iti baybay iti panawen nga agdama a bumaba iti langit, ket inkeddengko dagiti amin a rikna nga impundar ko ditoy iti naglabas a tawen.",
314
+ "Nagruyug dagiti laylayen ken napanay dagiti baybay, nga mangted iti amin ti panagserbi ken kapia."
315
+ ]
316
+ },
317
+ "Icelandic": {
318
+ "is": [
319
+ "Ég fór í langan göngutúr eftir ströndina meðan sólin settist hægt niður undir hvarfslínuna og hugsaði um allar minningarnar sem ég hef safnað hér yfir árin.",
320
+ "Fuglar byrjuðu að syngja og bylgjurnar róuðust, sem gaf öllu tilfinningu fyrir friði og ró."
321
+ ]
322
+ },
323
+ "Italian": {
324
+ "it": [
325
+ "Ho fatto una lunga passeggiata lungo la spiaggia mentre il sole scendeva lentamente sotto l'orizzonte e ho pensato a tutti i ricordi che ho accumulato qui nel corso degli anni.",
326
+ "Gli uccelli hanno cominciato a cantare e le onde si sono calmate, dando a tutto una sensazione di pace e tranquillità."
327
+ ]
328
+ },
329
+ "Japanese": {
330
+ "ja": [
331
+ "私はビーチを長い間散歩しながら、太陽がゆっくりと地平線の下に沈んでいくのを見て、ここで何年もかけて集めた思い出を考えました。",
332
+ "鳥たちが歌い始め、波が穏やかになり、すべてに平和と落ち着きの感覚を与えました。"
333
+ ]
334
+ },
335
+ "Javanese": {
336
+ "jv": [
337
+ "Aku mlaku adoh ing pantai nalika srengenge alon-alon mudhun ing ngisor cakrawala, lan aku mikir babagan kabeh kenangan sing wis tak kumpulake ing kene sajrone taun-taun.",
338
+ "Manuk-manuk wiwit nyanyi lan ombak-ombak dadi tentrem, menehi kabeh rasa tentrem lan ketenangan."
339
+ ]
340
+ },
341
+ "Georgian": {
342
+ "ka": [
343
+ "დიდი გასეირნება გავაკეთე სანაპიროზე, როცა მზე ნელ-ნელა ჩადიოდა ჰორიზონტის ქვეშ და ვფიქრობდი იმ ყველაფერზე, რაც ამ ადგილას ვაგროვე წლების განმავლობაში.",
344
+ "새들이 노래를 시작하고 파도가 잦아들어 모든 것에 평화와 평온의 느낌을 주었습니다."
345
+ ]
346
+ },
347
+ "Kazakh": {
348
+ "kk": [
349
+ "Мен жағажайда ұзақ серуендедім, күн горизонттың астына баяу түсіп бара жатты, мен осы жерде жылдар бойы жинаған барлық естеліктерімді ойладым.",
350
+ "Құстар ән сала бастады, ал толқындар тынышталды, бәріне тыныштық пен бейбітшіліктің сезімін сыйлады."
351
+ ]
352
+ },
353
+ "Central Khmer": {
354
+ "km": [
355
+ "ខ្ញុំបានធ្វើការហូបបែបយូរនៅឆ្នេរ ខណៈពេលព្រះអាទិត្យបានលិចតាមផ្លូវធនធានយ៉ាងល្អ ហើយខ្ញុំបានគិតអំពីអង្គការជាច្រើនដែលខ្ញុំបានបន្សល់ទុកនៅទីនេះក្នុងរយៈពេលជាច្រើនឆ្នាំ។",
356
+ "សត្វពពួកបានចាប់ផ្តើមច្រៀង ហើយការចុះឡើងនៃស្ទូចបានឧបត្ថម្ភឱ្យទាំងអស់នូវអារម្មណ៍សន្តិភាព និងការស្ងប់ស្ងាត់។"
357
+ ]
358
+ },
359
+ "Kannada": {
360
+ "kn": [
361
+ "ಸೂರ್ಯ ಹಾರಿಜಾನ್ ಕೆಳಗೆ ನಿಧಾನವಾಗಿ ಮರೆಯಾಗುವಾಗ ನಾನು ಕಡಲ ತೀರದಲ್ಲಿ longues ನಡೆಯಿತು ಮತ್ತು ನಾನು ಇಲ್ಲಿ ವರ್ಷಗಳ ಕಾಲ ಕಟ್ಟಿಸಿದ ಎಲ್ಲಾ ನೆನಪುಗಳನ್ನು ಯೋಚಿಸುತ್ತಿದ್ದೇನೆ.",
362
+ "ಹಕ್ಕಿಗಳು ಹಾಡಲು ಆರಂಭಿಸವು ಮತ್ತು ತಿರುವುಗಳು ಶಾಂತವಾಗುತ್ತವೆ, ಎಲ್ಲಿಗೊ ಶಾಂತಿ ಮತ್ತು ಶಾಂತಿಯ ಅನುಭವವನ್ನು ನೀಡುತ್ತದೆ."
363
+ ]
364
+ },
365
+ "Korean": {
366
+ "ko": [
367
+ "해가 수평선 아래로 천천히 지는 동안 해변을 따라 긴 산책을 하며 수년 동안 여기서 쌓아온 모든 추억을 생각했습니다.",
368
+ "새들이 노래를 부르기 시작했고 파도가 잦아들어 모든 것에 평화롭고 고요한 느낌을 주었습니다."
369
+ ]
370
+ },
371
+ "Luxembourgish": {
372
+ "lb": [
373
+ "Ech hunn eng laang Spazéiergang laanscht de Strad gemaach, während d'Sonn lues ënner de Horizont gesinckt ass, an ech hunn iwwer all d'Erënnerungen geduecht, déi ech hei iwwer d'Jore gesincht hunn.",
374
+ "D'Villercher hunn ugefaang ze sangen an d'Wellen hunn sech berouegt, wat allem e Gefill vu Fridden an Éischter ginn huet."
375
+ ]
376
+ },
377
+ "Ganda": {
378
+ "lg": [
379
+ "Nafunye okwanguwangu ogumu ku nnyanja ng’akabirye kakyali wansi w’okuze obudde, ate nze nakirumba ku nsonga zonna ezandibaddemu mu myaka.",
380
+ "Ekitenga kyatandika okutaabula, ate obwato bubadde butonotwa, obugamba buli kintu okwambalirira amagezi n’obulamu."
381
+ ]
382
+ },
383
+ "Lingala": {
384
+ "ln": [
385
+ "Nayaki na ndelo mpenza na mboka ya nkanda, tango soleil ebataki butu na mbuma ya horizon, nakomi kokanisa malamu na masolo nyonso nakokoti na libanda oyo na mikolo.",
386
+ "Biyaya bayei na masolo na yango mpe biloko esili kokola, ekeseni nyonso na esengo mpe po."
387
+ ]
388
+ },
389
+ "Lao": {
390
+ "lo": [
391
+ "ຂໍ່ານແລະຄະນາດໃນທະບອງແລະເຂົ້າບ້ານເຂົ້າໄປໃນການປ່ອນຜ້ອມຂອງຊິວິດ, ເວົ້າຂອງສະຄອລະນໃຊໃບເປີນໄວ້ຄວາມຮູ້ສຶກສະເມີນລະບົບບອດປະສົມ.",
392
+ "ສະບອຍໄດ້ເປົ້າເສັງເປິເຕັດລະວີບອງຕະລົງລະບົບຄວາມສະມເປີນ."
393
+ ]
394
+ },
395
+ "Lithuanian": {
396
+ "lt": [
397
+ "Aš nuėjau ilgą pasivaikščiojimą palei paplūdimį, kai saulė lėtai leidosi žemiau horizonto, ir galvojau apie visus prisiminimus, kuriuos sukaupiau čia per metus.",
398
+ "Paukščiai pradėjo dainuoti, o bangos nurimo, suteikdamos viskam ramybės ir ramybės jausmą."
399
+ ]
400
+ },
401
+ "Latvian": {
402
+ "lv": [
403
+ "Es devos garā pastaigā pa pludmali, kamēr saule pakāpeniski rieta zem horizonta, un domāju par visiem atmiņām, kuras es esmu savācis šeit gadu gaitā.",
404
+ "Putni sāk dziedāt un viļņi nomierinājās, piešķirot visam mieru un klusuma sajūtu."
405
+ ]
406
+ },
407
+ "Malagasy": {
408
+ "mg": [
409
+ "Nandeha nandeha nanodidina ny morontsiraka aho, raha ny masoandro mihena tsikelikely any ambanin'ny tendrombohitra, ary nieritreritra ny rehetra ireo fahatsiarovana azoko nandritra ny taona.",
410
+ "Nanomboka nanao hira ny vorona ary nihena ny onja, manome ny zava-drehetra fihetseham-po fiadanana sy fialam-boly."
411
+ ]
412
+ },
413
+ "Macedonian": {
414
+ "mk": [
415
+ "Направив долга прошетка покрај плажата додека сонцето полека се спушташе под хоризонтот и размислував за сите спомени што ги собрав тука низ годините.",
416
+ "Птиците започнаа да пеат и брановите се смирија, што му даде на сè чувство на мир и спокојство."
417
+ ]
418
+ },
419
+ "Malay": {
420
+ "ms": [
421
+ "Saya melakukan perjalanan panjang di pantai sementara matahari perlahan tenggelam di bawah cakrawala, dan saya memikirkan semua kenangan yang telah saya kumpulkan di sini selama bertahun-tahun.",
422
+ "Burung-burung mula bernyanyi dan ombak menjadi tenang, memberikan rasa damai dan ketenangan kepada segala-galanya."
423
+ ]
424
+ },
425
+ "Mongolian": {
426
+ "mn": [
427
+ "Нар уран туулж байхад би эрэг дээр удаан алхаж байсан бөгөөд олон жилийн турш цуглуулсан бүх дурсамжуудаа бодож байсан.",
428
+ "Шувууд дуугаа хурааж эхлээд давалгаа намжиж, бүх зүйлд амар тайвны мэдрэмжийг өгсөн."
429
+ ]
430
+ },
431
+ "Nepali": {
432
+ "ne": [
433
+ "सूर्यलाई आकाशको क्षितिजमुनि थोरै थोरै झर्नुहुँदा म समुद्रको तटमा लामो हिँडाइ गरें र यहाँका सबै सम्झनाहरूको बारेमा सोचें, जुन मैले यहाँका वर्षहरूमा संकलन गरेको थिएँ।",
434
+ "पक्षीहरूले गाउन थाले र लहरहरू शान्त भए, जसले सबैलाई शान्ति र शान्तिको अनुभव गरायो।"
435
+ ]
436
+ },
437
+ "Norwegian": {
438
+ "no": [
439
+ "Jeg tok en lang spasertur langs stranden mens solen sakte gikk ned under horisonten, og jeg tenkte på alle minnene jeg har samlet her gjennom årene.",
440
+ "Fuglene begynte å synge, og bølgene roet seg, og ga alt en følelse av fred og ro."
441
+ ]
442
+ },
443
+ "Oromo": {
444
+ "om": [
445
+ "Galgala dheeraa lafa qilleensaa tajaajiluu fi aduu gaafa haxaa haxa’a jala gad hafuura, yaadaan kan qophaawaa seenaa waliin waan ta’e.",
446
+ "Furnoon kan akka dammaqamuu eega jalqabu fi onganni akka qabamuu argachuu gammachuun tahuu."
447
+ ]
448
+ },
449
+ "Pashto": {
450
+ "ps": [
451
+ "ما د ساحل په اوږدو کې اوږد ځغل وکړ، په داسې حال کې چې لمر ورو ورو د افق لاندې لاړ، او ما د ټولو یادونو په اړه فکر وکړ چې ما دلته د کلونو په اوږدو کې راټول کړي وو.",
452
+ "پرندګان د ګانو پیل کړل او لندې خاموش شوې، چې هرڅه ته د سولې او سکون احساس ورکړ."
453
+ ]
454
+ },
455
+ "Punjabi": {
456
+ "pa": [
457
+ "ਮੈਂ ਸੂਰੇਜ ਨੂੰ ਹੌਲੀ-ਹੌਲੀ ਹੋਰੀਜ਼ਨ ਦੇ ਹੇਠਾਂ ਡੁਬਦੇ ਦੇਖਦੇ ਹੋਏ ਸਮੁੰਦਰ ਦੇ ਕਿਨਾਰੇ ਲੰਬੀ ਸੈਰ ਕੀਤੀ ਅਤੇ ਸੋਚਿਆ ਕਿ ਮੈਂ ਇੱਥੇ ਸਾਲਾਂ ਵਿਚ ਇਕੱਠੇ ਕੀਤੇ ਸਾਰੇ ਯਾਦਾਂ ਬਾਰੇ ਸੋਚਿਆ।",
458
+ "ਪੰਛੀਆਂ ਨੇ ਗਾਉਣਾ ਸ਼ੁਰੂ ਕੀਤਾ ਅਤੇ ਲਹਿਰਾਂ ਸ਼ਾਂਤ ਹੋ ਗਈਆਂ, ਜਿਸ ਨਾਲ ਸਾਰਿਆਂ ਨੂੰ ਅਮਨ ਅਤੇ ਸ਼ਾਂਤੀ ਦਾ ਅਹਿਸਾਸ ਹੋਇਆ।"
459
+ ]
460
+ },
461
+ "Quechua": {
462
+ "qu": [
463
+ "Ñawi urqu t'ikraykuñamanta chikninqa, chisqayku runakuna wanuyniy, qhapaq ñawi kuska suyuy.",
464
+ "Warmi puriykuypaq, quchañiqmi, taytakuy yachaykuna."
465
+ ]
466
+ },
467
+ "Romanian": {
468
+ "ro": [
469
+ "Am făcut o lungă plimbare pe plajă în timp ce soarele cobora încet sub orizont și m-am gândit la toate amintirile pe care le-am adunat aici de-a lungul anilor.",
470
+ "Păsările au început să cânte și valurile s-au liniștit, oferind totului un sentiment de pace și liniște."
471
+ ]
472
+ },
473
+ "Russian": {
474
+ "ru": [
475
+ "Я совершил долгую прогулку по пляжу, пока солнце медленно садилось за горизонт, и думал обо всех воспоминаниях, которые я накопил здесь за эти годы.",
476
+ "Птицы начали петь, и волны успокоились, придавая всему ощущение мира и покоя."
477
+ ]
478
+ },
479
+ "Samoan": {
480
+ "sm": [
481
+ "Na ou faia se savaliga umi i le matafaga i le taimi o le la e slowly malie i lalo o le horison, ma ou manatu i uma i le taunuʻuga na ou aofia iinei i tausaga.",
482
+ "O le fa'amalie e amata ona to'afa ma fa'ata'ita'iga e fa'amalie, e fa'ataga ai mea uma i se lagona o le filemu ma le susu."
483
+ ]
484
+ },
485
+ "Serbo-Croatian": {
486
+ "sh": [
487
+ "Išao sam na dugu šetnju obalom plaže dok je sunce polako zalazilo ispod horizonta i razmišljao o svim uspomenama koje sam prikupio ovde tokom godina.",
488
+ "Ptice su počele da pevaju i talasi su se smirili, dajući svemu osećaj mira i tišine."
489
+ ]
490
+ },
491
+ "Swahili": {
492
+ "sw": [
493
+ "Nilifanya matembezi marefu kando ya pwani wakati jua lilipokuwa likitua polepole chini ya upeo wa macho, na nikafikiria kuhusu kumbukumbu zote nilizokusanya hapa kwa miaka mingi.",
494
+ "Ndege walianza kuimba na mawimbi yakapungua, ikitoa kila kitu hisia ya amani na utulivu."
495
+ ]
496
+ },
497
+ "Sundanese": {
498
+ "su": [
499
+ "Kuring ngalakukeun leumpang panjang di pantai nalika panonpoé sacara laun turun di handap cakrawala, sareng kuring mikirkeun sagala kenangan anu parantos kuring kumpulkeun di dieu salami taun-taun.",
500
+ "Manuk-manuk mimiti nyanyi sareng ombak-ombak tenang, masihan sakabehna rasa damai sareng ketenangan."
501
+ ]
502
+ },
503
+ "Swedish": {
504
+ "sv": [
505
+ "Jag tog en lång promenad längs stranden medan solen långsamt gick ner under horisonten, och jag tänkte på alla minnen jag har samlat här genom åren.",
506
+ "Fåglarna började sjunga och vågorna lugnade sig, vilket gav allt en känsla av fred och ro."
507
+ ]
508
+ },
509
+ "Tagalog": {
510
+ "tl": [
511
+ "Naglakad ako ng mahaba sa tabing-dagat habang ang araw ay dahan-dahang lumulubog sa ilalim ng horizon, at iniisip ko ang lahat ng mga alaala na aking naipon dito sa mga taon.",
512
+ "Nagsimulang kumanta ang mga ibon at humupa ang mga alon, na nagbigay sa lahat ng pakiramdam ng kapayapaan at katahimikan."
513
+ ]
514
+ },
515
+ "Tamil": {
516
+ "ta": [
517
+ "சூரியன் நிலையின் கீழே மெதுவாக கீழே செல்கின்றபோது, கடற்கரையில் நீண்ட நடைபயணம் செய்தேன், மற்றும் நான் இங்கு பல வருடங்களுக்கு சேகரித்த அனைத்து நினைவுகளைப் பற்றியதைப் பற்றிக் கவனித்தேன்.",
518
+ "பறவைகள் பாட ஆரம்பித்தன, மற்றும் அலைகள் அமைதியாகக் கிடந்தன, இது ஒவ்வொன்றுக்கும் அமைதி மற்றும் அமைதியின் உணர்வை அளித்தது."
519
+ ]
520
+ },
521
+ "Tajik": {
522
+ "tg": [
523
+ "Ман дар соҳили баҳр як сафари тӯлонӣ анҷом додам, дар ҳоле ки офтоб ба тадриҷ зери нишебии гармии соя мерафт, ва ��ан ба ҳамаи ёдгориҳое, ки ман дар ин ҷо дар тӯли солҳо ҷамъ оварда будам, фикр кардам.",
524
+ "Паррандагон ба овоз оварданд ва мавҷҳо ором шуданд, ки ба ҳама эҳсоси осоиштагӣ ва осоишро бахшид."
525
+ ]
526
+ },
527
+ "Telugu": {
528
+ "te": [
529
+ "సూర్యుడు ఆఫిజన్ కింద క్షీణిస్తున్నప్పుడు, నేను ముద్రగని సవాలు చేశాను మరియు సంవత్సరాలుగా నేను ఇక్కడ సేకరించిన అన్ని జ్ఞాపకాలను గుర్తు చేసాను.",
530
+ "పక్షులు పాడడం మొదలుపెట్టాయి మరియు అలలు మెల్లగా పోయాయి, అందరికీ శాంతి మరియు ప్రశాంతత యొక్క అనుభూతిని ఇచ్చాయి."
531
+ ]
532
+ },
533
+ "Thai": {
534
+ "th": [
535
+ "ฉันเดินเล่นนาน ๆ ริมชายหาด ขณะที่ดวงอาทิตย์ค่อย ๆ ลับขอบฟ้า และคิดถึงความทรงจำทั้งหมดที่ฉันได้สะสมไว้ที่นี่ตลอดหลายปีที่ผ่านมา",
536
+ "นกเริ่มร้องเพลงและคลื่นสงบลง ทำให้ทุกสิ่งรู้สึกถึงความสงบและความสงบสุข"
537
+ ]
538
+ },
539
+ "Turkish": {
540
+ "tr": [
541
+ "Güneş ufkun altına yavaşça batarken plajda uzun bir yürüyüş yaptım ve yıllar içinde burada biriktirdiğim tüm anıları düşündüm.",
542
+ "Kuşlar şarkı söylemeye başladı ve dalgalar sakinleşti, her şeye huzur ve dinginlik hissi verdi."
543
+ ]
544
+ },
545
+ "Urdu": {
546
+ "ur": [
547
+ "میں ساحل پر لمبے راستے پر چلتا رہا، سورج آہستہ آہستہ افق کی طرف جا رہا تھا، اور میں نے یہاں سالوں کے دوران جمع کی گئی تمام یادوں کے بارے میں سوچا۔",
548
+ "پرندے گانا شروع ہوگئے اور لہریں پر سکون ہو گئیں، سب کو سکون اور آرام کی حس دی۔"
549
+ ]
550
+ },
551
+ "Ukrainian": {
552
+ "uk": [
553
+ "Я зробив довгу прогулянку пляжем, поки сонце повільно опускалося за горизонт, і думав про всі спогади, які я зібрав тут протягом років.",
554
+ "Птахи почали співати, а хвилі заспокоїлися, надаючи всьому відчуття спокою і умиротворення."
555
+ ]
556
+ },
557
+ "Uzbek": {
558
+ "uz": [
559
+ "Men plyaj bo'ylab uzoq yurish qildim, quyosh sekinlik bilan ufqqa tushayotgan vaqtda, va men bu erda yillar davomida to'plagan barcha xotiralarni o'yladim.",
560
+ "Qushlar qo'shiq ayta boshladilar va to'lqinlar tinchlandi, barchaga tinchlik va osoyishtalik hissini berdilar."
561
+ ]
562
+ },
563
+ "Vietnamese": {
564
+ "vi": [
565
+ "Tôi đã đi dạo dài dọc theo bãi biển trong khi mặt trời từ từ lặn xuống dưới chân trời và suy nghĩ về tất cả những kỷ niệm mà tôi đã tích lũy được ở đây trong nhiều năm qua.",
566
+ "Những con chim bắt đầu hát và những con sóng trở nên yên lặng, mang đến cho tất cả mọi thứ cảm giác bình yên và tĩnh lặng."
567
+ ]
568
+ },
569
+ "Wolof": {
570
+ "wo": [
571
+ "J'ai fait une longue promenade sur la plage pendant que le soleil se couchait lentement sous l'horizon, et j'ai pensé à tous les souvenirs que j'ai accumulés ici au fil des ans.",
572
+ "Les oiseaux ont commencé à chanter et les vagues se sont calmées, apportant à tout un sentiment de paix et de tranquillité."
573
+ ]
574
+ },
575
+ "Xhosa": {
576
+ "xh": [
577
+ "Ndihambe ibhude elide ngasemlanjeni ngelixa ilanga lihlala kancinci phantsi komphosa, ndacinga ngazo zonke izikhumbuzo endizibambileyo apha kwiminyaka.",
578
+ "Izinyoni zaqala ukuvuma kwaye amagagasi athule, ekhupha yonke into umoya wokuthula nokuqonda."
579
+ ]
580
+ },
581
+ "Yiddish": {
582
+ "yi": [
583
+ "איך האָב אַ לאַנג גאַנג נעבן דער ים געמאכט בעת דעם זון איז אין באַשיידן אונטערן ערד האָריזאָן, און איך האָב געדאַנקען וועגן אַלע די ערינערונגען וואָס איך האָבן געזאַמלט דאָ איבער די יאָרן.",
584
+ "די סינגערס האָבן אָנגעהויבן צו זינגן און די לויפן האָבן זיך געשווינד, געגעבן אַלען אַן ערפאַרונג פון שלום און שטילקייט."
585
+ ]
586
+ },
587
+ "Yoruba": {
588
+ "yo": [
589
+ "Mo ṣe irin-ajo gigun ni etí okun nigba ti oorun n lọ sẹ́gbẹ̀ẹ́ ìkànsí, àti pe mo rò nípa gbogbo àwọn ìrántí tí mo ti kó jọ níbí nípasẹ̀ àwọn ọdún.",
590
+ "Awọn ẹyẹ bẹ̀rẹ̀ sí kọ orin ati awọn igbi omi dinku, fifun gbogbo nkan ni iriri ti alaafia ati ìkànsí."
591
+ ]
592
+ },
593
+ "Chinese": {
594
+ "zh": [
595
+ "我在海滩上长时间散步,太阳缓缓落下地平线时,我思考了这些年来在这里积累的所有回忆。",
596
+ "鸟儿开始歌唱,海浪变得平静,为一切带来了和平与宁静的感觉。"
597
+ ]
598
+ },
599
+ "Zulu": {
600
+ "zu": [
601
+ "Ngihambe ibanga elide eceleni kolwandle ngesikhathi ilanga lihamba kancane phansi komkhawulo, ngacabanga ngazo zonke izinkumbulo engizibhalile lapha eminyakeni edlule.",
602
+ "Izinyoni zaqala ukuvuma futhi amagagasi athule, okwenza yonke into ibe nomuzwa wokuthula nokuthula."
603
+ ]
604
+ }
605
+ }
606
+
607
+ # Mapping language names to their codes
608
+ languages = {name: code for name, codes in language_map.items() for code in codes}
609
+
610
+ # Sidebar for Language Selection
611
+ st.sidebar.title("Language Selection")
612
+
613
+ # Selecting the "Translate From" language
614
+ from_language_name = st.sidebar.selectbox("Translate From", list(language_map.keys()))
615
+ from_language_code = next(iter(language_map[from_language_name].keys()))
616
+
617
+ # Logic to handle translation direction
618
+ if from_language_name == 'English':
619
+ to_language_name = st.sidebar.selectbox(
620
+ "Translate To",
621
+ [name for name in language_map.keys() if name != 'English']
622
+ )
623
+ else:
624
+ to_language_name = st.sidebar.selectbox(
625
+ "Translate To",
626
+ ['English'] + [name for name in language_map.keys() if name != from_language_name]
627
+ )
628
+
629
+ # Get the corresponding language code for the selected "Translate To" language
630
+ to_language_code = next(iter(language_map[to_language_name].keys()))
631
+
632
+ # Select model
633
+ model = st.sidebar.selectbox(
634
+ "Choose the pretrained model",
635
+ ["m2m100_1.2B"],
636
+ help="For more info about the models visit: https://sparknlp.org/models"
637
+ )
638
+
639
+ # Display the Selected Language and Sentence
640
+ st.write(f"**Translating From:** {from_language_name} ({from_language_code}) **To:** {to_language_name} ({to_language_code})")
641
+
642
+ # Reference Notebook Link in Sidebar
643
+ link= """<a href="https://colab.research.google.com/github/JohnSnowLabs/spark-nlp-workshop/blob/master/tutorials/streamlit_notebooks/TRANSLATION_MARIAN.ipynb"><img src="https://colab.research.google.com/assets/colab-badge.svg" style="zoom: 1.3" alt="Open In Colab"/></a>"""
644
+ st.sidebar.markdown('Reference notebook:')
645
+ st.sidebar.markdown(link, unsafe_allow_html=True)
646
+
647
+ # Load Sample Texts for the "Translate From" language
648
+ examples = language_map[from_language_name][from_language_code]
649
+
650
+ selected_text = st.selectbox("Select a Sample Text", examples)
651
+ custom_input = st.text_input("Try it for yourself!")
652
+
653
+ if custom_input:
654
+ selected_text = custom_input
655
+
656
+ # Display the Selected or Entered Text
657
+ st.subheader('Selected Text')
658
+ st.write(selected_text)
659
+
660
+ # Perform Translation and Display the Result
661
+ st.subheader("Translation Result")
662
+
663
+ spark = init_spark()
664
+ pipeline = create_pipeline(model, from_language_code, to_language_code)
665
+ output = fit_data(pipeline, selected_text)
666
+
667
+ res = "".join(output[0][0])
668
+ HTML_WRAPPER = """<div class="scroll entities" style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem; white-space:pre-wrap">{}</div>"""
669
+ st.markdown(HTML_WRAPPER.format(res), unsafe_allow_html=True)
670
+
671
+
Dockerfile ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Download base image ubuntu 18.04
2
+ FROM ubuntu:18.04
3
+
4
+ # Set environment variables
5
+ ENV NB_USER jovyan
6
+ ENV NB_UID 1000
7
+ ENV HOME /home/${NB_USER}
8
+ ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
9
+
10
+ # Install required packages
11
+ RUN apt-get update && apt-get install -y \
12
+ tar \
13
+ wget \
14
+ bash \
15
+ rsync \
16
+ gcc \
17
+ libfreetype6-dev \
18
+ libhdf5-serial-dev \
19
+ libpng-dev \
20
+ libzmq3-dev \
21
+ python3 \
22
+ python3-dev \
23
+ python3-pip \
24
+ unzip \
25
+ pkg-config \
26
+ software-properties-common \
27
+ graphviz \
28
+ openjdk-8-jdk \
29
+ ant \
30
+ ca-certificates-java \
31
+ && apt-get clean \
32
+ && update-ca-certificates -f
33
+
34
+ # Install Python 3.8 and pip
35
+ RUN add-apt-repository ppa:deadsnakes/ppa \
36
+ && apt-get update \
37
+ && apt-get install -y python3.8 python3-pip \
38
+ && apt-get clean
39
+
40
+ # Set up JAVA_HOME
41
+ RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/" >> /etc/profile \
42
+ && echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile
43
+ # Create a new user named "jovyan" with user ID 1000
44
+ RUN useradd -m -u ${NB_UID} ${NB_USER}
45
+
46
+ # Switch to the "jovyan" user
47
+ USER ${NB_USER}
48
+
49
+ # Set home and path variables for the user
50
+ ENV HOME=/home/${NB_USER} \
51
+ PATH=/home/${NB_USER}/.local/bin:$PATH
52
+
53
+ # Set up PySpark to use Python 3.8 for both driver and workers
54
+ ENV PYSPARK_PYTHON=/usr/bin/python3.8
55
+ ENV PYSPARK_DRIVER_PYTHON=/usr/bin/python3.8
56
+
57
+ # Set the working directory to the user's home directory
58
+ WORKDIR ${HOME}
59
+
60
+ # Upgrade pip and install Python dependencies
61
+ RUN python3.8 -m pip install --upgrade pip
62
+ COPY requirements.txt /tmp/requirements.txt
63
+ RUN python3.8 -m pip install -r /tmp/requirements.txt
64
+
65
+ # Copy the application code into the container at /home/jovyan
66
+ COPY --chown=${NB_USER}:${NB_USER} . ${HOME}
67
+
68
+ # Expose port for Streamlit
69
+ EXPOSE 7860
70
+
71
+ # Define the entry point for the container
72
+ ENTRYPOINT ["streamlit", "run", "Demo.py", "--server.port=7860", "--server.address=0.0.0.0"]
pages/Workflow & Model Overview.py ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Custom CSS for Styling
4
+ st.markdown("""
5
+ <style>
6
+ .main-title {
7
+ font-size: 36px;
8
+ color: #4A90E2;
9
+ font-weight: bold;
10
+ text-align: center;
11
+ }
12
+ .sub-title {
13
+ font-size: 24px;
14
+ color: #4A90E2;
15
+ margin-top: 20px;
16
+ }
17
+ .section {
18
+ background-color: #f9f9f9;
19
+ padding: 15px;
20
+ border-radius: 10px;
21
+ margin-top: 20px;
22
+ }
23
+ .section p, .section ul {
24
+ color: #666666;
25
+ }
26
+ .link {
27
+ color: #4A90E2;
28
+ text-decoration: none;
29
+ }
30
+ h2 {
31
+ color: #4A90E2;
32
+ font-size: 28px;
33
+ margin-top: 30px;
34
+ }
35
+ h3 {
36
+ color: #4A90E2;
37
+ font-size: 22px;
38
+ margin-top: 20px;
39
+ }
40
+ h4 {
41
+ color: #4A90E2;
42
+ font-size: 18px;
43
+ margin-top: 15px;
44
+ }
45
+ </style>
46
+ """, unsafe_allow_html=True)
47
+
48
+ # Main Title
49
+ st.markdown('<div class="main-title">Many-to-Many Multilingual Translation Model (Facebook M2M100)</div>', unsafe_allow_html=True)
50
+
51
+ # Overview Section
52
+ st.markdown("""
53
+ <div class="section">
54
+ <p>The <strong>M2M100</strong> model, introduced in the paper <strong>Beyond English-Centric Multilingual Machine Translation</strong> by Angela Fan et al., represents a significant advancement in multilingual machine translation. Unlike many previous models that were primarily English-centric, M2M100 is designed to handle translation tasks directly between any pair of 100 languages without relying on English as an intermediary.</p>
55
+ <p>This model leverages a large-scale multilingual dataset to ensure high-quality translations across a broad spectrum of languages, providing a more inclusive solution for global communication needs.</p>
56
+ </div>
57
+ """, unsafe_allow_html=True)
58
+
59
+ # Introduction to M2M100
60
+ st.markdown('<div class="sub-title">What is M2M100?</div>', unsafe_allow_html=True)
61
+
62
+ # What is M2M100?
63
+ st.markdown("""
64
+ <div class="section">
65
+ <p>The M2M100 model is a groundbreaking multilingual encoder-decoder model developed by Facebook AI Research. It supports direct translations between 100 languages, covering 9,900 possible language pairs. This eliminates the need for English as an intermediary, which is a common bottleneck in many translation systems.</p>
66
+ <p>M2M100 is built to handle diverse language pairs efficiently, making it particularly useful for applications requiring translations across less commonly spoken languages that might not have extensive English-language resources.</p>
67
+ </div>
68
+ """, unsafe_allow_html=True)
69
+
70
+ # Pipeline and Results
71
+ st.markdown('<div class="sub-title">Pipeline and Results</div>', unsafe_allow_html=True)
72
+
73
+ st.markdown("""
74
+ <div class="section">
75
+ <p>This section will guide you through setting up the M2M100 model within Spark NLP for multilingual translation tasks. We will cover the steps from creating the data to assembling the pipeline and viewing the results.</p>
76
+ </div>
77
+ """, unsafe_allow_html=True)
78
+
79
+ # Step 1: Creating the Data
80
+ st.markdown("""
81
+ <div class="section">
82
+ <h4>Step 1: Creating the Data</h4>
83
+ <p>Start by creating a Spark DataFrame containing the text you wish to translate. For example, we will prepare a DataFrame with some sample English text to translate into Chinese.</p>
84
+ """, unsafe_allow_html=True)
85
+
86
+ st.code("""
87
+ data = [["Hello, how are you?"]]
88
+ df = spark.createDataFrame(data).toDF("text")
89
+ """, language="python")
90
+
91
+ # Step 2: Assembling the Pipeline
92
+ st.markdown("""
93
+ <div class="section">
94
+ <h4>Step 2: Assembling the Pipeline</h4>
95
+ <p>Next, set up a Spark NLP pipeline that includes a document assembler and the M2M100 model for translation. The pipeline will process the input text and generate the translated output.</p>
96
+ """, unsafe_allow_html=True)
97
+
98
+ st.code("""
99
+ from sparknlp.base import *
100
+ from sparknlp.annotator import *
101
+ from pyspark.ml import Pipeline
102
+
103
+ # Define the Document Assembler
104
+ document_assembler = DocumentAssembler()\\
105
+ .setInputCol("text")\\
106
+ .setOutputCol("documents")
107
+
108
+ # Load the M2M100 model
109
+ m2m100 = M2M100Transformer.pretrained("m2m100_1.2B", "xx")\\
110
+ .setInputCols(["documents"])\\
111
+ .setMaxOutputLength(50)\\
112
+ .setOutputCol("generation")\\
113
+ .setSrcLang("en")\\
114
+ .setTgtLang("zh")
115
+
116
+ # Assemble the Pipeline
117
+ pipeline = Pipeline().setStages([document_assembler, m2m100])
118
+ model = pipeline.fit(df)
119
+ result = model.transform(df)
120
+ """, language="python")
121
+
122
+ # Step 3: Viewing the Results
123
+ st.markdown("""
124
+ <div class="section">
125
+ <h4>Step 3: Viewing the Results</h4>
126
+ <p>Once the pipeline has processed the input data, you can view the translated text generated by the M2M100 model. The results show the translation of the input English text into Chinese.</p>
127
+ """, unsafe_allow_html=True)
128
+
129
+ st.code("""
130
+ result.select("generation.result").show(truncate=False)
131
+ """, language="python")
132
+
133
+ st.text("""
134
+ +--------------+
135
+ |result |
136
+ +--------------+
137
+ |[你好,你好吗?] |
138
+ +--------------+
139
+ """)
140
+
141
+ # Model Information and Use Cases
142
+ st.markdown("""
143
+ <div class="section">
144
+ <h4>Model Information and Use Cases</h4>
145
+ <p>The M2M100 model offers extensive capabilities for multilingual translation. Here’s a quick overview:</p>
146
+ <ul>
147
+ <li><b>Model Name:</b> m2m100_1.2B</li>
148
+ <li><b>Languages Supported:</b> 100 languages (9,900 possible translation directions)</li>
149
+ <li><b>Best for:</b> High-quality translations between diverse language pairs without relying on English as a pivot</li>
150
+ <li><b>Compatibility:</b> Spark NLP 5.3.0+</li>
151
+ </ul>
152
+ </div>
153
+ """, unsafe_allow_html=True)
154
+
155
+ # Conclusion
156
+ st.markdown("""
157
+ <div class="section">
158
+ <h4>Conclusion</h4>
159
+ <p>The M2M100 model represents a significant step forward in multilingual translation technology. By supporting direct translations between 100 languages, it provides a more direct and inclusive approach to global communication. Its integration with Spark NLP allows for scalable and efficient translation workflows, and the support for ONNX enhances its interoperability and deployment options.</p>
160
+ </div>
161
+ """, unsafe_allow_html=True)
162
+
163
+ # References
164
+ st.markdown("""
165
+ <div class="section">
166
+ <h4>References</h4>
167
+ <ul>
168
+ <li>Model Documentation: <a class="link" href="https://sparknlp.org/models" target="_blank">Spark NLP Models</a></li>
169
+ <li>M2M100 Paper: <a class="link" href="https://arxiv.org/abs/2010.11934" target="_blank">Beyond English-Centric Multilingual Machine Translation</a></li>
170
+ <li>Facebook AI Research: <a class="link" href="https://ai.facebook.com/" target="_blank">Facebook AI</a></li>
171
+ </ul>
172
+ </div>
173
+ """, unsafe_allow_html=True)
174
+
175
+ # Community & Support
176
+ st.markdown('<div class="sub-title">Community & Support</div>', unsafe_allow_html=True)
177
+ st.markdown("""
178
+ <div class="section">
179
+ <ul>
180
+ <li><a class="link" href="https://sparknlp.org/" target="_blank">Official Website</a>: Documentation and examples</li>
181
+ <li><a class="link" href="https://join.slack.com/t/spark-nlp/shared_invite/zt-198dipu77-L3UWNe_AJ8xqDk0ivmih5Q" target="_blank">Slack</a>: Live discussion with the community and team</li>
182
+ <li><a class="link" href="https://github.com/JohnSnowLabs/spark-nlp" target="_blank">GitHub</a>: Bug reports, feature requests, and contributions</li>
183
+ <li><a class="link" href="https://medium.com/spark-nlp" target="_blank">Medium</a>: Tutorials and articles</li>
184
+ </ul>
185
+ </div>
186
+ """, unsafe_allow_html=True)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ numpy
4
+ spark-nlp
5
+ pyspark