Spaces:
Runtime error
Runtime error
File size: 465 Bytes
ec8e443 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from newspaper import Article
from transformers import pipeline
article_summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # Replace with your actual token
def extract_article_text(url):
article = Article(url)
article.download()
article.parse()
return article.text
def summarize_article(text):
summary = article_summarizer(text, max_length=150, min_length=50, do_sample=False)
return summary[0]['summary_text']
|