Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| from wordcloud import WordCloud | |
| # Function to analyze sentiment | |
| def analyze_sentiment(text): | |
| # Placeholder function for sentiment analysis | |
| # Replace with actual sentiment analysis logic | |
| return "Positive" if "good" in text else "Negative" | |
| # Function to generate word cloud | |
| def generate_wordcloud(text): | |
| wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text) | |
| return wordcloud | |
| # Streamlit app | |
| st.title("NFL Draft Sentiment Analysis") | |
| uploaded_file = st.file_uploader("Upload a text file", type=["csv"]) | |
| if uploaded_file is not None: | |
| # Read the file content | |
| file_content = uploaded_file.read().decode("utf-8") | |
| # Display the file content | |
| # st.subheader("File Content") | |
| # st.text(file_content) | |
| # Analyze sentiment | |
| sentiment = analyze_sentiment(file_content) | |
| st.subheader("Sentiment Analysis") | |
| st.write(f"The sentiment of the text is: {sentiment}") | |
| # Generate and display word cloud | |
| wordcloud = generate_wordcloud(file_content) | |
| st.subheader("Word Cloud") | |
| plt.figure(figsize=(10, 5)) | |
| plt.imshow(wordcloud, interpolation='bilinear') | |
| plt.axis("off") | |
| st.pyplot(plt) | |