Skip to content

Commit

Permalink
reconstruct writes to file
Browse files Browse the repository at this point in the history
  • Loading branch information
msimchowitz committed May 13, 2014
1 parent df706ad commit e078783
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions slda_input_files/reconstruct.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
parser.add_argument('term_file')
args = parser.parse_args()

term_topic = file('tokens.txt', 'w+')


terms = file(args.term_file).read().split('\n')
i = 0

for line in file(args.model_file).readlines():
data = line.split(' ')[1:]

print str(i) + '\t',
term_topic.write( str(i) + '\t')

for entry in data:
entry = entry.split(':')
term_index = int(entry[0])
term = str(terms[term_index]).replace(' ', '')
term_count = int(entry[1])
print ' '.join([term] * term_count),
print '\n',
term_topic.write( ' '.join([term] * term_count))
print term_topic.write('\n')
i += 1

0 comments on commit e078783

Please sign in to comment.