deeplearningwithpython5240 commited on
Commit
a8ffb38
·
verified ·
1 Parent(s): 595443b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -26,7 +26,7 @@ def process_data(input_data,columnname = 'text', num_data = 100):
26
  random.seed(20979738)
27
  processed_data = [i for i in input_data[columnname]]
28
  random_selection = random.sample(processed_data, num_data)
29
- filtered_data = filter_similar_items(random_selection, similarity_threshold = 0.5)
30
  st.write('Number of data input: ',len(random_selection))
31
  st.write('After removing duplicates: ',len(filtered_data))
32
  return filtered_data
@@ -90,7 +90,7 @@ def emotion_classification(translated_data):
90
  negative_dict_sorted = dict(sorted(negative_dict.items(), key=lambda x: x[1], reverse=True))
91
  top10_negative_str = ""
92
  if len(negative_dict_sorted) < 10:
93
- st.write("Totall Number of Negative Comments: ",len(negative_dict_sorted))
94
  for k,v in negative_dict_sorted.items():
95
  st.write(k)
96
  top10_negative_str += f"{k}."
@@ -118,11 +118,12 @@ def main():
118
  st.set_option('deprecation.showPyplotGlobalUse', False)
119
  st.set_page_config(page_title="Review Sentiment Analysis and Improvement Summarisation Report for Business Product", page_icon="🦜")
120
  st.header("Review Sentiment Analysis and Improvement Summarisation Report for Business Product")
 
121
  try:
122
  uploaded_file = st.file_uploader("🔶 Upload CSV file for analysis 🔶", type={"csv"})
123
  if uploaded_file is not None:
124
  columnname = st.text_input("🔶 Please enter the column name in CSV file you want to analyze 🔶")
125
- num_data = st.number_input("🔶 Please enter the number of rows you want to process 🔶",step=1)
126
  input_data = pd.read_csv(uploaded_file)
127
  st.dataframe(input_data)
128
  st.text('️️ ')
@@ -148,12 +149,15 @@ def main():
148
 
149
  #stage 4:Summarization
150
  st.text('🔶 Processing Summarization 🔶')
151
- summarized_text = summarization(top10_negative_str)
152
- st.write('Summarized Negative Comments:')
153
- st.write(summarized_text[0]["generated_text"])
 
 
 
154
  st.text('️️🟢 Summarization Finished 🟢')
155
  except:
156
  st.write("")
157
-
158
  if __name__ == "__main__":
159
  main()
 
26
  random.seed(20979738)
27
  processed_data = [i for i in input_data[columnname]]
28
  random_selection = random.sample(processed_data, num_data)
29
+ filtered_data = filter_similar_items(random_selection, similarity_threshold = 0.9)
30
  st.write('Number of data input: ',len(random_selection))
31
  st.write('After removing duplicates: ',len(filtered_data))
32
  return filtered_data
 
90
  negative_dict_sorted = dict(sorted(negative_dict.items(), key=lambda x: x[1], reverse=True))
91
  top10_negative_str = ""
92
  if len(negative_dict_sorted) < 10:
93
+ st.write("Total Number of Negative Comments: ",len(negative_dict_sorted))
94
  for k,v in negative_dict_sorted.items():
95
  st.write(k)
96
  top10_negative_str += f"{k}."
 
118
  st.set_option('deprecation.showPyplotGlobalUse', False)
119
  st.set_page_config(page_title="Review Sentiment Analysis and Improvement Summarisation Report for Business Product", page_icon="🦜")
120
  st.header("Review Sentiment Analysis and Improvement Summarisation Report for Business Product")
121
+ 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")
122
  try:
123
  uploaded_file = st.file_uploader("🔶 Upload CSV file for analysis 🔶", type={"csv"})
124
  if uploaded_file is not None:
125
  columnname = st.text_input("🔶 Please enter the column name in CSV file you want to analyze 🔶")
126
+ num_data = st.number_input("🔶 Please enter the number of rows you want to process 🔶",min_value=2, step=1)
127
  input_data = pd.read_csv(uploaded_file)
128
  st.dataframe(input_data)
129
  st.text('️️ ')
 
149
 
150
  #stage 4:Summarization
151
  st.text('🔶 Processing Summarization 🔶')
152
+ if len(top10_negative_str) == 0:
153
+ st.write("No Negative Reviews Detected")
154
+ else:
155
+ summarized_text = summarization(top10_negative_str)
156
+ st.write('Summarized Negative Comments:')
157
+ st.write(summarized_text[0]["generated_text"])
158
  st.text('️️🟢 Summarization Finished 🟢')
159
  except:
160
  st.write("")
161
+
162
  if __name__ == "__main__":
163
  main()