Problem 2 (150pts): about
Implement about
, which takes a list of topic
words.
It returns a function that can be passed to choose
as the select
argument.
The returned function takes a paragraph and returns a boolean indicating whether that paragraph contains any of the words in topic
.
Once we've implemented about
, we'll be able to pass the returned function to choose
as the select
argument, which will be useful as we continue to implement our typing test.
To make this comparison accurately, you will need to ignore case (that is, assume that uppercase and lowercase letters don't change what word it is) and punctuation. Additionally, only check for exact matches of the words in topic in the paragraph, not substrings. For example, "dogs" is not a match for the word "dog".
Hint: You may use the string utility functions in
utils.py
. You can reference the docstrings of the utility functions to see how they are being used.
Before writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 02 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 02