Created
April 9, 2012 15:00
-
-
Save Noleli/2344069 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
overlaps = [] | |
for postword in post: | |
matchcount = 0 | |
wordmatches = [] | |
for bncword in bnc: | |
if(postword['word'] == bncword['word']): | |
bnclogf = math.log(float(bncword['count'])) | |
wordmatches.append({'word': postword['word'], | |
'postlogf': postword['logf'], | |
'bnclogf': bnclogf, | |
'diff': float(postword['logf']) - bnclogf | |
}) | |
# find the max of duplicates | |
if len(wordmatches) > 0: | |
while len(wordmatches) > 1: | |
if wordmatches[0]['bnclogf'] > wordmatches[1]['bnclogf']: | |
del wordmatches[1] | |
else: | |
del wordmatches[0] | |
overlaps.append(wordmatches[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment