File size: 2,696 Bytes
fc71123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65749c3
fc71123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import sys
import xmlrpc
from xmlrpc import client
import pandas as pd

# Title for the page and nice icon
st.set_page_config(page_title="Hindi-Sindhi MT Model", page_icon="🤖", layout='wide')
st.markdown("""
        <style> .block-container {
            padding-top: 1rem;
            padding-bottom: 0rem;
            padding-left: 5rem;
            padding-right: 5rem;
            }
        </style>
        """, unsafe_allow_html=True)
# Header
st.header("Machine Translation System - Hindi to Sindhi", divider='rainbow')
st.write("**-Developed at Speech and Language Processing Lab, Center for Artificial Intelligence, Banasthali Vidyapith. Sponsored by SERB, GoI, :flag-in:.**")

# ===========================================================================

def translate(source):
    proxy =  xmlrpc.client.ServerProxy("http://localhost:8083/RPC2")
    print(source)
    text_translate = proxy.translate({"text":source}) ["text"]
    print(text_translate)
    lst = text_translate.split("\n")
    src = source.split("\n")
    final_output = ''
    for i in lst:
        final_output += i + '\n'
    return final_output

# ===========================================================================


c1, c2 = st.columns(2)
element = c2.empty()

user_input = c1.text_area("Source Text", max_chars=200000, height=500)
output = element.text_area("Target Text", max_chars=200000, height=500)

translation = translate(user_input)

submitted = st.button("Translate")

if submitted:
    new_output = element.text_area('New Target Text', value=translation, height=500, max_chars=200000)
    

    
# +++++++++++++++++++++++ BOSS KA ORIGINAL CODE ++++++++++++++++++++++++++++++++

# def translate(source):
#     proxy =  xmlrpc.client.ServerProxy("http://172.16.40.175:8083/RPC2")
#     print(source)
#     text_translate = proxy.translate({"text":source}) ["text"]
#     print(text_translate)
#     lst = text_translate.split("\n")
#     src = source.split("\n")
#     df = pd.DataFrame()
#     df["Source"] = src
#     df["Translations"] = lst
#     return df


# with st.form("my_form"):
#     # Textarea to type the source text.
#     user_input = st.text_area("Source Text", max_chars=200000)
#     # Translate with CTranslate2 model
#     translation = translate(user_input)

#     # Create a button
#     submitted = st.form_submit_button("Translate")
#     # If the button pressed, print the translation
#     # Here, we use "st.info", but you can try "st.write", "st.code", or "st.success".
#     if submitted:
#         st.write("Translation")
#         st.dataframe(translation)

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++