File size: 2,170 Bytes
154ca7b
b4f5518
154ca7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ae1cd4
 
 
 
 
 
154ca7b
 
 
 
 
 
 
b4f5518
 
154ca7b
b4f5518
4ae1cd4
 
 
 
154ca7b
 
 
 
 
 
 
 
b4f5518
4ae1cd4
 
154ca7b
 
 
 
 
 
 
 
 
 
4ae1cd4
154ca7b
 
 
 
 
 
 
 
 
 
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
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.markdown("""
<center><h2 style="padding-top: 0px; padding-bottom: 0px;">Entity Referring Classifier</h2></center>
<center><small>Ver 2.0.1208.01</small></center>
<center><h6><b>It knows exactly when you are calling it.</b></h6></center>
<br/>
""", unsafe_allow_html=True)

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'):
            if entity.lower() not in sentence.lower():
                st.session_state['running_status'] = STATUS_ERROR
            else:
                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")}`')
    elif st.session_state['running_status'] == STATUS_ERROR:
        st.warning('The entity name is not in the sentence!')

with livedemo_col2:
    st.empty()

with livedemo_col3:
    st.markdown("""
    #### Get Started
    """)
    st.markdown("""
    Hi! I'm the Entity Referring Classifier.
    I will fill this part later.
    """)
    st.markdown("""
    #### Terms
    """)
    st.markdown("""
    ##### `Calling`
    """)
    st.markdown("""
    ##### `Mentioning`
    """)