moodlens-api / app /utils /sequence_splitter.py
kpatel1607's picture
Upload folder using huggingface_hub
627c7fe verified
Raw
History Blame Contribute Delete
349 Bytes
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()
]