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., ...
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.
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 ...
2
votes
Accepted
PSET6 2016 Analyzer.py - Says all is neutral
In analyze, shouldn't you use self.positives, and not open the files again?
Now to the real problems: .lstrip(" ") does not remove the line break at the end of the line, you could use .strip() ...
1
vote
Sentiments Analyzer always neutral
if words.lower is not actually doing anything.
Be very careful when you call a method that you don't forget the ():
if words.lower()
will work.
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 ...
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 ...
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 ...
1
vote
PSET6 Loading Positive/Negative Words in Analyzer
Figured out myself... removed the == True comparison and it worked fine.
1
vote
pset6-analyzer: Please, can someone help me out. Analyzer gives me this error!
Maybe you skipped some points in Getting Started?
1
vote
Accepted
Pset6 - Analyzer.py - Says Undeclared Function
Based on how you write that, I assume both load_words and __init__ to be methods.
As you made load_words a method, you'd have to call it like self.load_words instead of just load_words.
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, ...
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.
1
vote
Accepted
Why am I getting SyntaxError: invalid syntax when I'm running ./smile?
Do you mean to be checking if file starts with? or if the line starts with?
You have if not file.startswith ... so you are not checking the individual line.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
analyzer × 21pset6 × 16
sentiments × 7
tweets × 5
pset6-sentiments × 3
python × 2
analyzer.py × 2
token × 2
cs50x × 1
error × 1
function × 1
init × 1
staffsolution × 1
score × 1
tokenizer × 1
2017 × 1
api-key-not-set × 1
smile × 1