File size: 5,125 Bytes
ae7c243 7439772 ae7c243 04c2e43 b776334 6ba7298 7439772 683a07d b776334 cd7cb7e b776334 04c2e43 7439772 ae7c243 8e95c41 ae7c243 b776334 7439772 459afd1 d9ab0a3 7439772 b776334 8e95c41 77fd540 8e95c41 ae7c243 1962c0b ae7c243 7439772 ae7c243 8e95c41 6bb0b40 b776334 4c6968c 459afd1 d9ab0a3 ae7c243 b776334 8e95c41 52b62bc 8e95c41 ae7c243 1962c0b ae7c243 04c2e43 b776334 04c2e43 b776334 04c2e43 1962c0b 04c2e43 b776334 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# import streamlit as st
# from polish import polish_sentence_to_latin
# st.title("Language Transliteration Interface")
# input_string = st.text_input("Enter a Polish word/sentence to transliterate :")
# example1 = "Dziękuję bardzo!" # Example 1
# example2 = "Wszystkiego najlepszego!" # Example 2
# example3 = "Jarosław, Przemyśl"
# selected_example = st.selectbox('Choose an example as demo',
# ('None','Dziękuję bardzo!', 'Wszystkiego najlepszego!', 'Jarosław, Przemyśl'))
# if selected_example == 'Dziękuję bardzo!':
# input_string = 'Dziękuję bardzo!'
# elif selected_example == 'Wszystkiego najlepszego!':
# input_string = 'Wszystkiego najlepszego!'
# elif selected_example == 'Jarosław, Przemyśl':
# input_string = 'Jarosław, Przemyśl'
# else:
# input_string = input_string
# if st.button("Transliterate"):
# if input_string:
# output_string = polish_sentence_to_latin(input_string)
# st.subheader("Transliterated Output:")
# st.write(output_string)
# else:
# st.warning("Please enter a string.")
import streamlit as st
from polish import polish_sentence_to_latin
from hungarian import hungarian_sentence_to_latin
from turkish import turkish_sentence_to_latin
from essential_generators import DocumentGenerator
from googletrans import Translator
import re
from nltk.tokenize import word_tokenize
gen = DocumentGenerator()
translator = Translator()
def random_sentence(lang):
sentence=gen.sentence() #Generates a random but coherent sentence in English
return str(translator.translate(sentence,dest=lang).text) #Translates the sentence to target language
tab1, tab2, tab3= st.tabs(["Polish/Polski", "Hungarian/Magyar", "Turkish/Türkçe"])
with tab1:
st.header("Polish Transliteration")
input_string_polish = st.text_input("Enter a Polish word/sentence to transliterate:")
polish_examples = ['Dziękuję bardzo!', 'Wszystkiego najlepszego!', 'Jarosław, Przemyśl']
selected_example_po = st.selectbox('Choose an example as demo', ['None', "Generate a random sentence"] + polish_examples)
if selected_example_po != 'None':
input_string_polish = selected_example_po
if selected_example_po == "Generate a random sentence" :
input_string_polish = random_sentence('pl')
if st.button("Transliterate Polish"):
if input_string_polish:
output_string = polish_sentence_to_latin(input_string_polish)
st.subheader("Transliterated Output:")
if selected_example_po == "Generate a random sentence" :
st.write("Polish:"+input_string_polish+'\nOutput:'+output_string)
else:
st.write(output_string)
else:
st.warning("Please enter a string.")
with tab2:
st.header("Hungarian Transliteration")
input_string_hungarian = st.text_input("Enter a Hungarian word/sentence to transliterate:")
hungarian_examples = ['Köszönöm szépen!', 'Nagyon szépen köszönjük','Budapest, Magyarország']
selected_example_hu = st.selectbox('Choose an example as demo', ['None', "Generate a random sentence"] + hungarian_examples)
if selected_example_hu != 'None':
input_string_hungarian = selected_example_hu
if selected_example_hu == "Generate a random sentence" :
input_string_hungarian = random_sentence('hu')
if st.button("Transliterate Hungarian"):
if input_string_hungarian:
output_string = hungarian_sentence_to_latin(input_string_hungarian)
st.subheader("Transliterated Output:")
if selected_example_hu == "Generate a random sentence" :
st.write("Hungarian:"+input_string_hungarian+'\nOutput:'+output_string)
else:
st.write(output_string)
else:
st.warning("Please enter a string.")
with tab3:
st.header("Turkish Transliteration")
input_string_turkish = st.text_input("Enter a Turkish word/sentence to transliterate:")
turkish_examples = ["Müzik, ruhumuzu besler ve duygularımızı ifade etmemize yardımcı olur.", "İhtiyaçlarınıza uygun özel bir çözüm sunabiliriz",
"Türkiye'nin güzel şehirlerinden biri olan İstanbul'u ziyaret etmek istiyorum."]
selected_example_tu = st.selectbox('Choose an example as demo', ['None', "Generate a random sentence"] + turkish_examples)
if selected_example_tu != 'None':
input_string_turkish = selected_example_tu
if selected_example_tu == "Generate a random sentence" :
input_string_turkish = random_sentence('tr')
if st.button("Transliterate Turkish"):
if input_string_turkish:
output_string = turkish_sentence_to_latin(input_string_turkish)
st.subheader("Transliterated Output:")
if selected_example_tu == "Generate a random sentence" :
st.write("Turkish:"+input_string_turkish+'\nOutput:'+output_string)
else:
st.write(output_string)
else:
st.warning("Please enter a string.") |