Skip to content

Instantly share code, notes, and snippets.

@quickcode00
Last active September 12, 2021 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quickcode00/5fad5776d22aba6ff2f98bd63c7b3d4b to your computer and use it in GitHub Desktop.
Save quickcode00/5fad5776d22aba6ff2f98bd63c7b3d4b to your computer and use it in GitHub Desktop.
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