Question: You are expected to write the specified functions accurately. These functions will take certain inputs as described. Your solution will be evaluated by running several
You are expected to write the specified functions accurately. These functions will take certain inputs as described. Your solution will be evaluated by running several test cases, including hidden tests. Note that it is forbidden to use loops, recursions and list methods like countappend etc.
You will use map, reduce and filter in your functions. Your program
should pass all of them to receive full credit. Use the given functions below:
Note: The readfile function expects the file to be in the same directory as the program; otherwise,
you must provide the full file path.
Required Functions:
myinfo:
o Parameters: None.
o Functionality: This function should return a tuple containing your personal information
in the following order: Your student ID your first name, your last name.
o Example: myinfo should return something like "John", "Doe"Replace this
example with your actual student ID and name.
countwordstringlist, word:
o Parameters:
stringlist list: A list of strings representing the text split into individual words.
word str: The target word whose frequency you want to count.
o Functionality: This function calculates and returns the frequency of the specified word in
the given stringlist. It uses the reduce function to iterate through the list and count
occurrences of the word. The comparison between words is caseinsensitive, and
punctuation marks are stripped using a helper function called stem
findfrequencystringlist, words:
o Parameters:
stringlist list: A list of strings representing the text split into individual words.
words list: A list of target words whose frequencies you want to count.
o Functionality: This function calculates the frequency of each word in the words list by
calling the countword function for each word. It returns a list of frequencies
corresponding to the order of words in the words list. The map function is used to apply
countword to each word in the words list
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
