stanlys96 commited on
Commit
156dc45
·
verified ·
1 Parent(s): f427cce

Upload 51 files

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -2
  2. youtube.py +3 -12
requirements.txt CHANGED
@@ -12,5 +12,4 @@ google-auth-httplib2==0.2.0
12
  google-api-core==2.23.0
13
  googleapis-common-protos==1.66.0
14
  python-dotenv==1.0.1
15
- tensorflow==2.15.1
16
- tensorflow_hub==0.16.1
 
12
  google-api-core==2.23.0
13
  googleapis-common-protos==1.66.0
14
  python-dotenv==1.0.1
15
+ nltk
 
youtube.py CHANGED
@@ -1,12 +1,7 @@
1
- from helper import extract_youtube_id, get_all_comments, text_preprocessing, slang_dict
2
  import streamlit as st
3
  import random
4
  import pandas as pd
5
- import tensorflow as tf
6
- import tensorflow_hub as tf_hub
7
-
8
- def load_model():
9
- return tf.keras.models.load_model('model_lstm.h5', custom_objects={'KerasLayer': tf_hub.KerasLayer})
10
 
11
  st.header("💬 Youtube Comments Sentiment Analysis")
12
 
@@ -35,11 +30,7 @@ if st.button('Submit', type="secondary"):
35
  the_youtube_id = extract_youtube_id(user_input)
36
  if the_youtube_id:
37
  with st.spinner("Please wait while we're loading the data..."):
38
- the_data, comment_only = get_all_comments(the_youtube_id)
39
- the_comments = pd.DataFrame({"comment": comment_only})
40
- the_comments['text_processed'] = the_comments['comment'].apply(lambda x: text_preprocessing(x))
41
- the_comments['text_processed'] = the_comments['text_processed'].apply(lambda x: x if len(x.split()) > 0 else None)
42
- the_comments = the_comments.dropna(subset=['text_processed'])
43
  st.balloons()
44
  st.markdown(f"""<p style="color: green; padding: 0; margin: 0;">Total comments: {len(the_data)}</p>""", unsafe_allow_html=True)
45
  for data in the_data:
@@ -50,7 +41,7 @@ if st.button('Submit', type="secondary"):
50
  <p style="font-size: 18px; line-height: 1.6; color: #333; font-family: 'Arial', sans-serif;">
51
  {data["comment"]}
52
  </p>
53
- <p style="font-size: 16px; color: gray; margin-top: 15px; font-family: 'Arial', sans-serif; font-weight: bold;">
54
  Sentiment Analysis: <span style="color: {sentiment_color}; font-size: 18px; font-weight: bold; padding: 5px 10px; background-color: {sentiment_color + "33"}; border-radius: 5px;">
55
  {sentiment}
56
  </span>
 
1
+ from helper import extract_youtube_id, get_all_comments
2
  import streamlit as st
3
  import random
4
  import pandas as pd
 
 
 
 
 
5
 
6
  st.header("💬 Youtube Comments Sentiment Analysis")
7
 
 
30
  the_youtube_id = extract_youtube_id(user_input)
31
  if the_youtube_id:
32
  with st.spinner("Please wait while we're loading the data..."):
33
+ the_data = get_all_comments(the_youtube_id)
 
 
 
 
34
  st.balloons()
35
  st.markdown(f"""<p style="color: green; padding: 0; margin: 0;">Total comments: {len(the_data)}</p>""", unsafe_allow_html=True)
36
  for data in the_data:
 
41
  <p style="font-size: 18px; line-height: 1.6; color: #333; font-family: 'Arial', sans-serif;">
42
  {data["comment"]}
43
  </p>
44
+ <p style="font-size: 16px; margin-top: 15px; font-family: 'Arial', sans-serif; font-weight: bold;">
45
  Sentiment Analysis: <span style="color: {sentiment_color}; font-size: 18px; font-weight: bold; padding: 5px 10px; background-color: {sentiment_color + "33"}; border-radius: 5px;">
46
  {sentiment}
47
  </span>