macrdel commited on
Commit
ad71124
1 Parent(s): 51906e7

add pipeline summarization

Browse files
Files changed (1) hide show
  1. app/src/src.py +11 -0
app/src/src.py CHANGED
@@ -60,3 +60,14 @@ def pipeline_sentiment(url_video, api_key, model):
60
  def pipeline_stats(data):
61
  """Get statistic of sentiment"""
62
  return data['sentiment'].value_counts(normalize=True).mul(100).round(2)
 
 
 
 
 
 
 
 
 
 
 
 
60
  def pipeline_stats(data):
61
  """Get statistic of sentiment"""
62
  return data['sentiment'].value_counts(normalize=True).mul(100).round(2)
63
+
64
+ def pipeline_summarize(data, model, length=2000, max_length=100):
65
+ """Get summarization result"""
66
+ text = " ".join(data)
67
+ result_text = []
68
+
69
+ for i in range(0, len(text), length):
70
+ new_text = text[i : i + length]
71
+ result_text.append(model(new_text, max_length=max_length))
72
+
73
+ return ". ".join([i[0]["summary_text"] for i in result_text])