Spaces:
Sleeping
Sleeping
| 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 | |
| } | |