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, 23.06.2019 00:40
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why.a.) student.course.callnum = "csc230"; b.) cin > > student.name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student.name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist.course.credits = 3; j.) course = studenttype.course;
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
question
Computers and Technology, 24.06.2019 05:30
Why is hard disk space important to an audio engineer? why are usb ports and firewire ports useful for an audio engineer? explain in 2-3 sentences. (3.0 points) here's a list of different audio software: ableton live apple inc.'s garageband apple inc.'s logic studio digidesign's pro tools propellerhead sofware's reason sony creative software's acid pro steinberg cubase steinberg nuendo choose one of the software programs listed above, and then go to that software program's web site. read about what the software program is used for, and then write 4-5 sentences about what you learned. (10.0 points) which type of software license is the most limiting? why? explain in 2-3 sentences. (3.0 points) when sending a midi channel voice message, how can you control the volume of the sound? explain in 2-3 sentences. (4.0 points)
Answers: 1
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
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
question
Mathematics, 18.10.2019 13:10
question
English, 18.10.2019 13:10
Questions on the website: 13722363