File size: 349 Bytes
2d8051f
 
 
627c7fe
 
 
 
 
 
 
 
 
 
 
 
2d8051f
 
 
 
 
627c7fe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re


def split_sentences(text: str):
    text = str(text).strip()

    if not text:
        return []

    text = re.sub(r"[\r\n]+", ". ", text)

    sentences = re.split(
        r"(?<=[.!?])\s+|(?<=;)\s+",
        text
    )

    return [
        sentence.strip()
        for sentence in sentences
        if sentence.strip()
    ]