---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-5511c9e27cd2> in <module>()
37 for ti in range(model.num_topics):
38 words = model.show_topic(ti, 64)
---> 39 tf = sum(f for f, w in words)
40 with open('topics.txt', 'w') as output:
41 output.write('\n'.join('{}:{}'.format(w, int(1000. * f / tf)) for f, w in words))
TypeError: unsupported operand type(s) for +: 'int' and 'str'
I think, since the frequency, f, and word, w, are the opposite on words, did you want to write w, f in words instead, as in the following?
39 tf = sum(f for w, f in words)
40 with open('topics.txt', 'w') as output:
41 output.write('\n'.join('{}:{}'.format(w, int(1000. * f / tf)) for w, f in words))