egumasa commited on
Commit
8b41226
·
1 Parent(s): b1a6fff
Files changed (1) hide show
  1. demo.py +6 -3
demo.py CHANGED
@@ -115,6 +115,7 @@ TEXT_LIST = [
115
  ]
116
 
117
 
 
118
  def preprocess(text):
119
  text = re.sub("\n\n", ' &&&&&&&&#&#&#&#&', text)
120
  text = re.sub('\n', ' ', text)
@@ -123,6 +124,7 @@ def preprocess(text):
123
  return text
124
 
125
 
 
126
  def delete_span(span_sc: dict):
127
  id_del = []
128
  for n, spn in enumerate(span_sc, start=1):
@@ -231,9 +233,10 @@ st.sidebar.markdown("""
231
  - Dr. Kristopher Kyle (Associate Professor in Linguistics, University of Oregon)
232
  """)
233
  cc = '<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.'
 
234
  st.sidebar.markdown(cc, unsafe_allow_html=True)
235
 
236
- # st.title("Engagement Analyzer (beta ver 0.2)")
237
  st.info('Updated on Nov. 18th, 2022')
238
 
239
  st.write(
@@ -274,11 +277,11 @@ with st.form("my_form"):
274
  if submitted:
275
  if textmode == 'Option 2: My own text':
276
  text = input_text
277
- with st.spinner('Analysis in pregress...'):
278
  doc = nlp(preprocess(text))
279
  #st.markdown("> " + input_text)
280
  else:
281
- with st.spinner('Analysis in pregress...'):
282
  doc = nlp(preprocess(text))
283
  #st.markdown("> " + text)
284
 
 
115
  ]
116
 
117
 
118
+ @st.cache
119
  def preprocess(text):
120
  text = re.sub("\n\n", ' &&&&&&&&#&#&#&#&', text)
121
  text = re.sub('\n', ' ', text)
 
124
  return text
125
 
126
 
127
+ @st.cache(allow_output_mutation=True)
128
  def delete_span(span_sc: dict):
129
  id_del = []
130
  for n, spn in enumerate(span_sc, start=1):
 
233
  - Dr. Kristopher Kyle (Associate Professor in Linguistics, University of Oregon)
234
  """)
235
  cc = '<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.'
236
+
237
  st.sidebar.markdown(cc, unsafe_allow_html=True)
238
 
239
+ st.header("Engagement Analyzer (beta ver 0.2)")
240
  st.info('Updated on Nov. 18th, 2022')
241
 
242
  st.write(
 
277
  if submitted:
278
  if textmode == 'Option 2: My own text':
279
  text = input_text
280
+ with st.spinner('Analysis in progress...'):
281
  doc = nlp(preprocess(text))
282
  #st.markdown("> " + input_text)
283
  else:
284
+ with st.spinner('Analysis in progress...'):
285
  doc = nlp(preprocess(text))
286
  #st.markdown("> " + text)
287