Spaces:
Sleeping
Sleeping
File size: 651 Bytes
42b5a1a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from transformers import pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
classifier = pipeline("zero-shot-classification")
def analyze_article(text, title, link):
summary = summarizer(text[:1024], max_length=200, min_length=50, do_sample=False)[0]['summary_text']
relevance = classifier(
summary,
candidate_labels=["Useful for data analytics team", "Not useful"],
multi_label=False
)
is_useful = relevance["labels"][0] == "Useful for data analytics team"
return {
"title": title,
"summary": summary,
"link": link,
"useful": is_useful
}
|