Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -2
src/streamlit_app.py
CHANGED
|
@@ -67,7 +67,13 @@ def text_preprocessing(text):
|
|
| 67 |
text = ' '.join(tokens)
|
| 68 |
|
| 69 |
return text
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
# Define the Streamlit interface
|
| 72 |
st.title('Sentiment Analysis App')
|
| 73 |
|
|
@@ -78,7 +84,8 @@ if st.button('Analyze'):
|
|
| 78 |
if user_input:
|
| 79 |
# Preprocess the input text
|
| 80 |
processed_text = text_preprocessing(user_input)
|
| 81 |
-
|
|
|
|
| 82 |
sentiment = "Positive" if prediction[0] > 0.5 else "Negative"
|
| 83 |
|
| 84 |
# Display the result
|
|
|
|
| 67 |
text = ' '.join(tokens)
|
| 68 |
|
| 69 |
return text
|
| 70 |
+
|
| 71 |
+
hub_layer = tf_hub.KerasLayer(
|
| 72 |
+
"https://www.kaggle.com/models/google/nnlm/TensorFlow2/id-dim128-with-normalization/1",
|
| 73 |
+
input_shape=[],
|
| 74 |
+
dtype=tf.string,
|
| 75 |
+
trainable=False
|
| 76 |
+
)
|
| 77 |
# Define the Streamlit interface
|
| 78 |
st.title('Sentiment Analysis App')
|
| 79 |
|
|
|
|
| 84 |
if user_input:
|
| 85 |
# Preprocess the input text
|
| 86 |
processed_text = text_preprocessing(user_input)
|
| 87 |
+
data_inf = hub_layer(processed_text)
|
| 88 |
+
prediction = model.predict(data_inf)
|
| 89 |
sentiment = "Positive" if prediction[0] > 0.5 else "Negative"
|
| 90 |
|
| 91 |
# Display the result
|