Question: Using Python write the tunc ready_for_work(): - This Python function takes a list of strings. It will be called with a list of real survey

Using Python write the tunc ready_for_work(): - This Python function takes a list of strings. It will be called with a list of real survey responses. - Each item in the list is a response forma different participant. - To meet the function requirements you need to a) combine all the individual strings into one big string with a space between each participant response. b) lowercase all the test c) remove all the punctuation d) convert any double or triple spaces to single spaces e) the function also has a parameter called min_count. If this number is greater than 0, then you are to remove any word from your big combined string that occurs Fewer than min_count times in the combined text. To achieve this, you should create a Counter. I've already imported the Counter class from the collections module. To use it, just call Counter(word_list) where word_list is a list of all of your words. This will produce a dict of all the words as keys and their frequency as volues. Use this dict to remove any words from your big combined strings that are too infrequent according to min_count. E.g., this call: wood chuck - I'How much wood would', 'a wood chuck chuck', 'if a wood chuck could chuck wood?, 'a wood Chuck would', 'chuck as much as he could", "a would chuck could', 'chuck wood!!') ready_for_work(responses-wood_chuck) would return this string: "how much wood would a wood chuck chuck it a wood chuck could chuck wood a wood chuck would chuck as much as he could if a would chuck could chuck wood" However, this call: ready_for_work(responses=wood_chuck, min_count=2) would internally generate this Counter (which can be uses exactly as if it were a plain dict object): Counter('chuck': 8, 'wood': 6, 'a': 4, would': 3, 'could': 3, 'much': 2, "T: 2, 'as": 2, "how": 1, "he":1}} and remove "how" and "he" from the combined string as they occurred fewer times than min_count. this would lead to a final returned string of: "much wood would a wood chuck chuck it a wood chuck could chuck wood a wood chuck would chuck as much as could if a would chuck could chuck wood" from pprint import pprint from copy import deepcopy from collections import Counter import string import random You can use try/except blocks whenever you see fit. #****** # These are "globat' variable that are automatically available to all functions. # DO NOT ALTER ANY GLOBAL VARIABLE IN ANY OF YOUR CODE!! wood_chuck = [How much wood would, a wood chuck chuck", f a wood chuck could chuck wood?', "a wood Chuck would', 'chuck as much as he could", "If a would chuck could', chuck wood!!'] def ready_for_work (responses: un countint -9.-> str: return None
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
