Skip to content

Instantly share code, notes, and snippets.

@judell
Created April 29, 2015 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judell/a63c392c4b4f64776fb9 to your computer and use it in GitHub Desktop.
Save judell/a63c392c4b4f64776fb9 to your computer and use it in GitHub Desktop.
tag concordance
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