Update app.py
Browse files25 unmodified lines2627282930313257 unmodified lines9091929394959621 unmodified lines11811912012112212312412512612712819 unmodified lines14814915015115215315415515615715815925 unmodified linesrandom.seed(20979738)processed_data = [i for i in input_data[columnname]]random_selection = random.sample(processed_data, num_data)filtered_data = filter_similar_items(random_selection, similarity_threshold = 0.5)st.write('Number of data input: ',len(random_selection))st.write('After removing duplicates: ',len(filtered_data))return filtered_data57 unmodified linesnegative_dict_sorted = dict(sorted(negative_dict.items(), key=lambda x: x[1], reverse=True))top10_negative_str = ""if len(negative_dict_sorted) < 10:st.write("Totall Number of Negative Comments: ",len(negative_dict_sorted))for k,v in negative_dict_sorted.items():st.write(k)top10_negative_str += f"{k}."21 unmodified linesst.set_option('deprecation.showPyplotGlobalUse', False)st.set_page_config(page_title="Review Sentiment Analysis and Improvement Summarisation Report for Business Product", page_icon="🦜")st.header("Review Sentiment Analysis and Improvement Summarisation Report for Business Product")try:uploaded_file = st.file_uploader("🔶 Upload CSV file for analysis 🔶", type={"csv"})if uploaded_file is not None:columnname = st.text_input("🔶 Please enter the column name in CSV file you want to analyze 🔶")num_data = st.number_input("🔶 Please enter the number of rows you want to process 🔶",step=1)input_data = pd.read_csv(uploaded_file)st.dataframe(input_data)st.text('️️ ')19 unmodified lines#stage 4:Summarizationst.text('🔶 Processing Summarization 🔶')summarized_text = summarization(top10_negative_str)st.write('Summarized Negative Comments:')st.write(summarized_text[0]["generated_text"])st.text('️️🟢 Summarization Finished 🟢')except:st.write("")if __name__ == "__main__":main()25 unmodified lines2627282930313257 unmodified lines9091929394959621 unmodified lines11811912012112212312412512612712812919 unmodified lines14915015115215315415515615715815916016116216325 unmodified linesrandom.seed(20979738)processed_data = [i for i in input_data[columnname]]random_selection = random.sample(processed_data, num_data)filtered_data = filter_similar_items(random_selection, similarity_threshold = 0.9)st.write('Number of data input: ',len(random_selection))st.write('After removing duplicates: ',len(filtered_data))return filtered_data57 unmodified linesnegative_dict_sorted = dict(sorted(negative_dict.items(), key=lambda x: x[1], reverse=True))top10_negative_str = ""if len(negative_dict_sorted) < 10:st.write("Total Number of Negative Comments: ",len(negative_dict_sorted))for k,v in negative_dict_sorted.items():st.write(k)top10_negative_str += f"{k}."21 unmodified linesst.set_option('deprecation.showPyplotGlobalUse', False)st.set_page_config(page_title="Review Sentiment Analysis and Improvement Summarisation Report for Business Product", page_icon="🦜")st.header("Review Sentiment Analysis and Improvement Summarisation Report for Business Product")st.write(f"Welcome to the user guide for our product feedback analysis application. Our application is designed to help companies review their product feedback and summarise areas for improvement. Here are the steps to get started:\n1. Upload reviews in CSV file format\n2. Input column name and number of data to be analysed\n3. Automatically removes duplicate reviews\n4. Translate data into English (if the dataset is Chinese)\n5. Analyse reviews sentiment\n6. Summarize top negative reveiws")try:uploaded_file = st.file_uploader("🔶 Upload CSV file for analysis 🔶", type={"csv"})if uploaded_file is not None:columnname = st.text_input("🔶 Please enter the column name in CSV file you want to analyze 🔶")num_data = st.number_input("🔶 Please enter the number of rows you want to process 🔶",min_value=2, step=1)input_data = pd.read_csv(uploaded_file)st.dataframe(input_data)st.text('️️ ')19 unmodified lines#stage 4:Summarizationst.text('🔶 Processing Summarization 🔶')if len(top10_negative_str) == 0:st.write("No Negative Reviews Detected")else:summarized_text = summarization(top10_negative_str)st.write('Summarized Negative Comments:')st.write(summarized_text[0]["generated_text"])st.text('️️🟢 Summarization Finished 🟢')except:st.write("")if __name__ == "__main__":main()
app.py+11-7