File size: 982 Bytes
726f5db
 
 
 
 
5c89452
726f5db
 
5c89452
726f5db
5c89452
726f5db
5c89452
 
 
 
726f5db
 
 
 
 
 
 
5c89452
 
 
 
 
726f5db
 
5c89452
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
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()