5
votes
Accepted
pset6 tweets, analyze.py and application.py
Maybe a simple typo in tweets here score = analyzer.analyze(tweets), since you want to send one tweet at a time.
Also, beware here: token.lower(). The lower method returns the string in lower case, ...
- 27.5k
4
votes
Error in pset6 API Key not set
Make sure you're running flask in the same terminal window in which you exported the keys.
- 183
3
votes
Accepted
pset6 - tweets, get_user_timeline function
Try it without the '@' prefix. get_user_timeline calls twitter.lookup_user(). The example in the twitter API doc shows screen_name without the '@' in the example.
- 27.5k
3
votes
Accepted
Python. Can't understand this code
The [expression_using_X for X in Y] is evaluating expression_using_X for every X being an element of Y, and the [] make that list of expression values a Python list.
squares = [x**2 for x in range(11)...
- 20.8k
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 ...
- 27.5k
1
vote
Accepted
Sentiments "tweets" elif statement error
Looks like unbalanced parentheses in the line above the elif.
- 27.5k
1
vote
Accepted
pset6 sentiments tweets
The most serious error I see in the first view is on the next line:
file = open(positives, "r")
keep in mind that both positives and negatives are variables that are meant to be a (disordered) set ...
- 5,201
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 ...
- 27.5k
1
vote
Accepted
pset6 tweets subtraction when word is negative doesn't work
elif text.lower() in self.neg_words:
shouldn't that be token.lower()?
- 18.5k
1
vote
Accepted
I don't understant how TweetTokenizer works
TweetTokenizer is a class in the nltk.tokenize.casual module.
When you use the name of the class as a function, like:
tokenizer = TweetTokenizer()
that function, in Object Oriented Languages, is ...
- 7,366
1
vote
Accepted
Why am I getting TypeError: expected string or buffer?
The problem is get_user_timeline because it returns a list of strings i.e you can't just pass it to the tokenize function.
Instead you have to iterate over the strings and tokenize them seperatly.
- 162
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
tweets × 18pset6 × 11
sentiments × 7
pset6-sentiments × 5
analyzer × 5
python × 2
cs50x × 1
cs50x2017 × 1
application.py × 1
staffsolution × 1
score × 1
analyzer.py × 1
install × 1
api-key-not-set × 1