import streamlit as st import tensorflow as tf import pickle import numpy as np from tensorflow.keras.preprocessing.sequence import pad_sequences # Load the model and tokenizer model = tf.keras.models.load_model('sentiment_model.keras') with open('tokenizer.pickle', 'rb') as handle: tokenizer = pickle.load(handle) with open('max_length.txt', 'r') as f: max_length = int(f.read()) def classify_sentence(sentence): seq = tokenizer.texts_to_sequences([sentence]) padded_seq = pad_sequences(seq, maxlen=max_length) prediction = model.predict(padded_seq) label = "Positive" if prediction[0][0] > 0.5 else "Negative" return label # Streamlit UI st.title("Restaurant Review Sentiment Analysis") st.write("Enter your review in Turkish to analyze its sentiment") user_input = st.text_area("Enter your review:") if st.button("Analyze"): if user_input: result = classify_sentence(user_input) st.write(f"Sentiment: {result}") else: st.write("Please enter a review to analyze")