result.dfs[wordid] = result.dfs.get(wordid, 0) + 1
// now make sure length(result) == get_max_id(corpus) + 1
if (id2word is None): id2word = list(map(str, xrange(max_id + 1)))
for i in xrange(max_id + 1):
result.token2id[id2word[i]] = i
result.dfs[i] = result.dfs.get(i, 0)
After Change
if id2word is None:
// make sure length(result) == get_max_id(corpus) + 1
result.token2id = dict((unicode(i), i) for i in xrange(max_id + 1))
else:
// id=>word mapping given: simply copy it
result.token2id = dict((utils.to_unicode(token), id) for id, token in iteritems(id2word))
for id in itervalues(result.token2id):