Created
April 17, 2012 18:57
-
-
Save crizCraig/2408259 to your computer and use it in GitHub Desktop.
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
synonyms = {'scotty': 'dog', 'puppy': 'dog', 'dog': 'dog'} | |
counts = [(2, 'dog'), (2, 'puppy'), (2, 'scotty')] | |
syn_counts = [] | |
for count in counts: | |
syn_counts.append((count[0], synonyms[count[1]])) | |
print syn_counts | |
sum_counts = {} | |
for syn_count in syn_counts: | |
try: | |
sum_counts[syn_count[1]] += syn_count[0] | |
except: | |
sum_counts[syn_count[1]] = syn_count[0] | |
print sum_counts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment