add detect_filetype
add segment_lines function