Question: Please complete in python 3. Part F Write a function, featurize , which takes a list of strings as its lone input argument: each element

Please complete in python 3.
Part F Write a function, featurize , which takes a list of strings as its lone input argument: each element is a string with the contents of an entire book. The output of this function is a 2D NumPy array of counts, where the rows are the documents/books (i.e., one row per element!) and the columns are the counts for all the words in the global vocabulary. For instance, if I pass a two-string list to featurize that collectively have 50 unique words between the two strings, the output matrix should have shape (2, 50) : the first row will be the respective counts of the words in that document, and same with the second row. The rows (documents) should be in the same ordering as they're given in the function's argument list, and the columns (words) should be increasing lexicographic order (aka alphabetic order). You are welcome to use your function from Part B, and from Part E (Part E's function would be particularly useful here, since that pretty much does all the heavy lifting, you'd just need to convert that dictionary to a matrix). NI Graded : Read Only kj = open("king_james_bible.txt", "r").read() wp = open("war_and_peace.txt", "r").read() matrix = featurize([kj, wp]) assert 2 == matrix.shape[@] assert 63889 == matrix.shape[1] assert 2 == int(matrix[:, 836). sum()) assert 16 == int(matrix[:, 62655]. sum()) : Read Only kj = open("king_james_bible.txt", "r").read() wp = open("war_and_peace.txt", "").read() md = open("moby_dick.txt", "r").read() cs = open("complete_shakespeare.txt", "-").read()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
