Fix training year filter and reject incomplete OCR titles
This commit is contained in:
1 parent
65d851bb92
commit
3717a00459
3 files changed
+11
-4
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user