def segment(self, document):
<EOL>assert(len(document) > <NUM_LIT:0> and len([d for d in document if not isinstance(d, str)]) == <NUM_LIT:0>)<EOL>n = len(document)<EOL>self.window = max(min(self.window, n / <NUM_LIT:3>), <NUM_LIT:1>)<EOL>cnts = [Counter(self.tokenizer.tokenize(document[i])) for i in range(n)]<EOL>gap_score = [<NUM_LIT:0> for _ in range(n)]<EOL>for i in range(n):<EOL><INDENT>sz = min(min(i + <NUM_LIT:1>, n - i - <NUM_LIT:1>), self.window)<EOL>lcnt, rcnt = Counter(), Counter()<EOL>for j in range(i - sz + <NUM_LIT:1>, i + <NUM_LIT:1>):<EOL><INDENT>lcnt += cnts[j]<EOL><DEDENT>for j in range(i + <NUM_LIT:1>, i + sz + <NUM_LIT:1>):<EOL><INDENT>rcnt += cnts[j]<EOL><DEDENT>gap_score[i] = cosine_sim(lcnt, rcnt)<EOL><DEDENT>depth_score = [<NUM_LIT:0> for _ in range(n)]<EOL>for i in range(n):<EOL><INDENT>if i < self.window or i + self.window >= n:<EOL><INDENT>continue<EOL><DEDENT>ptr = i - <NUM_LIT:1><EOL>while ptr >= <NUM_LIT:0> and gap_score[ptr] >= gap_score[ptr + <NUM_LIT:1>]:<EOL><INDENT>ptr -= <NUM_LIT:1><EOL><DEDENT>lval = gap_score[ptr + <NUM_LIT:1>]<EOL>ptr = i + <NUM_LIT:1><EOL>while ptr < n and gap_score[ptr] >= gap_score[ptr - <NUM_LIT:1>]:<EOL><INDENT>ptr += <NUM_LIT:1><EOL><DEDENT>rval = gap_score[ptr - <NUM_LIT:1>]<EOL>depth_score[i] = lval + rval - <NUM_LIT:2> * gap_score[i]<EOL><DEDENT>smooth_dep_score = [<NUM_LIT:0> for _ in range(n)]<EOL>for i in range(n):<EOL><INDENT>if i - <NUM_LIT:1> < <NUM_LIT:0> or i + <NUM_LIT:1> >= n:<EOL><INDENT>smooth_dep_score[i] = depth_score[i]<EOL><DEDENT>else:<EOL><INDENT>smooth_dep_score[i] = np.average(depth_score[(i - <NUM_LIT:1>):(i + <NUM_LIT:2>)])<EOL><DEDENT><DEDENT>boundaries = [<NUM_LIT:0> for _ in range(n)]<EOL>avg = np.average(smooth_dep_score)<EOL>stdev = np.std(smooth_dep_score)<EOL>cutoff = avg - stdev / <NUM_LIT><EOL>depth_tuples = list(zip(smooth_dep_score, list(range(len(smooth_dep_score)))))<EOL>depth_tuples.sort()<EOL>depth_tuples.reverse()<EOL>hp = [x for x in depth_tuples if (x[<NUM_LIT:0>] > cutoff)]<EOL>for dt in hp:<EOL><INDENT>boundaries[dt[<NUM_LIT:1>]] = <NUM_LIT:1><EOL>for i in range(dt[<NUM_LIT:1>] - <NUM_LIT:4>, dt[<NUM_LIT:1>] + <NUM_LIT:4> + <NUM_LIT:1>):<EOL><INDENT>if i != dt[<NUM_LIT:1>] and i >= <NUM_LIT:0> and i < n and boundaries[i] == <NUM_LIT:1>:<EOL><INDENT>boundaries[dt[<NUM_LIT:1>]] = <NUM_LIT:0><EOL>break<EOL><DEDENT><DEDENT><DEDENT>return [<NUM_LIT:1>] + boundaries[:-<NUM_LIT:1>]<EOL>
document: list[str]
return list[int],
    i-th element denotes whether exists a boundary right before paragraph i(0 indexed)