Open
Conversation
HadronCollider
requested changes
Dec 7, 2025
Collaborator
HadronCollider
left a comment
There was a problem hiding this comment.
- Подтяните изменения из dev
- Отформатируйте код по pep8
| @@ -0,0 +1,80 @@ | |||
| import re | |||
| from pymorphy2 import MorphAnalyzer | |||
Collaborator
There was a problem hiding this comment.
Подтяните изменения из dev и перейдите на pymorphy3
Comment on lines
+6
to
+9
| class PresAbbreviationsCheck(BasePresCriterion): | ||
| label = "Проверка расшифровки аббревиатур в презентации" | ||
| description = "Все аббревиатуры должны быть расшифрованы при первом использовании" | ||
| id = 'abbreviations_check_pres' |
Collaborator
There was a problem hiding this comment.
Придерживайтесь шаблона именований
- для классов
Pres<>Check - для id
pres_<>_check - для отчетов - аналогично, но
report*
Comment on lines
+48
to
+50
| filtered_abbr = [abbr for abbr in abbreviations if abbr not in common_abbr and morph.parse(abbr.lower())[0].score != 0] | ||
|
|
||
| return list(set(filtered_abbr)) |
Collaborator
There was a problem hiding this comment.
Можно сразу формировать set в конструкции вида {i for i in array}
Comment on lines
+15
to
+45
| text = self._get_document_text() | ||
|
|
||
| if not text: | ||
| return answer(False, "Не удалось получить текст документа") | ||
|
|
||
| abbr_is_finding, unexplained_abbr = get_unexplained_abbrev(text=text) | ||
|
|
||
| if not abbr_is_finding: | ||
| return answer(True, "Аббревиатуры не найдены в документе") | ||
|
|
||
| if not unexplained_abbr: | ||
| return answer(True, "Все аббревиатуры правильно расшифрованы") | ||
|
|
||
| unexplained_abbr_with_page = {} | ||
|
|
||
| for page_num in range(1, self.file.page_counter() + 1): | ||
| text_on_page = self.file.pdf_file.text_on_page[page_num] | ||
|
|
||
| for abbr in unexplained_abbr: | ||
| if abbr in text_on_page and abbr not in unexplained_abbr_with_page: | ||
| unexplained_abbr_with_page[abbr] = page_num | ||
|
|
||
|
|
||
| result_str = "Найдены нерасшифрованные аббревиатуры при первом использовании:<br>" | ||
| page_links = self.format_page_link(list(unexplained_abbr_with_page.values())) | ||
| for index_links, abbr in enumerate(unexplained_abbr_with_page): | ||
| result_str += f"- {abbr} на странице {page_links[index_links]}<br>" | ||
| result_str += "Каждая аббревиатура должна быть расшифрована при первом использовании в тексте.<br>" | ||
| result_str += "Расшифровка должны быть по первыми буквам, например, МВД - Министерство внутренних дел.<br>" | ||
|
|
||
| return answer(False, result_str) |
Collaborator
There was a problem hiding this comment.
С учетом, что данный код 1 в 1 дублируется в обоих критериях (за исключением строк с указанием документа/презентации и получения данных), его стоит вынести в отдельную функцию/модуль
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.