<jupyter_start><jupyter_text>Week 3 handin  Handin Exercise 6Create a module containing a class: TextComparer with the following methods:1. `__init__(self, url_list)`2. `download(url,filename)` that stores the file on disk and raises NotFoundException when url returns 4043. `multi_download()` uses threads to download multiple urls as text and stores filenames on a property of the TextComparer class object (Hint: use the download() method and create the filenames from the url or from the response object)4. `__iter__()` returns an iterator5. `__next__()` returns the next filename (and stops when there are no more)6. `urllist_generator()` returns a generator to loop through the urls7. `avg_vowels(text)` - a rough estimate on readability returns average number of vowels in the words of the text8. `hardest_read()` reads all text from files in `filenames` and returns the filename of the text with the highest vowel score (use all the cpu cores on the computer for this work. Ex 2Create a notebook and import your module from above1. Find 10 books on https://www.gutenberg.org/browse/scores/top and download them using an object of the class you just created before2. Test the different methods of your class3. Make a bar plot with a sorted list of books on x-axis and avg vowels on y-axis  02 StatusHere is a status on the handin. How far you got. What is implemented and what is not  03 Solution part 1<jupyter_code># 2 Create a notebook and import your module from above
from modules.week6.text_comparer import TextComparer
# 2.1 Find 10 books
comparer = TextComparer(
    [
        "https://www.gutenberg.org/files/84/84-0.txt",
        "https://www.gutenberg.org/files/1342/1342-0.txt",
        "https://www.gutenberg.org/files/25344/25344-0.txt",
        "https://www.gutenberg.org/files/11/11-0.txt",
        "https://www.gutenberg.org/files/2701/2701-0.txt",
        "https://www.gutenberg.org/files/1952/1952-0.txt",
        "https://www.gutenberg.org/files/1661/1661-0.txt",
        "https://www.gutenberg.org/files/345/345-0.txt",
        "https://www.gutenberg.org/files/2542/2542-0.txt",
        "https://www.gutenberg.org/files/43/43-0.txt"
    ]
)
# 2.2 Test the different methods on your class
comparer.multi_download()<jupyter_output><empty_output><jupyter_text>04 Solution part 2<jupyter_code># class iterator
iterator = iter(comparer)
try:
    [print(next(iterator)) for _ in range(0, 5)]
except StopIteration as e:
    print(type(e))
# urllist_generator
urllist = comparer.urllist_generator()
try:
    [print(next(urllist)) for _ in range(0, 5)]
except StopIteration as e:
    print(type(e))
sorted_hardest_books = comparer.hardest_read()
print(sorted_hardest_books)
# Make a bar plot with a sorted list of books on x-axis and avg vowels on y-axis
import matplotlib.pyplot as plt

plt.figure(figsize= (12, 8))
plt.bar(sorted_hardest_books.keys(), sorted_hardest_books.values(), width=0.5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10258152173913043, 'fraction_numerical': 0.041440217391304345, 'mean_word_length': 4.175746924428823, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 11, 'lorem ipsum': 0, 'www.': 11, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '209952', 'license': 'MIT', 'n_tokens_mistral': 1016, 'n_tokens_neox': 940, 'n_words': 318, 'path': 'Week_6.ipynb', 'repo_name': 'tobias-z/4-sem-python', 'size': '2944'}