(spans, join_on_lowercase, short_sentence_length)
Join spans back together into sentences as necessary.
Join spans back together into sentences as necessary.
Join spans back together into sentences as necessary .
def _sentences(spans, join_on_lowercase, short_sentence_length):
    """Join spans back together into sentences as necessary."""
    last = None
    shorterThanATypicalSentence = lambda c, l: c < short_sentence_length or l < short_sentence_length

    for current in _abbreviation_joiner(spans):
        if last is not None:
            if (join_on_lowercase or BEFORE_LOWER.match(last)) and LOWER_WORD.match(current):
                last = '%s%s' % (last, current)
            elif shorterThanATypicalSentence(len(current), len(last)) and _is_open(last) and (
                _is_not_opened(current) or last.endswith(' et al. ') or (
                    UPPER_CASE_END.search(last) and UPPER_CASE_START.match(current)
                )
            ):
                last = '%s%s' % (last, current)
            elif shorterThanATypicalSentence(len(current), len(last)) and _is_open(last, '[]') and (
                _is_not_opened(current, '[]') or last.endswith(' et al. ') or (
                    UPPER_CASE_END.search(last) and UPPER_CASE_START.match(current)
                )
            ):
                last = '%s%s' % (last, current)
            elif CONTINUATIONS.match(current):
                last = '%s%s' % (last, current)
            else:
                yield last.strip()
                last = current
        else:
            last = current

    if last is not None:
        yield last.strip()
def _sentences ( spans , join_on_lowercase , short_sentence_length ) : last = None shorterThanATypicalSentence = lambda c , l : c < short_sentence_length or l < short_sentence_length for current in _abbreviation_joiner ( spans ) : if last is not None : if ( join_on_lowercase or BEFORE_LOWER . match ( last ) ) and LOWER_WORD . match ( current ) : last = '%s%s' % ( last , current ) elif shorterThanATypicalSentence ( len ( current ) , len ( last ) ) and _is_open ( last ) and ( _is_not_opened ( current ) or last . endswith ( ' et al. ' ) or ( UPPER_CASE_END . search ( last ) and UPPER_CASE_START . match ( current ) ) ) : last = '%s%s' % ( last , current ) elif shorterThanATypicalSentence ( len ( current ) , len ( last ) ) and _is_open ( last , '[]' ) and ( _is_not_opened ( current , '[]' ) or last . endswith ( ' et al. ' ) or ( UPPER_CASE_END . search ( last ) and UPPER_CASE_START . match ( current ) ) ) : last = '%s%s' % ( last , current ) elif CONTINUATIONS . match ( current ) : last = '%s%s' % ( last , current ) else : yield last . strip ( ) last = current else : last = current if last is not None : yield last . strip ( )