Исправить заполнение вида и года распознанного курса

This commit is contained in:
codex committed 2026-11-25 19:18:49 +03:00
1 parent a4b188d562
commit 7d1939a598
2 files changed
+16 -4

No files matched your search

+7 -3
View File
@@ -134,15 +134,19 @@ def dpo_source_digest(education):
def dpo_suggestions(education):
courses = []
for section in education:
years = {entry.get("text"): entry["year"] for entry in _as_list(section.get("year_entries"))
if isinstance(entry, dict) and type(entry.get("year")) is int}
for title in section.get("items", []):
dedicated = str(section.get("title") or "").casefold().strip().rstrip(":") in {
_TRAINING_LABEL, "курсы повышения квалификации"}
text = _QUOTED_TEXT.sub("", title)
year = _TRAINING_YEAR.search(text)
kind = "training" if dedicated or _TRAINING_KIND.search(text) or _TRAINING_MENTION.search(text) else "other"
year = years.get(title)
if year is None and (match := _TRAINING_YEAR.search(text)):
year = int(match.group(1) or match.group(2))
kind = "training" if dedicated or _TRAINING_MENTION.search(text) else "other"
if "переподготовк" in text.casefold():
kind = "retraining"
courses.append({"title": title, "kind": kind, "year": int(year.group(1) or year.group(2)) if year else None,
courses.append({"title": title, "kind": kind, "year": year,
"evidence": ""})
return courses