Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is ar_lst Problem 5 (4 pts.): Iterate over ar_list and print the name of each reviewer (author) and the total number of *different*, i.e.
Here is ar_lst
Problem 5 (4 pts.): 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. [ ]: from collections import Counter import re 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 H used 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. TimothyFlorida used 70 unique words. KarenArmstrong_BC used 107 unique words. Shane33333 used 51 unique words. Bnkruzn used 16 unique words. 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 lst list. print(f'There are {len(ar_lst)} elements in the list.') Problem 5 (4 pts.): 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. [ ]: from collections import Counter import re 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 H used 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. TimothyFlorida used 70 unique words. KarenArmstrong_BC used 107 unique words. Shane33333 used 51 unique words. Bnkruzn used 16 unique words. 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 lst list. print(f'There are {len(ar_lst)} elements in the list.')
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