subject
Computers and Technology, 11.05.2021 20:20 joeyhd

Write a new program that computes the average score for all words in the movie reviews. txt file. You should do this by building a program that does the follow- ing: • Set up a new dictionary variable called 'words’ • Iterate over every review in the text file. • Examine every word in every review. If this is the first time you have seen this word (i. e. it is not in your dictionary yet) you should add a new entry into your dictionary for that word (i. e. the word becomes a new key in the dictionary). The value to store at this key should be a list that contains two elements - the review and the number 1 (indicating that you've seen this word 1 time) If you have seen the word before (i. e. it is already in your dictionary) then you should add the new score into your list and increase the number of times that you have seen this word. for example: 4 I loved it 1 I hated it ... might look like this as a dictionary: words['i'] = [5,2] words['loved'] = [4,1] words['it'] = [5,2] words ['hated'] = [1,1] Report to the user that the analysis of the 'movie reviews. txt' file has been com- pleted. Also give them a summary of how long this took (hint: import the time module and use time. time() to compute the current time before and after your analysis algorithm and then compute the difference). For example: Initializing sentiment database Sentiment database initilization complete Total unique words analyzed: 16643 Analysis took 0.19 seconds to complete • Next, ask the user for a phrase. Analyze each word in this phrase and use your dictionary to compute the average score for each word. Also compute whether the overall phrase is positive or negative by averaging together the scores for each word that is contained within the phrase. For example: Initializing sentiment database Sentiment database initialization complete Total unique words analyzed: 16643 Analysis took 0.18 seconds to complete Enter a phrase to test: i loved it * 'i' appears 422 times with an average score of 1.8222748815165877 * 'loved' appears 9 times with an average score of 2.6666666666666665 * 'it' appears 2402 times with an average score of 1.9904246461282264 Average score for this phrase is: 2.15978873143716 This is a POSITIVE phrase Initializing sentiment database Sentiment database initialization complete Total unique words analyzed: 16643 Analysis took 0.17 seconds to complete Enter a phrase to test: this movie was awful * 'this' appears 994 times with an average score of 1.9657947686116701 * 'movie' appears 968 times with an average score of 1.8305785123966942 * 'was' appears 169 times with an average score of 1.621301775147929 * 'awful' appears 23 times with an average score of 1.0869565217391304 Average score for this phrase is: 1.626157894473856 This is a NEGATIVE phrase Initializing sentiment database Sentiment database initialization complete Total unique words analyzed: 16643 Analysis took 0.18 pseconds to complete Initializing sentiment database Sentiment database initialization complete Total unique words analyzed: 16643 Analysis took 0.18 seconds to complete Enter a phrase to test: happy birthday sad kitten * 'happy' appears 17 times with an average score of 2.588235294117647 * 'birthday' appears 9 times with an average score of 2.7777777777777777 * 'sad' appears 33 times with an average score of 2.212121212121212 * 'kitten' appears 1 times with an average score of 2.0 Average score for this phrase is: 2.3945335710041595 This is a POSITIVE phrase Initializing sentiment database Sentiment database initialization complete Total unique words analyzed: i16643 tAnalysis took 0.18 seconds to complete Enter a phrase to test: it made me want to poke out my eyeballs * 'it' appears 2402 times with an average score of 1.9904246461282264 * 'made' appears 148 times with an average score of 1.945945945945946 * 'me' appears 80 times with an average score of 1.575 * 'want' appears 67 times with an average score of 1.8208955223880596 * 'to' appears 2996 times with an average score of 1.959279038718291 * 'poke' does not appear in any moview reviews * 'out' appears 298 times with an average score of 1.8187919463087248 * 'my' appears 83 times with an average score of 2.036144578313253 * 'eyeballs' appears 1 times with an average score of 1.0 Average score for this phrase is: 1.7683102097253127 This is a NEGATIVE phrase • Important note: You must use a dictionary to solve this problem, and you may only analyze the 'moview review. txt' file ONE TIME. You CANNOT re-analyze the file over and over again (i. e. for the phrase 'happy birthday' you can't iterate over every movie review to find all occurrences of 'happy and then repeat this process to find all occurrences of 'birthday')

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 19:40, queenskyyt
Write the quartstogallons java class that declares a named constant to hold the number of quarts in a gallon (4). also declare a variable to represent the number of quarts needed for a painting job, and assign an appropriate value—for example, 18. compute and display the number of gallons and quarts needed for the job. display explanatory text with the values, for example:
Answers: 2
image
Computers and Technology, 22.06.2019 07:20, Hcalhoun21
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, Jessieeeeey
Kto rozmawia z clamentain przez krótkofalówke w the walking dead która śledzi lee w 4 epizodzie
Answers: 1
image
Computers and Technology, 23.06.2019 14:00, ava5015
What is html ? give a small description about html
Answers: 2
You know the right answer?
Write a new program that computes the average score for all words in the movie reviews. txt file. Yo...

Questions in other subjects:

Konu
Mathematics, 02.12.2020 19:00
Konu
Mathematics, 02.12.2020 19:00