Skip to content

Commit 26a2507

Browse files
committed
ENH Write to a file, not stdout
1 parent 1edf567 commit 26a2507

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎ch04/blei_lda.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@
4343
for ti in xrange(model.num_topics):
4444
words = model.show_topic(ti, 64)
4545
tf = sum(f for f, w in words)
46-
print('\n'.join('{}:{}'.format(w, int(1000. * f / tf)) for f, w in words))
47-
print()
48-
print()
49-
print()
46+
with open('topics.txt', 'w') as output:
47+
output.write('\n'.join('{}:{}'.format(w, int(1000. * f / tf)) for f, w in words))
48+
output.write("\n\n\n")
5049

5150
try:
5251
from pytagcloud import create_tag_image, make_tags

0 commit comments

Comments
 (0)