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, ...
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-...
  • 7,356
2 votes

i cant set up twitter developer account for pset6 sentiments tweets

sentiments is not included in the 2018 CS50x courseware. Two options would be to Use the current courseware, which includes the Similarities project OR Make sure you follow the suggestions in the ...
2 votes
Accepted

PSET6 credit.py, not able to import 'get_long_long'

Python doesn't have a long long type. You can use get_int to hold your credit card number.
  • 18.4k
2 votes
Accepted

Struggling to load positive and negative words in analyzer.py, PSET6 2017

"Instance of 'set' has no 'adds' member" - this is on lines 18 and 28 - the "self.positives.adds(..." lines. The set operator is the singular add. Notice Prof is (presumably) having the same error: ...
1 vote

Struggling to load positive and negative words in analyzer.py, PSET6 2017

The function for adding elements to set in python is add() not adds(). Moreover in your last line of code you have called the load() function but you have not passed the required parameters. i.e the ...
1 vote
Accepted

pset6 - builtins.importerror when run webserser

Have you done all the steps in Sentiments#Getting Started, especially the first one? Some people reported that using pip3 install --user -r requirements.txt with an additional --upgrade appended as ...
  • 20.7k
1 vote
Accepted

pset6 caesar.py Invalid output only with lowercase characters

The solution is simple, you are calling the isupper and islower functions without parenthesis, the correct way is: if c.isupper(): if c.islower():
  • 5,181
1 vote
Accepted

CS50 2017: string index out of range when trying to load words into dictionary (dict.update())

Maybe you have a string that's empty, so has no character at index 0. There's no string terminator like in C that you could access.
  • 20.7k
1 vote
Accepted

How can for File IO works in Python?

Python file objects are also iterators, that's how for uses them. It keeps calling the iterator's next method, which spits out a single line at a time. Just don't combine this implicit next and any ...
  • 20.7k
1 vote
Accepted

TweetTokenizer don't process 3 specific words

It's not a "mistake" in tokenizer, it is how tokenizer works. It creates separate tokens for "punctuation", as is evidenced by the examples in the doc: >>> s0 = "This is a cooool #...
1 vote
Accepted

Pset 6 Words are randomly not being added to the dictionary

I think your list usage is fine, but a see a few possible problem spots. 1) In your init function you open your positives and negatives documents with "r" which already means you are reading the file,...
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 ...

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