In Python, compute the following:
(A) Define a function tokenize to tokenize text and remove stop words
(B) Define a function sentiment_analysis to count the positive and negative words in the tokenized text. [Positive words are either a positive word not preceded by a negation word, or a negative word preceded by a negation word. Negative words are either a negative word not preceded by a negation word or a positive word preceded by a negation word.] Determine the sentiment of the string as follows: 2: number of positive words > number of negative words or 1: number of positive words <= number of negative words. Return sentiment.
(C) Define a function performance_evaluate the accuracy of the sentiment analysis in (B). Takes an input file (“amazon_review_300.csv”), a list of positive words, and a list of negative words as inputs. The input file has a list of reviews in the format of (label, review). Reads the input file to get a list of reviews including review text and label of each review. For each review, predict its sentiment using the function defined in. Return the accuracy as the number of correct sentiment predictions/total review.
# Structure of solution is as follows:
import nltk
# add import statements
def tokenize(text):
tokens = []
# add your code
return tokens
def sentiment_analysis(text, positive_words, negative_words):
negations=[“not”, “no”, “isn’t”, “wasn’t”, “aren’t”, “weren’t”, “don’t”, “didn’t”, “cannot”, “couldn’t”, “won’t”, “neither”, “nor”]
sentiment = None
# add your code
return sentiment
def performance_evaluate(input_file, positive_words, negative_words):
accuracy = None
# add your code
return accuracy
Looking for solution of this Assignment?

WHY CHOOSE US?
We deliver quality original papers |
Our experts write quality original papers using academic databases. |
Free revisions |
We offer our clients multiple free revisions just to ensure you get what you want. |
Discounted prices |
All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount |
100% originality |
We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity |
On-time delivery |
We will deliver your paper on time even on short notice or short deadline, overnight essay or even an urgent essay |