In the Document Distance problem from the first two lectures, we compared two documents by counting the words in each, treating these counts as vectors, and computing the angle between these two vectors. For this problem, we will change the Document Distance code to use a new metric. Now, we will only care about words that show up in both documents, and we will ignore the contributions of words that only show up in one document. Download,, and from the class Sakai site. is mostly the same as seen in class, however it does not implement vector angle or inner product; instead, it imports those functions from Currently, contains code copied straight from, but you will need to modify this code to implement the new metric. • Modify inner product to take a third argument, domain, which will be a set containing the words in both texts. Modify the code so that it only increases sum if the word is in domain. Don’t forget to change the documentation string at the top. • Modify vector angle so that it creates sets of the words in both L1 and L2, takes their intersection, and uses that intersection when calling inner product. Again, don’t forget to change the docstring at the top. Run to make sure your modified code works. The same test suite will be run when you submit to the class Sakai site. Does your code take significantly longer with the new metric? Why or why not? Submit on the class Sakai site. All code submitted for this class will be checked for accuracy, asymptotic efficiency, and clarity.

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now