вырезание последнего предложения если содержит слово макс (любой регистр)
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 30s

This commit is contained in:
vrubel 2026-06-20 08:26:28 +00:00
parent 39f10be7fd
commit 649cd8cc33

View file

@ -69,7 +69,13 @@ def clean_text(text: str) -> str:
text = re.sub(r'@\S+\s*', '', text)
text = re.sub(r'[ \t]+', ' ', text)
text = re.sub(r'\n{2,}', '\n', text)
text = re.sub(r'\n', ' ', text)
text = text.strip()
parts = re.split(r'(?<=[.!?])\s+', text)
if parts and re.search(r'макс', parts[-1], re.IGNORECASE):
text = ' '.join(p.strip() for p in parts[:-1] if p.strip())
if text:
text += '\nПип.'
return text