newsletter2.0 / summarizer.py
claytonsamples's picture
Create summarizer.py
dad8a09
raw
history blame contribute delete
508 Bytes
# Import necessary libraries
from transformers import pipeline
class ContentSummarizer:
def __init__(self, data):
self.data = data
self.summarizer = pipeline('summarization')
def summarize(self):
summaries = []
for index, row in self.data.iterrows():
summary = self.summarizer(row['content'], max_length=150, min_length=30, do_sample=False)
summaries.append({'url': row['url'], 'summary': summary[0]['summary_text']})
return summaries