Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import data | |
| import models | |
| def main(): | |
| st.title("Sentiment Analysis") | |
| uploaded_file = st.file_uploader("Upload CSV or Excel file", type=["csv", "xlsx"]) | |
| classifier = models.load_model() | |
| if uploaded_file: | |
| df = data.read_data(uploaded_file) | |
| if df is not None: | |
| st.write("✅ File Uploaded Successfully!") | |
| column = list(df.columns) | |
| column_with_empty = [""] + column | |
| text_to_analyze = st.selectbox("Select text column", column_with_empty) | |
| if text_to_analyze in df.columns: | |
| text_column = text_to_analyze | |
| df = models.analyze_sentiments(df, text_column, classifier) | |
| data.visualize_data(df, st) | |
| st.subheader("Processed Data Preview") | |
| st.dataframe(df.head()) | |
| st.download_button("Download Results", df.to_csv(index=False).encode('utf-8'), "sentiment_results.csv", "text/csv") | |
| if __name__ == "__main__": | |
| main() |