-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
59 lines (42 loc) · 1.98 KB
/
app.py
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
import streamlit as st
from gurmukhiutils.converters.guru_latn import guru_latn
from gurmukhiutils.converters.guru_latn_pa import guru_latn_pa
from table import HTML
# Function to initialize session state
def init_session_state():
if 'input_data' not in st.session_state:
st.session_state['input_data'] = ""
st.session_state['input_data_text'] = ""
st.session_state['input_data_unicode'] = ""
st.session_state['guru_latn_result'] = ""
st.session_state['guru_latn_pa_result'] = ""
st.session_state['unicode_for_text'] = ""
st.session_state['unicode_result'] = ""
# Call the function to initialize session state
init_session_state()
# Streamlit app interface
st.title('Punjabi Language Gurmukhi Utils Interface')
text_user_input = st.text_input('Enter Text for Unicode', st.session_state['input_data_text'])
if st.button("Generate Unicode"):
st.session_state['unicode_for_text'] = ord(text_user_input)
st.write(f"Text for Unicode : {st.session_state['unicode_for_text']}")
unicode_user_input = st.text_input('Enter Unicode for Text', st.session_state['input_data_unicode'])
if st.button("Generate Text"):
st.session_state['unicode_result'] = chr(int(unicode_user_input))
st.write(f"Unicode for Text : {st.session_state['unicode_result']}")
# Input from user
user_input = st.text_input('Enter Punjabi Word', st.session_state['input_data'])
# Button to process the input
if st.button('Generate IPA'):
st.session_state['guru_latn_result'] = guru_latn(user_input)
st.session_state['guru_latn_pa_result'] = guru_latn_pa(user_input)
result_container = st.container()
with result_container:
col1, col2 = st.columns(2)
with col1:
st.write(f"ShabadOS recommended result : {st.session_state['guru_latn_result']}")
with col2:
st.write(f"Latest Punjabi IPA result : {st.session_state['guru_latn_pa_result']}")
st.text("IPA TABLE")
html_string = str(HTML)
st.markdown(html_string, unsafe_allow_html=True)