def segment_text(text=os.path.join(DATA_PATH, '<STR_LIT>'),<EOL>start=None, stop=r'<STR_LIT>', ignore=r'<STR_LIT>'):
start = start if hasattr(start, '<STR_LIT>') else re.compile(start) if start else None<EOL>stop = stop if hasattr(stop, '<STR_LIT>') else re.compile(stop) if stop else None<EOL>ignore = ignore if hasattr(ignore, '<STR_LIT>') else re.compile(ignore) if ignore else None<EOL>segments = []<EOL>segment = []<EOL>with open(text) as fin:<EOL><INDENT>for line in fin:<EOL><INDENT>if start is not None and start.match(line):<EOL><INDENT>segments += [segment] if len(segment) else []<EOL>segment = [line]<EOL><DEDENT>elif stop is not None and stop.match(line):<EOL><INDENT>segments += [segment]<EOL>segment = []<EOL><DEDENT>elif ignore is not None and ignore.match(line):<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>segment += [segment]<EOL><DEDENT><DEDENT><DEDENT>
Split text into segments (sections, paragraphs) using regular expressions to trigger breaks.start