jcg00v commited on
Commit
73b559a
1 Parent(s): 3aaa4ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -2,6 +2,12 @@ import streamlit as st
2
  from PIL import Image
3
  from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
4
 
 
 
 
 
 
 
5
  def get_result_text_es_pt (list_entity, text, lang):
6
  result_words = []
7
  tmp_word = ""
@@ -109,6 +115,9 @@ def get_result_text_ca (list_entity, text):
109
 
110
  if __name__ == "__main__":
111
 
 
 
 
112
  st.title('Sanivert Punctuation And Capitalization Restoration')
113
  model_es = AutoModelForTokenClassification.from_pretrained("VOCALINLP/spanish_capitalization_punctuation_restoration_sanivert")
114
  tokenizer_es = AutoTokenizer.from_pretrained("VOCALINLP/spanish_capitalization_punctuation_restoration_sanivert")
@@ -131,7 +140,9 @@ if __name__ == "__main__":
131
  )
132
 
133
  st.subheader("Enter the text to be analyzed.")
134
- text = st.text_input('Enter text') #text is stored in this variable
 
 
135
  if input_text == "Spanish":
136
  result_pipe = pipe_es(text)
137
  out = get_result_text_es_pt(result_pipe, text, "es")
 
2
  from PIL import Image
3
  from transformers import pipeline, AutoModelForTokenClassification, AutoTokenizer
4
 
5
+
6
+ def clear_text():
7
+ st.session_state.my_text = st.session_state.widget
8
+ st.session_state.widget = ""
9
+
10
+
11
  def get_result_text_es_pt (list_entity, text, lang):
12
  result_words = []
13
  tmp_word = ""
 
115
 
116
  if __name__ == "__main__":
117
 
118
+ if "text" not in st.session_state:
119
+ st.session_state.text = ""
120
+
121
  st.title('Sanivert Punctuation And Capitalization Restoration')
122
  model_es = AutoModelForTokenClassification.from_pretrained("VOCALINLP/spanish_capitalization_punctuation_restoration_sanivert")
123
  tokenizer_es = AutoTokenizer.from_pretrained("VOCALINLP/spanish_capitalization_punctuation_restoration_sanivert")
 
140
  )
141
 
142
  st.subheader("Enter the text to be analyzed.")
143
+ st.text_input('Enter text', key='widget', on_change=clear_text) #text is stored in this variable
144
+ text = st.session_state.text
145
+
146
  if input_text == "Spanish":
147
  result_pipe = pipe_es(text)
148
  out = get_result_text_es_pt(result_pipe, text, "es")