For analyzer.py, I think my code works for defining the first part: instantiation of the analyzer, but not for defining the second: analyze. Please see the failing part of my code below.
Also, I have one question - the walkthrough for analyzer.py mentions tokenization. If, however, tokenizing an article of 1000 words, for instance, only means splitting up the article into 1000 separate words, why do we have to tokenize the user's input to this program, if the program is set up to prompt the user to enter one and only one word? Any insight is highly appreciated, thank you!
def analyze(self, text): """Analyze text for sentiment, returning its score.""" tokenizer = nltk.tokenize.TweetTokenizer() tokensii = tokenizer.tokenize(text) tokens = str(tokensii).lower() print(tokens) score = 0 for token in tokens: if token in self.positives: score = score + 1 elif token in self.negatives: score = score - 1 return score