Question: from textblob import TextBlob from statistics import * def sumMA(sentList): total=0 for l in sentList: total=total+l return total def meanMA(sentList): total=0 n=star_rating for l in
from textblob import TextBlob
from statistics import *
def sumMA(sentList):
total=0
for l in sentList:
total=total+l
return total
def meanMA(sentList):
total=0
n=star_rating
for l in sentList:
total=total+l
n=n+1
avg=total
return avg
def maxMA(sentList):
maxRating=sentList[0]
for l in sentList:
if l>maxRating:
maxRating=l
return maxRating
rating_text=[]
sent=[]
reviews=rating_text
for i in reviews:
print(i)
#create the object
review=TextBlob(i)
print(review.sentiment.polarity)
#add each sentiment to a list
sent.append(review.sentiment.polarity)
#print(review.noun_phrases)
#calculate average sentiment
avgSent=meanMA(sent)
sd=stdev(sent)
print("Average Sentiment:", avgSent)
print("Sentiment SD:", sd)
def main():
while True:
star_rating = int(input('Enter star rating: '))
if 1
break
print('Invalid star rating. Enter a rating between 1-10!')
while True:
rating_text = input('Enter rating text: ')
if 1
break
print('Invalid rating text. It should be between 1-30 length!')
print('Star rating is ' + str(star_rating))
print('Rating text is ' + rating_text)

Question 1. 50 points) 1. Write a program that accepts user input for reviews. 2. The program should allow the user to input data for the "star rating" and "review text" 3. The program should accept star ratings between 1 and 10. 4. The program should accept review text that has a length between 1 and 30 characters 5. The program should calculate the sentiment polarity for each review then add the sentiment polarity to a list. Program should also add the stars to a list. Compute the average, minimum, maximum, range, and standard deviation for both stars and the sentiment lists. Create functions to calculate the minimum, maximum, range, and average (DO NOT USE THE STATISTICS LIBRARY) 6. 7. 8. 9. You can use statistics library to calculate the standard deviation only. 10. Program should control for invalid input. 11. Use comments throughout your program 12. Print the results
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
