Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Print words with largest weights.
#!/usr/bin/env python
import sys
Dict = []
with open('aclImdb/imdb.vocab','r') as f:
for line in f:
with open('audit.log','r') as f:
line = f.readline()
parts = line.split()
for part in parts:
if part[0]=='C': continue
bits = part.split(":")
wordidx = int(bits[0].split("^")[1])
if float(bits[3]) > 0: sent = '+'
elif float(bits[3]) < 0: sent = '-'
else: sent = '?'
if wordidx < 1000:
print "%20s: %s %0.4f" % (Dict[wordidx], sent, abs(float(bits[3])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.