Kurkur99's picture
Upload 8 files
8c2d9a7
raw
history blame
No virus
1.7 kB
import streamlit as st
import prediction
import eda
# Function to display the sentiment prediction
@st.cache_data
def get_prediction(text):
return prediction.predict_sentiment(text)
# Main function for the Streamlit app
def main():
st.title("Sentiment Analysis App")
menu = ["Home", "Sentiment Prediction", "Exploratory Data Analysis"]
choice = st.sidebar.selectbox("Menu", menu)
if choice == "Home":
st.write("""
## Welcome to the Sentiment Analysis App!
Navigate to the menu on the left to:
- Predict the sentiment of a given review text.
- View exploratory data analysis visuals.
""")
elif choice == "Sentiment Prediction":
st.write("""
### Sentiment Prediction
Enter a review text below to predict its sentiment.
""")
# Create a text input widget
text = st.text_area("Enter the review text:")
if st.button("Predict"):
sentiment = get_prediction(text)
st.success(f"The sentiment of the review is: **{sentiment}**")
elif choice == "Exploratory Data Analysis":
st.write("""
### Exploratory Data Analysis
View visualizations derived from the dataset.
""")
# Display wordcloud
st.write("### Word Cloud for Reviews")
st.pyplot(eda.visualize_wordcloud())
# Display review lengths distribution
st.write("### Distribution of Review Lengths")
st.pyplot(eda.plot_review_lengths())
# Display rating distribution
st.write("### Rating Distribution")
st.pyplot(eda.rating_distribution())
if __name__ == '__main__':
main()