-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalltehdat.py
64 lines (45 loc) · 1.37 KB
/
alltehdat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!usr/env/python
# This program is a word frequency analyzer you can interact with it a
#and find interesting things about words!
import facebook
import simplejson as json
import requests
#gets a shitload of data
#change value of xrange to get all teh dataz
#need to update the token every so often for now, about every hour
oauth_access_token = "own key here"
graph = facebook.GraphAPI(oauth_access_token)
newf = graph.get_connections("TuftsConfessions", "feed")
#adds messages and other info into list of dictionaries
#returns the url of the next page to get
string_god_dayum = []
def addData(json_body):
for i in json_body['data']:
#creates a dictionary with the message and time
string_god_dayum.append(i['message'])
return json_body['paging']['next']
#gets data
for x in xrange(1,330):
url = addData(newf)
r = requests.get(url)
if r.status_code != 200:
break
newf = json.loads(r.text)
word_dictionary = {}
def is_in(word, word_dictionary):
for key in word_dictionary:
if word in word_dictionary:
return False
return True
text_wordlist = []
for i in string_god_dayum:
text_wordlist = i.split()
for word in text_wordlist:
if is_in(word, word_dictionary):
word_dictionary[word] = 1
else:
word_dictionary[word] += 1
max_word = {}
max_word = sorted(word_dictionary, key=word_dictionary.get, reverse=True)[:100]
for key in max_word:
print key