Created
August 7, 2020 01:34
-
-
Save a-poor/c6700ab59c5d6cc683a7f69ff304a973 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
@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