if start_ind <= term[1] <= end_ind)
// get all token combinations within window
for t1, t2 in itertools.combinations(window_terms, 2):
if t1 == t2:
continue
n_coocs[t1[0]][t2[0]] += 1
try:
sum_logdists[t1[0]][t2[0]] += \
log_(window_width / abs(t1[1] - t2[1]))
After Change
// get all token combinations within window
for t1, t2 in itertools.combinations(window_terms, 2):
n_coocs[t1[0]][t2[0]] += 1
sum_logdists[t1[0]][t2[0]] += log_(window_width / max(abs(t1[1] - t2[1]), 1))
if end_ind > n_toks:
break