Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following quote (also given as a text file): My name is Yoshikage Kira. I'm 33 years old. My house is in the northeast

Given the following quote (also given as a text file):

My name is Yoshikage Kira. I'm 33 years old. My house is in the northeast section of Morioh, where all the villas are, and I am not married. I work as an employee for the Kame Yu department stores, and I get home every day by 8 PM at the latest. I don't smoke, but I occasionally drink. I'm in bed by 11 PM, and make sure I get eight hours of sleep, no matter what. After having a glass of warm milk and doing about twenty minutes of stretches before going to bed, I usually have no problems sleeping until morning. Just like a baby, I wake up without any fatigue or stress in the morning. I was told there were no issues at my last check-up. I'm trying to explain that I'm a person who wishes to live a very quiet life. I take care not to trouble myself with any enemies, like winning and losing, that would cause me to lose sleep at night. That is how I deal with society, and I know that is what brings me happiness. Although, if I were to fight I wouldn't lose to anyone.

image text in transcribedYour job is to read the file and save it to a string variable. Then, you have to apply the stem function to each of its words and get the output as a list. An example output is given below:

['my', 'name', 'is', 'yoshikage', 'kira', "i'm", '33', 'years', 'old', , ]

After that, write a function named frequencies that outputs the frequency of the given word in the list. For example:

>>> frequencies(my_list, is)

>>> 4

Remember that you cannot use any sort of loop, list comprehension, or recursion. You can only use map, reduce!!!!

Given the following functions: def stem(word: str): return word. lower().rstrip(",.!:;'-"").lstrip("'"") def read_file(): with open ("quote.txt", "r") as quote_f: quote = quote_f.read() return quote

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

Students also viewed these Databases questions