Question: 1. Convert the string to only lowercase letters (let the result be called Si). Hint: there is a buit-in string method that does this) 2.

 1. Convert the string to only lowercase letters (let the result

1. Convert the string to only lowercase letters (let the result be called Si). Hint: there is a buit-in string method that does this) 2. Remove all non-alphabetical characters from S except for spaces (et the result be called S2). 3. Use the split() method on S2 to produce a list L of words occurring in S. 4. By using the python set type, produce a set W of all the unique words occurring in L. What is the ratio of the length of W to the length of L? 5. Use W to produce a list W S of the words in W occurring in sorted order 6. Create a function word_vector (WS, L) that takes WS and L as input and returns a numpy array N of length Len (wS) such that for each t in range ( len (WS ) ), NI] is equal to the number of times the word ws[iroccurs in L 7. Create a function cos sim(N,M) that computes the cosine similarity of two word vectors (two outputs from word_vector called N and M) s"A deep, brutal cold set in across the Midwest on Wednesday, sending temperatures plummeting to depths that stunned even Midwesterners, a group accustomed to shrugging off winter. The cold that seized the middle of the country was the sort that makes cars moan, that makes breathing hurt, that makes any bit of exposed skin sting. cities like Chicago had been preparing for the deep freeze for days, so when it arrived, much of life had come to a standstill. Colleges and schools were closed all around, and even the United States Postal Service had stopped deliveries in some places. Workers were sent home, meetings canceled, parties called off And the worst of the blast was still to come: Forecasters said temperatures would drop again after sunset on Wednesday, and that Chicago might even break its record low of minus 27. The outlook for Thursday was different but still grim: slightly warmer temperatures- and snow

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!