Quantcast
Channel: Machine Learning
Viewing all articles
Browse latest Browse all 62700

Basic Question from NLP Example

$
0
0

Hi All,

I'm teaching myself the basics of NLP in Python with the assistance of NLTK.

I have been teaching myself from the example here (http://andybromberg.com/sentiment-analysis-python/) with source code here (https://github.com/abromberg/sentiment_analysis_python/blob/master/sentiment_analysis.py). There were several problems with the example being outdated, such as their use f the print function without the parends. I have fixed that.

For some reason, in the example the code:

def find_best_words(word_scores, number): best_vals = sorted(word_scores.iteritems(), key=lambda (w, s): s, reverse=True)[:number] best_words = set([w for w, s in best_vals]) return best_words

Has a syntax error saying:

best_vals = sorted(word_scores.iteritems(), key=lambda(w, s): s, reverse=True)[:number] ^ SyntaxError: invalid syntax

Any ideas?

Thanks!

submitted by kylecares
[link][3 comments]

Viewing all articles
Browse latest Browse all 62700

Trending Articles