Question: In this assignment, you are expected to write the specified functions accurately. These functions will take certain inputs as described. Your solution will be evaluated
In this assignment, 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. in this assignment. 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:
def readfilefilename:str:
with openfilename, r as file:
content file.read
return content
def stemword:str:
return word.lowerrstrip:;Istrip
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:
Parameters: None.
Functionality: This function should return a tuple containing your personal information in the following order: Your student ID your first name, your last name.
Example: myinfo should return something like "John", "Doe"Replace this example with your actual student ID and name.
countwordstringlist, word:
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.
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:
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.
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 appl count word to each word in the words list. Submission and Grading:
Test Cases:
Your program will be evaluated against several test cases, some of which will be visible to you, and others will be hidden.
Hardcoding solutions for visible test cases is strictly prohibited. If your program only works for the visible test cases through hardcoding, it will fail the hidden test cases and most likely receive a score of zero.
After completing your solution in a file named hwpy place it in the same directory as the provided "studenttesterpy file. Then, simply run "studenttesterpy which will automatically execute several test cases to check your functions. Passing both the visible and hidden test cases is required to receive full credit for the assignment.
Grading Criteria:
Programs that pass all test cases and obey the rules will receive full marks.
Programs that fail test cases may be manually reviewed and could receive partial credit based on the level of correctness and effort. Incomplete or incorrect solutions may result in a score of zero.
If AI detected in your assignment, you will get zero.
If you do not write your own information in my info function, you will get zero.
If you use forbidden methods, you will get zero.
Important Notes:
Only upload your program file named "studentidnamesurname.py
Do not change function names.
Your solution should include only function definition. Do not call functions in your program for the version you to upload.
Use functional programming tools like map, reduce, and filter to handle operations on lists. It is not mandatory to use all of them for every function, but your solution should incorporate at least one where applicable.
Avoid Hardcoding: Your solution should work for any valid input and must not rely on hardcode values for test cases. Solutions that are hardcoded to pass the visible test cases will fail hidden test cases and mav receive a score of zero
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
