Created
April 29, 2015 22:34
-
-
Save judell/a63c392c4b4f64776fb9 to your computer and use it in GitHub Desktop.
tag concordance
This file contains hidden or 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
import json | |
f = open('c:\\users\\jon\\all_annos.json','r') | |
s = f.read().decode('utf-8') | |
j = json.loads(s) | |
s = '' | |
all_tags = {} | |
for row in j: | |
try: | |
user = row['user'].replace('acct:','') | |
if row.has_key('tags'): | |
tags = row['tags'] | |
for tag in tags: | |
if all_tags.has_key(tag): | |
all_tags[tag] += 1 | |
else: | |
all_tags[tag] = 1 | |
uri = row['uri'] | |
line = '%s\t%s\t%s\n' % (user, uri, ','.join(tags)) | |
s += line | |
except: | |
print row['uri'] | |
f = open('c:\\users\\jon\\all_tags.txt','w') | |
f.write(s.encode('utf-8')) | |
f.close() | |
s = '' | |
keys = all_tags.keys() | |
keys.sort() | |
for key in keys: | |
s += '%02d: %s\n' % (all_tags[key], key) | |
f = open('c:\\users\\jon\\tag_concordance.txt','w') | |
f.write(s.encode('utf-8')) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment