Spaces:
Runtime error
Runtime error
File size: 4,712 Bytes
154ca7b b4f5518 154ca7b 74abd6a 154ca7b 4ae1cd4 74abd6a 154ca7b 74abd6a cd78976 74abd6a 154ca7b 74abd6a cd78976 b4f5518 154ca7b b4f5518 4ae1cd4 154ca7b b4f5518 4ae1cd4 154ca7b cd78976 74abd6a cd78976 74abd6a cd78976 74abd6a cd78976 154ca7b 74abd6a 154ca7b 74abd6a cd78976 154ca7b 74abd6a 154ca7b 74abd6a cd78976 74abd6a 154ca7b 74abd6a |
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 |
import streamlit as st
from datetime import datetime
from ercbcm import predict
STATUS_STOPPED = 120001
STATUS_SUBMIT = 120002
STATUS_ERROR = 120003
st.session_state['running_status'] = STATUS_STOPPED
st.markdown("""
<center><h2 style="padding-top: 0px; padding-bottom: 8px;">Entity Referring Classifier</h2></center>
<center><h6 style="color: #bfbfbf"><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:
# Version.
st.markdown("""
<h3>Live Demo <small style="font-size:12px; color: #cfcfcf">version 2.1.0.1216</small></h3>
""", unsafe_allow_html=True)
# Live Demo form.
with st.form("live_demo_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!')
st.markdown("""
#### Corpus
""")
st.markdown("""
<small style="font-size: 19px; padding-bottom: 6px;"><b><code>Calling</code></b></small>
means that the sentence contains the name and is telling to the entity.<br/>
<small style="color: #afafaf">
<b><i>Examples:</i></b><br/>
<b>-</b> Are you feeling good about it Jimmy?<br/>
<b>-</b> Are you feeling good Jimmy?<br/>
<b>-</b> Jimmy you are so cool!
</small>
""", unsafe_allow_html=True)
st.markdown("""
<small style="font-size: 19px; padding-bottom: 6px;"><b><code>Mentioning</code></b></small>
means that the sentence contains the name but is telling to other person.<br/>
<small style="color: #afafaf">
<b><i>Examples:</i></b><br/>
<b>-</b> Are you feeling good about Jimmy?<br/>
<b>-</b> Have you heard about Jimmy?<br/>
<b>-</b> Jimmy said that you are so cool!
</small>
""", unsafe_allow_html=True)
st.markdown("""
#### Applications and Future Works
""")
st.markdown("""
Developers can apply it on their virtual bots or voice assistants to detect
if the user is calling the bot or just mentioning the bot rather than detecting a fixed wake-up phrase.
It will improve the human-computer interaction and usability.
Additionally, Lingxi is going to expand the project into Simplified Chinese in the future,
implement it into a Discord Bot,
and deliver it into medium-sized channels to see if users feel better in communicating with bots in this way
and if it works well in conversations in practice.
If it works well,
we may try to combine it with the speech-to-text to analyze the experience in the context of voice,
which has a lot more complicated scenarios.
""")
with livedemo_col2:
st.empty()
with livedemo_col3:
st.markdown("""
#### Get Started
""")
st.markdown("""
Hi! I'm the Entity Referring Classifier.
Specify an entity name, and then type a sentence to get started!
""")
st.markdown("""
#### Members
""")
st.markdown("""
Lingxi Li, Li Xu, Zachary Polak, Tudor-Cristian Foca
""")
st.markdown("""
#### Background
""")
st.markdown("""
There are a lot of voice assistants and bots out there,
but they all need a specific prefix to wake them like “hey siri” or “hey alexa”.
At our real world, nobody is communicating with others with such prefix all the time.
Everyone should be able to communicate in a comfortable way including with bots and virtual assistants.
Our aim here is to get rid of the "wake phrase".
""") |