def guess_segments_lines(segments, lines, nearline_tolerance=<NUM_LIT>):
ys = segments[:, <NUM_LIT:1>]<EOL>closeness = numpy.abs(numpy.subtract.outer(ys, lines))  <EOL>line_of_y = numpy.argmin(closeness, axis=<NUM_LIT:1>)<EOL>distance = numpy.min(closeness, axis=<NUM_LIT:1>)<EOL>bad = distance > numpy.mean(distance) + nearline_tolerance * numpy.std(distance)<EOL>line_of_y[bad] = -<NUM_LIT:1><EOL>return line_of_y<EOL>
given segments, outputs a array of line numbers, or -1 if it
doesn't belong to any