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
+1 -2
View File
@@ -42,7 +42,6 @@ DIRECTORY_COLUMNS = (
)
_TRAINING_LABEL = "повышение квалификации"
_TRAINING_KIND = re.compile(r",\s*повышение квалификации\s*(?:,|$)", re.IGNORECASE)
_TRAINING_MENTION = re.compile(
r"\b(?:повышение квалификации|(?:курс|программ)[а-яё]* (?:повышения|по повышению) квалификации)\b",
re.IGNORECASE,
@@ -66,7 +65,7 @@ def _has_training(data: dict[str, Any], since_year: int | None) -> bool:
structured_texts.add(text)
if since_year is not None and (type(year) is not int or year < since_year):
continue
if text and text != str(year) and (dedicated or _TRAINING_KIND.search(_QUOTED_TEXT.sub("", text))):
if text and text != str(year) and (dedicated or _TRAINING_MENTION.search(_QUOTED_TEXT.sub("", text))):
return True
# Profiles may also list completed courses in manually entered paragraphs or lists.
for text in _clean_list(section.get("paragraphs")) + _clean_list(section.get("items")):
+2
View File
@@ -14,6 +14,8 @@ from app.services.admin_data import list_employees_page
@pytest.mark.parametrize(
("html", "has_course", "has_recent_course"),
[
('<div><div class="person-list-hangover">2025</div><span>Курс повышения квалификации по Python</span></div>', True, True),
('<div><div class="person-list-hangover">2025</div><span>Стажировка «Курс повышения квалификации»</span></div>', False, False),
('<p>2024 (11 декабря), НИУ ВШЭ. Программа повышения квалификации «ИИ».</p>', True, True),
('<ul><li>Программа повышения квалификации «ДПО», октябрь 2024 года.</li></ul>', True, True),
('<p>Курс повышения квалификации «ДПО», 7 сентября 2024 год.</p>', True, True),