This is an OPTIONAL assignment. It will in no way affect your grade if you do or do not hand this in.
hw2-extra.arr
. Hand in your work on Gradescope. There is a separate assignment location than the assignment location for the rest of Homework 2.When we use a search engine, ads related to those searches sometimes appear in the same window. That suggests that the content of our search terms (also known as "queries") might be used to select ads. For this problem, you will work with a simple version of this setup.
Assume that an ad is an arbitrary String and that a query can have up to three words (such as "bike", "store", "providence"). We want to rate an ad for how well it fits these three words. We will score each word against the ad. A word contributes a score of 1 if it (or a simple modification to it) appears in the ad; otherwise it contributes 0. The rating for an ad against the whole query is the sum of the ratings for each of the three query words divided by the length of the ad String (in characters).
For this question, we will consider modifications that make a word singular (by removing an "s" from the end, e.g. "helmets" -> "helmet"
) or turn a gerund into a verb (by removing "ing" from the end, e.g. "skateboarding" -> "skateboard"
). This means that any of the query words can score against an ad with or without an ending removed.
Task: Complete the following function:
Your work should emphasize two skills:
This question doesn't earn any points. It is meant to let you fine-tune your skills at structuring code and to practice developing good sets of examples to illustrate a problem.