Skip to content

Instantly share code, notes, and snippets.

@jwf-zz
Created July 6, 2012 19:36
Show Gist options
  • Select an option

  • Save jwf-zz/3062323 to your computer and use it in GitHub Desktop.

Select an option

Save jwf-zz/3062323 to your computer and use it in GitHub Desktop.

Revisions

  1. jwf-zz created this gist Jul 6, 2012.
    21 changes: 21 additions & 0 deletions print_words.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/usr/bin/env python
    import sys

    Dict = []
    with open('aclImdb/imdb.vocab','r') as f:
    for line in f:
    Dict.append(line.strip())

    with open('audit.log','r') as f:
    f.readline()
    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])))