Last active
September 12, 2021 17:16
-
-
Save quickcode00/5fad5776d22aba6ff2f98bd63c7b3d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def summarize_news_api(articles: list, sentences_count: int) -> list: | |
""" | |
summarizes text at URL for each element of articles dict | |
(return value from news_api_request) and adds a new element | |
articles dict where the key is 'summary' and the value is | |
the summarized text | |
Inputs | |
---------- | |
articles: list of dict returned from news_api_request() | |
sentences_count: specifies max number of sentences for | |
return value | |
Return | |
---------- | |
articles list with summary element added to each dict | |
""" | |
for article in articles: | |
summary = summarize_html(article.get('url'), sentences_count) | |
article.update({'summary': summary}) | |
return articles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment