Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 10074

Questions related to the pset6 exercise: Sentiments. In particular, issues with implementing analyzer.py

1 vote
Accepted

Analyze doesn't show colors

poss and negs are not instance variables, so they are not available to analyze. From the Hints section of the spec: If you would like a variable to be accessible from both __init__ and analyze, …
DinoCoderSaurus's user avatar
7 votes
Accepted

Instance of 'Analyzer' has no 'tokenizer' member

You don't have a "thing" named tokenizer. Review the hints section of the spec: Odds are you’ll find nltk.tokenize.casual.TweetTokenizer of interest, which can be used to tokenize a tweet (i.e., …
DinoCoderSaurus's user avatar
1 vote
Accepted

pset6 sentiments PYTHON analyze

As per the spec [emphasis added]: ...among whose features is a tokenizer that you can use to split a tweet (which is maximally a 140-character str object) into a list of words (i.e., shorter str o …
DinoCoderSaurus's user avatar
1 vote
Accepted

Pset6 analyzer.py not incrementing counter

One problem is here self.positives.add(line.strip). line.strip returns the method whereas line.strip() returns the result of the method. (Ditto negatives). You could do a quick test in command-line p …
DinoCoderSaurus's user avatar
1 vote

PSET6/Sentiments/analyzer.py, tweets

This syntax if word.lower() in self.positives == True: is the problem. Use if word.lower() in self.positives (without the equality). I don't remember the exact evaluation/operator precedence rules tha …
DinoCoderSaurus's user avatar
0 votes
Accepted

pset6: why is my version of the analyzer not working?

Big problem here str(tokensii). tokenizer returns a list. str returns a string. for token in tokens iterates over each character in the string. It may look ok here print(tokens), but tokens is not a l …
DinoCoderSaurus's user avatar
0 votes

Lost trying to figure out sentiments PSET 6 2017

One problem in analyze is with split here self.negatives.extend(line.split()). split returns a list. You would have to put token in a list to find it in self.positives or self.negatives. Or perhaps y …
DinoCoderSaurus's user avatar
2 votes
Accepted

Pset6 Tweets output score and color different to staff version

This line token.lower() does not change token to lower case, it returns a copy of token in lower case. You can either set something to that return value (as with word = token.lower()) and then test fo …
DinoCoderSaurus's user avatar