Spaces:
Sleeping
Sleeping
File size: 1,026 Bytes
e65e518 |
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 |
import streamlit as st
import re
import fasttext
model = fasttext.load_model("fasttext_model.bin")
def preprocess_input(text):
text = re.sub(r'[^\w\s\']|\n', ' ', text)
text = re.sub(' +', ' ', text)
return text.strip().lower()
def classify_transcript(transcript):
preprocessed_transcript = preprocess_input(transcript)
prediction = model.predict(preprocessed_transcript)
predicted_label = prediction[0][0].replace('__label__', '')
return predicted_label
def main():
st.title("FASTTEXT MENTAL HEALTH CLASSIFIER")
st.write("Type 'exit' in the input box below to end the conversation.")
user_input = st.text_area("Please enter the transcript of the patient:", "")
if st.button("Classify"):
if user_input.lower() == 'exit':
st.stop()
else:
predicted_disease = classify_transcript(user_input)
st.write(f"Based on the transcript, the predicted disease category is: {predicted_disease}")
if __name__ == "__main__":
main()
|