// now make sure length(result) == get_max_id(corpus) + 1
if (tokens is None): tokens = map(str, xrange(max_id + 1))
tokens_iter = iter(tokens)
for i in xrange(max_id + 1):
result.token2id[next(tokens_iter)] = i
result.dfs[i] = result.dfs.get(i, 0)
logger.info("built %s from %i documents (total %i corpus positions)" %
After Change
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)