Skip to content

Conversation

@LapshinAE0
Copy link
Collaborator

No description provided.

@github-actions github-actions bot added the has conflicts if new merge has conflicts label Nov 21, 2025
@github-actions github-actions bot removed the has conflicts if new merge has conflicts label Dec 4, 2025
@HadronCollider HadronCollider changed the base branch from master to dev December 7, 2025 11:22
Copy link
Collaborator

@HadronCollider HadronCollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Подтяните изменения из dev
  • Отформатируйте код по pep8

@@ -0,0 +1,80 @@
import re
from pymorphy2 import MorphAnalyzer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Подтяните изменения из dev и перейдите на pymorphy3

Comment on lines +6 to +9
class PresAbbreviationsCheck(BasePresCriterion):
label = "Проверка расшифровки аббревиатур в презентации"
description = "Все аббревиатуры должны быть расшифрованы при первом использовании"
id = 'abbreviations_check_pres'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Придерживайтесь шаблона именований

  • для классов 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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно сразу формировать 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

С учетом, что данный код 1 в 1 дублируется в обоих критериях (за исключением строк с указанием документа/презентации и получения данных), его стоит вынести в отдельную функцию/модуль

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants