7 votes
Accepted

IndexError in initial state of pset6 Sentiments

This command pip3 install --user -r requirements.txt --upgrade solves the problem according to this post on reddit (and the comments here :).
user avatar
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() ...
user avatar
  • 20.7k
2 votes
Accepted

Confused by NLTK

You are right, this is confusing and it's not in the documentation. Since you are new in Object Oriented Programming, I'll try to explain it as simple as I can. In OOP, the main difference from a non-...
user avatar
  • 7,326
1 vote
Accepted

Tokenizer adds space before text

Are you sure it's adding a space, and you're not just printing a space using print? Consider print('token: "{}"'.format(token)) Added " so it's clear where the token begins and ends. Is there an ...
user avatar
  • 20.7k
1 vote
Accepted

Sentiments "tweets" elif statement error

Looks like unbalanced parentheses in the line above the elif.
user avatar
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.
user avatar
  • 18.4k
1 vote

Some basics of python

Both single and double quotation marks in python are used to specify some string data. For instance def func(): """This is a docstring, it's similar to what a comment is!"""" a = 'This is a ...
user avatar
  • 3,326
1 vote
Accepted

Some basics of python

enclosing a set of characters inside a double quotes tells the interpreter to treat it as a string so you can perform the respective operations with it. e.g. "Hello", "123", "5", "5df", etc. In ...
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 ...
user avatar
1 vote
Accepted

A simple question in application.py sentiments

That default value for neutral is merely a placeholder at the start. When you run application.py without implementing it, you see a graph that is 100% neutral. You should initialize those values ...
user avatar
  • 1,424
1 vote
Accepted

Smile/Analyzer always return 0

tokenize returns a list, therefore tokens is a list from tokens = tokenizer.tokenize(text). Even if text is only one word. If text is 'cat', tokens is ['cat']. This if tokens==self.Pos[A]: can never ...
user avatar
1 vote

When I run ./tweets @user_name, I get API_KEY not set and when do flask run ,I get this e What could be wrong?

Here's a trick that might make the API_KEY/SECRET easier to manage. Create a new file in your sentiments directory (I call mine twitkeys). Type or copy/paste the two export commands into this file and ...
user avatar
1 vote
Accepted

Pset6 2017 application.py Sentiments

Yes, in the application.py you need to implement almost the same code as you have written in tweets. load positive.file and negative.file into memory analyze each tweet positive = 0 negative = 0 ...
user avatar
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.
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible