7

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., split it up into a list of words) with code like: tokenizer = nltk.tokenize.TweetTokenizer() tokens = tokenizer.tokenize(tweet)


4

Make sure you're running flask in the same terminal window in which you exported the keys.


2

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 for word in the arrays, or change the test(s) from if token in self.positives: to if token.lower() in self.positives:


2

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() instead to remove all kinds of whitespace at both ends.


1

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

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 that apply.


1

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 python to see the difference. Python 3.4.3 (default, Jul 28 2015, 18:20:59) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more ...


1

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 objects). Program is trying to find a list of words in a list of words here if tokens in self.positives:. You want to test each word in tokens individually; you'...


1

Figured out myself... removed the == True comparison and it worked fine.


1

Maybe you skipped some points in Getting Started?


1

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

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, be sure to define it as an "instance variable" inside of [__init__]. For instance, if you were to define self.n = 42 inside of __init__, then self.n ...


1

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

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 voted, non community-wiki answers of a minimum length are eligible