Skip to content

Instantly share code, notes, and snippets.

@a-poor
Created August 7, 2020 01:34
Show Gist options
  • Save a-poor/c6700ab59c5d6cc683a7f69ff304a973 to your computer and use it in GitHub Desktop.
Save a-poor/c6700ab59c5d6cc683a7f69ff304a973 to your computer and use it in GitHub Desktop.
@profile
def read_books(urls):
"""For each url in urls,
load the book and count the words"""
# Create a place to store word counts
word_counts = {}
# For each book: load it, count words, store the counts
for title, path in urls.items():
book = get_book(path)
words = split_words(book)
counts = count_words(words)
word_counts[title] = counts.most_common()[:10]
return word_counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment