legco_ai_assistant/backend/app/utils/sentence_splitter.py

9 lines
224 B
Python

import re
def split_sentences(text: str) -> list[str]:
if not text or not text.strip():
return []
raw = re.split(r"(?<=[.!?。!?])\s*|(?<=\n)\s+", text)
return [s.strip() for s in raw if s.strip()]