将文本按行标识符进行分割
Posted wenlin-gk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将文本按行标识符进行分割相关的知识,希望对你有一定的参考价值。
def split_docs(lines, separator): """ :note: The English sentence is in the front, the Chinese sentence is in the back, and the two are separated by a separator. """ if not lines: return [], [] eng_lines = [] chn_lines = [] chn_begin_condition = False for line in lines: if chn_begin_condition: chn_lines.append(line) else: chn_begin_condition = line.lstrip().startswith(separator) if not chn_begin_condition: eng_lines.append(line) return eng_lines, chn_lines
以上是关于将文本按行标识符进行分割的主要内容,如果未能解决你的问题,请参考以下文章