Fix training year filter and reject incomplete OCR titles
CI / test (pull_request) Successful in 12m53s
CI / Fingerprint diagnostics (production deployment temporarily disabled) (pull_request) Skipped

This commit is contained in:
codex committed 2026-11-24 10:21:22 +00:00
1 parent 65d851bb92
commit 3717a00459
3 files changed
+11 -4

No files matched your search

+8 -2
View File
@@ -17,9 +17,15 @@ def _run(args):
def _certificate(text):
text = " ".join(text.split())
title = re.search(r'(?:по (?:дополнительной профессиональной )?программе|по теме|на тему)\s*[:«"\s]*([^»"]{5,300})[»"]', text, re.I)
title = re.search(
r'(?:по (?:дополнительной профессиональной )?программе|по теме|на тему)'
r'(?: повышения квалификации| дополнительного профессионального образования)?'
r'\s*:?\s*[«"“]([^»"”]{5,300})[»"”]', text, re.I,
)
if not title:
title = re.search(r'[«"]([^«»"]{8,250})[»"]\s*[,.(]?\s*(?:в объ[её]ме|\d+ час)', text, re.I)
title = re.search(r'[«"“]([^«»"“”]{8,250})[»"”]\s*[,.(]?\s*(?:в объ[её]ме|\d+ час)', text, re.I)
if title and "|" in title[1]:
return None # OCR could not read the entire program name.
years = re.findall(r"\b(?:19|20)\d{2}\b", text)
if not title or not years or not re.search(r"квалификаци|сертификат|удостоверение", text, re.I):
return None