lilingxi01's picture
[UI] Optimize the informations in result box.
b4f5518
raw
history blame
1.79 kB
import streamlit as st
from datetime import datetime
from modules.prediction import prepare, predict
STATUS_STOPPED = 120001
STATUS_SUBMIT = 120002
STATUS_ERROR = 120003
has_prepared = False
st.session_state['running_status'] = STATUS_STOPPED
if not has_prepared:
print('>>> [PREPARE] Preparing...')
prepare()
has_prepared = True
st.title('Entity Referring Classifier')
st.caption('It knows exactly when you are calling it. - Version 2.0.1208.01')
st.markdown('---')
livedemo_col1, livedemo_col2, livedemo_col3 = st.columns([12,1,6])
with livedemo_col1:
st.subheader('Live Demo')
with st.form("my_form"):
entity = st.text_input('Entity Name:', 'Jimmy')
sentence = st.text_input('Sentence Input:', 'Are you feeling good, Jimmy?',
help='The classifier is going to analyze this sentence.')
if st.form_submit_button('πŸš€ Submit'):
st.session_state['running_status'] = STATUS_SUBMIT
if st.session_state['running_status'] == STATUS_STOPPED:
st.info('Type something and submit to start!')
elif st.session_state['running_status'] == STATUS_SUBMIT:
if predict(sentence, entity) == 'CALLING':
st.success('It is a **calling**!')
else:
st.success('It is a **mentioning**!')
st.caption(f'Submitted: `{sentence.lower()}` by `{datetime.now().strftime("%Y-%m-%d %H:%M:%S")}`')
with livedemo_col2:
st.empty()
with livedemo_col3:
st.markdown("""
#### Get Started
""")
st.markdown("""
Hi! I'm the Entity Referring Classifier.
I can help you find out when you are calling it.
""")
st.markdown("""
#### Terms
""")
st.markdown("""
##### `Calling`
""")
st.markdown("""
##### `Mentioning`
""")