macrdel commited on
Commit
3a69ea2
1 Parent(s): 84bcdcd

update pipeline sentiment src.py

Browse files
Files changed (1) hide show
  1. app/src/src.py +5 -4
app/src/src.py CHANGED
@@ -42,18 +42,19 @@ def get_comments(api_key, video_id):
42
  for num, x in enumerate(res['items'])
43
  }
44
 
45
- def get_sentim(data, model):
46
  """Get result of sentimental analysis"""
47
- res = model(data)[0]
 
48
  return res['label'], res['score']
49
 
50
- def pipeline_sentiment(url_video, api_key, model):
51
  """Pipeline of sentimental analysis"""
52
  video_id = get_video_id(url_video)
53
  comments = get_comments(api_key, video_id)
54
  comments_df = pd.DataFrame(comments).T
55
 
56
- text_tuple = [get_sentim(i, model) for i in comments_df["text_comment"]]
57
  comments_df[["sentiment", "score"]] = pd.DataFrame(list(text_tuple))
58
  return comments_df
59
 
 
42
  for num, x in enumerate(res['items'])
43
  }
44
 
45
+ def get_sentim(data, headers, url):
46
  """Get result of sentimental analysis"""
47
+ res = requests.post(url, headers=headers, json=data)
48
+ res = res.json()[0][0]
49
  return res['label'], res['score']
50
 
51
+ def pipeline_sentiment(url_video, api_key, headers, url):
52
  """Pipeline of sentimental analysis"""
53
  video_id = get_video_id(url_video)
54
  comments = get_comments(api_key, video_id)
55
  comments_df = pd.DataFrame(comments).T
56
 
57
+ text_tuple = [get_sentim(i, headers, url) for i in comments_df["text_comment"]]
58
  comments_df[["sentiment", "score"]] = pd.DataFrame(list(text_tuple))
59
  return comments_df
60