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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:10
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Which steps will open the system so that you can enter a question and do a search for
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
What are the charges for invasion of privacy on computers
Answers: 1
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
question
History, 24.03.2021 02:10
question
Mathematics, 24.03.2021 02:10
question
Mathematics, 24.03.2021 02:10
question
Mathematics, 24.03.2021 02:10
Questions on the website: 13722359