Skip to content

Conversation

@baydakov-georgiy
Copy link
Collaborator

Задача #751

@HadronCollider HadronCollider changed the base branch from master to dev December 6, 2025 17:18
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
  • Новые критерии импортируются в модуле https://github.com/moevm/document_insight_system/blob/master/app/main/checks/report_checks/__init__.py (для презентаций в своём), чтобы они могли быть использованы в системе - сейчас в запущенной системе к ним нет доступа и они не используются (= не могут быть запущены для документов)
  • установите одинаковые ограничения для критериев (max_decimal_places=2, max_number_of_violations=3)
  • если 0<total_violations<max_number_of_violations (т.е. нарушение не обнуляет критерий), необходимо вывести предупреждение, что есть вот такие числа, но их немного

class PresExcessiveDecimalPlacesCheck(BasePresCriterion):
description = 'Проверка на избыточное количество десятичных знаков в числах'
label = "Проверка на избыточное количество десятичных знаков"
id = 'pres_excessive_decimal_places_check'
Copy link
Collaborator

@HadronCollider HadronCollider Dec 6, 2025

Choose a reason for hiding this comment

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

  • неверно определяется/пишется страница для презентации (для отчета забыл проверить, но возможно такая же история)
image

- Обычные числа с десятичными знаками (например, -3.14159)
Не проверяет:
- IP-адреса (например, 192.168.1.1)
- Версии ПО (например, 1.2.3.4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если версия выглядит как дробное число, то засечет (см. скрин проверки у критерия презентаций), но думаю это слишком частный случай - его можно будет учесть в пороге для критериев

Comment on lines +93 to +109
def format_success_message(self):
if self.type == DocumentType.REPORT:
document_type = "документе"
elif self.type == DocumentType.PRESENTATION:
document_type = "презентации"
return (
f'Проверка пройдена! Все числа в {document_type} имеют допустимое количество '
f'десятичных знаков (не более {self.max_decimal_places}).'
)

def format_failure_message(self, total_violations,
violations_by_location,
format_page_link_fn=None):
if self.type == DocumentType.REPORT:
location_label = "Страница"
elif self.type == DocumentType.PRESENTATION:
location_label = "Слайд"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если вся "возня" с enum и if/else только для красивого вывода - это явно лишняя логика, без которой можно спокойно жить, поэтому уберите

class ReportExcessiveDecimalPlacesCheck(BaseReportCriterion):
label = "Проверка на избыточное количество десятичных знаков"
description = 'Проверка на избыточное количество десятичных знаков в числах'
id = 'excessive_decimal_places_check'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Придерживайтесь одного стандартного формата для id критериев (как в критерии для презентаций)

Comment on lines +21 to +49
detected_pages = {}
total_violations = 0

for page_num, page_text in self.file.pdf_file.get_text_on_page().items():
lines = re.split(r'\n', page_text)

page_violations = self.checker.find_violations_in_lines(lines)

for line_idx, number_str, decimal_places, line in page_violations:
total_violations += 1

if page_num not in detected_pages:
detected_pages[page_num] = []

violation_msg = self.checker.format_violation_message(
line_idx, line, number_str, decimal_places
)
detected_pages[page_num].append(violation_msg)

if total_violations > self.max_number_of_violations:
result_str = self.checker.format_failure_message(
total_violations,
detected_pages,
format_page_link_fn=self.format_page_link
)
result_score = 0
else:
result_str = self.checker.format_success_message()
result_score = 1.0
Copy link
Collaborator

@HadronCollider HadronCollider Dec 6, 2025

Choose a reason for hiding this comment

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

С учетом, что эта логика 1 в 1 повторяется в обоих критериях - кажется её можно вынести в одну функцию / метод +- как вы сделали в https://github.com/moevm/document_insight_system/pull/755/files

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