Created
August 15, 2014 09:46
-
-
Save JonnoFTW/659bfceda5e9f2e2489e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import re, praw | |
print "Fetching unimportant words..." | |
import nltk | |
nltk.download('stopwords') | |
from nltk.corpus import stopwords | |
c = Counter() | |
r = praw.Reddit(user_agent='praw') | |
username = 'username' | |
print "Logging in as",username | |
r.login(username,'password') | |
comments = r.get_redditor(username).get_comments(limit=None) | |
print "Fetching ALL your comments. This will take a while...." | |
stops = set(stopwords.words('english')) | |
reg = re.compile(r'([^\s\w]|_)+') | |
for i in comments: | |
line = re.sub(reg,'',i.body) | |
for word in line.split(): | |
word = word.lower() | |
if word not in stops: | |
c[word] +=1 | |
for i in enumerate(c.most_common(100),1): # Leave out 100 if you want them all | |
print i[0],i[1][0],i[1][1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment