aannor commited on
Commit
408ae47
1 Parent(s): 4d4dde7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -6,7 +6,6 @@ from PIL import Image
6
  import base64
7
  from transformers import pipeline
8
  import spacy
9
- import googleapiclient
10
  import numpy as np
11
  from sentence_transformers import SentenceTransformer
12
  from matplotlib import colormaps
@@ -199,17 +198,23 @@ if (st.session_state.rerun_button == "QUERYING") and (st.session_state["video_li
199
  yt_parser.scrape_comments(st.session_state['video_link'])
200
  yt_parser.scrape_video_title()
201
  except:
202
- st.error("Error: Unable to query comments, incorrect YouTube URL or maximum \
203
- API call limit reached.")
204
  st.stop()
205
 
206
  # Run formatting and models
207
- yt_parser.format_comments()
208
- yt_parser.clean_comments()
209
- yt_parser.run_sentiment_pipeline(sentiment_pipeline)
210
- yt_parser.run_topic_modelling_pipeline(embedding_model,
211
- nlp=spacy_nlp,
212
- max_topics=st.session_state['max_topics'])
 
 
 
 
 
 
 
213
  # Set "QUERY COMPLETE" to bypass running this section on script re-run
214
  st.session_state.rerun_button = "QUERY COMPLETE"
215
 
 
6
  import base64
7
  from transformers import pipeline
8
  import spacy
 
9
  import numpy as np
10
  from sentence_transformers import SentenceTransformer
11
  from matplotlib import colormaps
 
198
  yt_parser.scrape_comments(st.session_state['video_link'])
199
  yt_parser.scrape_video_title()
200
  except:
201
+ st.error("Error: Unable to query comments, incorrect YouTube URL.")
 
202
  st.stop()
203
 
204
  # Run formatting and models
205
+ try:
206
+ yt_parser.format_comments()
207
+ yt_parser.clean_comments()
208
+ yt_parser.run_sentiment_pipeline(sentiment_pipeline)
209
+ yt_parser.run_topic_modelling_pipeline(embedding_model,
210
+ nlp=spacy_nlp,
211
+ max_topics=st.session_state['max_topics'])
212
+ except ValueError:
213
+ st.error("Error: Oops there are not enough comments to analyse, please try a different video.")
214
+ st.stop()
215
+ except:
216
+ st.error("Error: Oops there's an issue on our end, please wait a moment and try again.")
217
+ st.stop()
218
  # Set "QUERY COMPLETE" to bypass running this section on script re-run
219
  st.session_state.rerun_button = "QUERY COMPLETE"
220