Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please get my right, the last time it was incorrect. Compulsory Task 1 Follow these steps: - Create a file called semantic.py and run all
please get my right, the last time it was incorrect.
Compulsory Task 1 Follow these steps: - Create a file called semantic.py and run all the code extracts above. - Write a note about what you noticed interesting about the similarities between cat, monkey and banana and think of an example of your own. - Run the example file on with the simpler language model 'en' and write a note on what you notice different from the model 'en_core_web_md' Compulsory Task 2 Let us build a system that will tell you what to watch next based on the word vector similarity of the description of movies. - Read in the movies.txt file. Each separate line is a description of a different movie. - Your task is to create a function to return which movies a user would watch next if they have watched Planet Hulk with the description "Will he save their world or destroy it? When the Hulk becomes too dangerous for the Earth, the Illuminati trick Hulk into a shuttle and launch him into space to a planet where the Hulk can live in peace. Unfortunately, Hulk land on the planet Sakaar where he is sold into slavery and trained as a gladiator." - The function should take in the description as a parameter and return the title of the most similar movie. \# *** IF YOU DID NOT INSTALL NOTEPAD++ AND PYTHON (VERSION 2.7.3 or 2.7.5 ) *** \# *** PLEASE STOP READING THIS NOW, OPEN THE INSTALLERS FOLDER IN THIS DIRECTORY, \# RUN BOTH FILES TO INSTALL NOTEPAD++ AND PYTHON. *** \# PLEASE ENSURE YOU OPEN THIS FILE IN NOTEPAD++ OR IDLE otherwise you will not be able to read it. \# *** NOTE ON COMMENTS *** \# This is a comment in Python. \# Comments can be placed anywhere in Python code and the computer ignores them - they are intended to be read by humans. \# Any line with a \# in front of it is a comment and any with is also a docstring. \# Please read all the comments in this example file and all others. import spacy \# importing spacy nlp= spacy. Load('en_core_web_md') \# specifying the model we want to use. Remember to install this model by typing python -m spacy download en_core_web_md into your command line and compare them. \# be low we have two lists: one containina comolaints submitted to a \# Below we have two lists: one containing complaints submitted to a company, and another of recipes found online. \# We want to establish how spaCy's model can identify similarities or dissimilarities between complaint and recipes. \# Make sure to run this example file and read through the explanations. \# Below is a list of six complaints. complaints = [ 'We bought a house in CA. Our mortgage was handled by a company called ki. Soon after the mortgage was sold to ABC. Shortly after that XYZ took over the mortgage. The other day we got a notice not to send our payment to them but to loi instead. This is all so frustrating and wreaks of the mortgage nightmare.", 'I got approved for a loan to buy a house I have submitted everything I need to for them I paid for the inspection and paid good faith check after all of that they said I did not get approved for the loan to cancel my contract because they do not want to wait for the down payments assistant said that the Sellers do not want to wait that long I feel like they are getting over on me I feel that they should have told me that I did not get approved before I spent my money and picked out a house Carrington mortgage in Ohio', 'As per the correspondence, I received from : The University This is to inform you that I have recently pulled my credit report and noticed that there is a collection listing from The University on my credit report. I WAS never notified of this collection action or that I owed the debt. This letter is to inform you that I would action or that I owed the debt. This letter is to inform you that I would like a verification of the debt and juilo ability to collect this money from me. 'I am writing to dispute the follow information in my file.ON BOTH TransUnion \&. for {$15000.00}. I have contacted this agency to advise to STOP CALLING ME this case was dismissed in court 2014. Please see the attached document from County State Court. Thanking you in advanced regarding this matter.', 'I have not had a XXXX phone since early 2007. I have tried to resolve my bill in the past but it keeps reposting an old bill. I have no way to provide financial info from 8 years ago and they know that so they want me to prove it to them but I have no way to do that. Is there anyway to get to find out how old it is.", 'I posted dated a check and mailed it for 2015 for my mortgage payment as my mortgage company will only take online payments if all the late charges are paid at once ( also illegal), and the check was cashed on 2015 which cost me over {$70.00} in over draft fees with my bank.' \# We will now compare the similarity of the complaints to ascertain if spaCy's similarity \# model is able to distinguish between these long pieces of text. \# Below is a list of six recipe instructions. recipes= [ 'Bake in the preheated oven, stirring every 20 minutes, until sugar mixture has baked and caramelized onto popcorn and cashews, about 1 hour. Spread cashew caramel corn onto a parchment paper-lined baking sheet to cool. If desired, form into balls while still warm.', 'Combine brown sugar, corn syrup, butter, salt, and cream of tartar in a large saucepan. Bring to a boil, stirring constantly, until a candy thermometer inserted into the middle of the syrup, not touching the bottom, reads 260 degrees F (127 degrees C), 6 to 8 minutes. 'Lift marshmallow fudge out of the pan by the edges of the foil and place on a large cutting board. Dip a large knife in the remaining confectioners\' sugar and slice fudge into 1 1/2-inch squares, continually dipping knife in the sugar after each slice.", 'Melt butter in a medium saucepan over medium heat; stir in condensed milk. Pour in chocolate chips; cook and stir until melted, 5 to 10 minutes.", 'Lightly grease a cookie sheet. Deflate the dough and turn it out onto a lightly floured surface. Roll the marzipan into a rope and place it in the center of the dough. Fold the dough over to cover it; pinch the seams together to seal. Place the loaf, seam side down, on the prepared baking sheet. Cover with a damp cloth and let rise until doubled in volume, about 40 minutes. Meanwhile, preheat oven to 350 degrees F (175 degrees C), 'In a large bowl, cream together the butter, brown sugar, and white sugar. butter, brown sugar, and white sugar. Beat in the instant pudding mix until blended. Stir in the eggs and vanilla. Blend in the flour mixture. Finally, stir in the chocolate chips and nuts. Drop cookies by rounded spoonfuls onto ungreased cookie sheets." ] \# We will now compare the similarity of the recipes. to ascertain how well spaCy's similarity \# model is able to distinguish between them. print("-_-_-_-_-_Recipes for token in recipes: token =nlp (token) for token_ in recipes: token_ = nlp(token_) print(token.similarity(token_)) \# Now we want to obtain the extent of similarity between the complaints and the recipes. \# we will loop through every recipe instruction and compare it with a complaint. print("-__Recipes similarity-_-") for token in recipes: token = nlp(token) for token_ in complaints: token_ = nlp(token_) \[ \text { print(token. similarity(token_)) } \] \# What do you observe? Note that the similarity index has reduced from what we observed in the short-text example discussed in the content PDF. \# There are several ways to make your similarity-roven in recipes: for token token = nlp(token) for token_ in recipes: token_= nlp(token_) print(token. similarity(token_)) \# Now we want to obtain the extent of similarity between the complaints and the recipes. \# we will loop through every recipe instruction and compare it with a complaint Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started