marcelomoreno26 commited on
Commit
3407050
1 Parent(s): 071db21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -26
app.py CHANGED
@@ -6,11 +6,16 @@ import pandas as pd
6
 
7
 
8
  def main():
 
 
 
 
 
9
  st.title("WhatsApp Analysis Tool")
10
  st.markdown("This app summarizes Whatsapp chats and provides named entity recognition as well as sentiment analysis for the conversation")
11
  st.markdown("**NOTE**: *This app can only receive chats downloaded from IOS as the downloaded chat format is different than from Android.*")
12
  st.markdown("Download your whatsapp chat by going to Settings > Chats > Export Chat and there select the chat you want to summarize (download 'Without Media').")
13
-
14
 
15
  # File uploader
16
  uploaded_file = st.file_uploader("Choose a file (.zip)", type=['zip'])
@@ -32,31 +37,21 @@ def main():
32
  st.markdown(f"```\n{text_for_analysis}\n```", unsafe_allow_html=True)
33
  process = st.button('Process')
34
  if process:
35
- # Load models
36
- tokenizer_sentiment, model_sentiment = load_sentiment_analyzer()
37
- tokenizer_summary, model_summary = load_summarizer()
38
- pipe_ner = load_NER()
39
-
40
- # Load models
41
- tokenizer_sentiment, model_sentiment = load_sentiment_analyzer()
42
- tokenizer_summary, model_summary = load_summarizer()
43
- pipe_ner = load_NER()
44
-
45
- # Perform analysis
46
- sentiment = get_sentiment_analysis(text_for_analysis, tokenizer_sentiment, model_sentiment)
47
- summary = generate_summary(text_for_analysis, tokenizer_summary, model_summary)
48
- ner_results = get_NER(text_for_analysis, pipe_ner)
49
-
50
- # Display results
51
- st.subheader("Sentiment Analysis")
52
- st.write("Sentiment:", sentiment)
53
-
54
- st.subheader("Summary")
55
- st.write("Summary:", summary)
56
-
57
- st.subheader("Named Entity Recognition")
58
- ner_df = pd.DataFrame(ner_results, columns=["Word", "Entity Group"])
59
- st.write(ner_df)
60
  else:
61
  st.error("Unsupported file type. Please upload a .txt or .zip file.")
62
  else:
 
6
 
7
 
8
  def main():
9
+ # Load models
10
+ tokenizer_sentiment, model_sentiment = load_sentiment_analyzer()
11
+ tokenizer_summary, model_summary = load_summarizer()
12
+ pipe_ner = load_NER()
13
+
14
  st.title("WhatsApp Analysis Tool")
15
  st.markdown("This app summarizes Whatsapp chats and provides named entity recognition as well as sentiment analysis for the conversation")
16
  st.markdown("**NOTE**: *This app can only receive chats downloaded from IOS as the downloaded chat format is different than from Android.*")
17
  st.markdown("Download your whatsapp chat by going to Settings > Chats > Export Chat and there select the chat you want to summarize (download 'Without Media').")
18
+
19
 
20
  # File uploader
21
  uploaded_file = st.file_uploader("Choose a file (.zip)", type=['zip'])
 
37
  st.markdown(f"```\n{text_for_analysis}\n```", unsafe_allow_html=True)
38
  process = st.button('Process')
39
  if process:
40
+ # Perform analysis
41
+ sentiment = get_sentiment_analysis(text_for_analysis, tokenizer_sentiment, model_sentiment)
42
+ summary = generate_summary(text_for_analysis, tokenizer_summary, model_summary)
43
+ ner_results = get_NER(text_for_analysis, pipe_ner)
44
+
45
+ # Display results
46
+ st.subheader("Sentiment Analysis")
47
+ st.write("Sentiment:", sentiment)
48
+
49
+ st.subheader("Summary")
50
+ st.write("Summary:", summary)
51
+
52
+ st.subheader("Named Entity Recognition")
53
+ ner_df = pd.DataFrame(ner_results, columns=["Word", "Entity Group"])
54
+ st.write(ner_df)
 
 
 
 
 
 
 
 
 
 
55
  else:
56
  st.error("Unsupported file type. Please upload a .txt or .zip file.")
57
  else: