You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeError: unsupported operand type(s) for +: 'int' and 'str' #21
---------------------------------------------------------------------------
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))
changed the title [-]TypeError: unsupported operand type(s) for +: 'int' and 'str' on tf[/-][+]TypeError: unsupported operand type(s) for +: 'int' and 'str'[/+]on Mar 12, 2017
Activity
[-]TypeError: unsupported operand type(s) for +: 'int' and 'str' on tf[/-][+]TypeError: unsupported operand type(s) for +: 'int' and 'str'[/+]luispedro commentedon Jun 25, 2017
Sorry, I had missed this bug report. Fixed.