(text, pattern, join_on_lowercase=False,
                            short_sentence_length=SHORT_SENTENCE_LENGTH)
Remove line separator chars inside sentences and ensure there is a ``\\n`` at their end.

    :param text: input plain-text
    :param pattern: for the initial sentence splitting
    :param join_on_lowercase: always join sentences that start with lower-case
    :param short_sentence_length: the upper boundary for text spans that are not split
                                  into sentences inside brackets
    :return: a generator yielding the spans of text
Remove line separator chars inside sentences and ensure there is a ``\\n`` at their end.
Remove line separator chars inside sentences and ensure there is a \\ n at their end .
def rewrite_line_separators(text, pattern, join_on_lowercase=False,
                            short_sentence_length=SHORT_SENTENCE_LENGTH):
    """
    Remove line separator chars inside sentences and ensure there is a ``\\n`` at their end.

    :param text: input plain-text
    :param pattern: for the initial sentence splitting
    :param join_on_lowercase: always join sentences that start with lower-case
    :param short_sentence_length: the upper boundary for text spans that are not split
                                  into sentences inside brackets
    :return: a generator yielding the spans of text
    """
    offset = 0

    for sentence in _sentences(pattern.split(text), join_on_lowercase, short_sentence_length):
        start = text.index(sentence, offset)
        intervening = text[offset:start]

        if offset != 0 and '\n' not in intervening:
            yield '\n'
            intervening = intervening[1:]

        yield intervening
        yield sentence.replace('\n', ' ')
        offset = start + len(sentence)

    if offset < len(text):
        yield text[offset:]
def rewrite_line_separators ( text , pattern , join_on_lowercase = False , short_sentence_length = SHORT_SENTENCE_LENGTH ) : offset = 0 for sentence in _sentences ( pattern . split ( text ) , join_on_lowercase , short_sentence_length ) : start = text . index ( sentence , offset ) intervening = text [ offset : start ] if offset != 0 and '\n' not in intervening : yield '\n' intervening = intervening [ 1 : ] yield intervening yield sentence . replace ( '\n' , ' ' ) offset = start + len ( sentence ) if offset < len ( text ) : yield text [ offset : ]