Hello, everyone.
I am facing a problem with a very simple streamlit app in Python.
For a ML app, I want to ask the user to introduce a text. If the user replies āendā, the app should stop, otherwise the userās text is lemmatized, and send back to the screen. thatās all. However, the app enters in a inifinite loop when running. It should stop while the user has not yet entered his question, but that is not the case. The code is something like this:
import streamlit as st
import all other necessary libraries (ā¦)
st.write(āLibraries have been importedā)
#--------------------
Global Variables
#--------------------
(ā¦ global variables are definedā¦)
st.write(āGlobal Variables have been definedā)
#-----------------------------------------
Function definitions
#-----------------------------------------
#----------------------------------------------------
clean_txt: Cleans a string, and then lemmatize it.
#----------------------------------------------------
def clean_txt(txt):
# txt: string to clean
(ā¦ function code in Pythonā¦)
return txt
st.write(āfunctions have been definedā)
#---------------------------------------------
The user enter his text
#---------------------------------------------
def tagging():
user_input = st.text_area(āEnter your question here belowā, āendā, key = str(counter))
question_txt = clean_txt(user_input)
label_list =
if (question_txt == āendā):
return āendā, False
else:
return question_txt, True
Main program
counter=0
keep_going = True
while (keep_going):
results, keep_going = tagging()
if (results!=āendā):
st.write(results)
counter += 1
if not(keep_going):
st.write(āEnd of Projectā)
st.stop()
maybe my programming logic is not the best, but I found quite confusing how this simple program works. Streamlit doest not stop to wait for usersā input but continues the execution of the remaining code.