Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose you have a text file (.txt) and want to analyze the sentiment of the text on the sentence level. That is, we want to
Suppose you have a text file (.txt) and want to analyze the sentiment of the text on the sentence level. That is, we want to classify each sentence in this text as having either positive, neutral, or negative sentiment. The following three sentences illustrate each sentiment type. For example, I am so excited about my new car. (Positive sentiment) I feel tired and moody today. (Negative sentiment) There is parked car on the street. (Neutral sentiment) To aid us in deciding which words carry positive, neutral, or negative sentiment, we will consult the two files positivesentimentwords.txt (http://homepages.math.uic.edu/~adrovic/mcs260-s2018/project2/positivesentimentwords.txt) and negativesentimentwords.txt (http://homepages.math.uic.edu/~adrovic/mcs260-s2018/project2/negativesentimentwords.txt). Each of these files contains a list of words that are generally associated with positive/negativesentiment. The classification of each sentence as being positive, neutral, or negative is based on the following assessment. If more words in a sentence carry the positive sentiment than negative, we will classify that sentence as having a positive sentiment. If the number of positive and negative words in a sentence is equal, we will classify that sentence as neutral. Otherwise, the sentence is classified as having a negative sentiment. Upon completion, your code should print sentence counts for each sentiment type: Positive: Negative:
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