7

This command pip3 install --user -r requirements.txt --upgrade solves the problem according to this post on reddit (and the comments here :).


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.


2

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-OOP language, is the existence of classes. Now you may think of a class, as you think of a struct (i.e. a group of variables that serve a common goal), but ...


1

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 extra space?


1

Looks like unbalanced parentheses in the line above the elif.


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

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 string' b = "I am Knuth's fan." print(a) print(b) # Calling the function func() # Everything in python is Object, even functions! print(func) # ...


1

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 python array is referred to as a List and it is more flexible that C array as you can add and delete elements dynamically with no pre-definition of the size of list. ...


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

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 differently once you begin filling in the appropriate code there. As for your for loop, the logic is there for the variables, but there is one way of handling case ...


1

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 be true (nor the analogous test on sef.Neg[B]) because you are comparing a list (tokens) to one member of a list (ie a single word Pos[A], Neg[B]). You do ...


1

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 save it. Your file will look something like export API_KEY=whatever export API_SECRET=whatever (of course your KEY and SECRET instead of whatever). Now ...


1

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 neutral = 0 score = 0 for tweet in tweets: score = analyzer.analyze(tweet) if score > 0.0: positive += 1 elif score < 0.0: ...


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.


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