Spaces:
Sleeping
Sleeping
File size: 1,033 Bytes
7b97e29 |
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 |
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") |