Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Iterate over ar_list and print the name of each reviewer (author) and the total number of *different*, i.e. *unique*, words in his review. For example,
Iterate over ar_list and print the name of each reviewer (author) and the total number of *different*, i.e. *unique*, words in his review. For example, "We stayed here and we liked it" contains 6 *unique* words since 'we' is repeated. Either of the three methods shown below are fine. Data consists "Author" and "Review".
from collections import Counter import re ar lst = [] for review in reviews: ar_dict={} ar_dict["Comments" ] = review["content"] ar dict["Author"] = review [ "Author"] ar_lst.append(ar_dict) # Let us check that we have 233 elements in the ar_1st list. print(f 'There are {len(ar_lst)} elements in the list.') for review in ar_lst: # TO DO: (1) Get the number of words in the current review variable. (2) Print the author's name and the number of (unique) words in his review Below are three approaches listed in increasing "sophistication". Three possible approaches... 1) Removing spaces between words and then counting uniques. gowharr32 used 91 unique words. Nancy W used 90 unique words. Janet Hused 44 unique words. TimothyFlorida used 70 unique words. KarenArmstrong_BC used 111 unique words. Shane33333 used 51 unique words. Bnkruzn used 16 unique words. 2) Converting to lower case, removing spaces and then counting uniques. gowharr32 used 90 unique words. Nancy W used 88 unique words. Janet H used 43 unique words. Timothy Florida used 70 unique words. KarenArmstrong_BC used 107 unique words. Shane 33333 used 51 unique words. Bnkruzn used 16 unique words. 3) Removing punctuation, converting to lower case, removing spaces and counting uniques. Note: That symbols that were considered "punctuation" and removed to generate the output below were: .,;: @ # $ ?>Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started