diff --git a/app/main/checks/report_checks/banned_words_in_literature.py b/app/main/checks/report_checks/banned_words_in_literature.py index 2d1ed0d5..bc12888f 100644 --- a/app/main/checks/report_checks/banned_words_in_literature.py +++ b/app/main/checks/report_checks/banned_words_in_literature.py @@ -1,5 +1,5 @@ import re - +from .style_check_settings import StyleCheckSettings from ..base_check import BaseReportCriterion, answer, morph @@ -15,14 +15,21 @@ def __init__(self, file_info, banned_words=["wikipedia"], headers_map=None): self.banned_words = [morph.normal_forms(word)[0] for word in banned_words] self.name_pattern = r'список[ \t]*(использованных|использованной|)[ \t]*(источников|литературы)' if headers_map: - self.requirement_header = headers_map + self.config = headers_map else: - self.requirement_header ='список использованных источников' + self.config = 'VKR_HEADERS' if (self.file_type['report_type'] == 'VKR') else 'LR_HEADERS' def late_init_vkr(self): - self.literature_header = self.file.find_literature_vkr(self.file_type['report_type'], self.requirement_header) self.headers_page = self.file.find_header_page(self.file_type['report_type']) - self.lit_page = self.file.find_literature_page(self.file_type['report_type']) + self.lit_page = self.file.find_literature_page(self.file_type['report_type']) + self.headers = self.file.make_chapters(self.file_type['report_type']) + self.headers_main = self.file.get_main_headers(self.file_type['report_type']) + if not self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): + self.headers_main = 'any_header' + if 'literature_header' in StyleCheckSettings.CONFIGS.get(self.config).get(self.headers_main): + self.literature_header = self.file.find_literature_vkr(self.file_type['report_type'], StyleCheckSettings.CONFIGS[self.config][self.headers_main]['literature_header']) + else: + self.literature_header = self.file.find_literature_vkr(self.file_type['report_type'], 'список использованных источников') def check(self): if self.file.page_counter() < 4: diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index 32be66ed..b3998fa2 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -27,7 +27,12 @@ def late_init_vkr(self): else: if 'any_header' in StyleCheckSettings.CONFIGS.get(self.config): self.min_ref = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['min_ref_for_literature_references_check'] + self.headers_main = 'any_header' self.max_ref = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['mах_ref_for_literature_references_check'] + if 'literature_header' in StyleCheckSettings.CONFIGS.get(self.config).get(self.headers_main): + self.literature_header = self.file.find_literature_vkr(self.file_type['report_type'], StyleCheckSettings.CONFIGS[self.config][self.headers_main]['literature_header']) + else: + self.literature_header = self.file.find_literature_vkr(self.file_type['report_type'], 'список использованных источников') def check(self): if self.file.page_counter() < 4: diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index e4443c78..23fb7453 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -114,7 +114,7 @@ class StyleCheckSettings: { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], - "headers": ["ВВЕДЕНИЕ", "ЗАКЛЮЧЕНИЕ", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], + "headers": ["введение", "заключение", "список использованных источников"], "unify_regex": None, "regex": HEADER_REGEX, "banned_words": STD_BANNED_WORDS, @@ -139,12 +139,13 @@ class StyleCheckSettings: "style": HEADER_1_STYLE, "docx_style": ["heading 2"], "headers": ["постановка задачи", "результаты работы в весеннем семестре", "описание предполагаемого метода решения", - "план работы на осенний семестр", "список использованных источников"], + "план работы на осенний семестр", "список литературы"], "unify_regex": None, "regex": HEADER_REGEX, "banned_words": ['wikipedia', 'wikipedia.org'], 'min_count_for_banned_words_check': 3, 'max_count_for_banned_words_check': 6, + 'literature_header': 'список литературы', 'min_ref_for_literature_references_check': STD_MIN_LIT_REF, 'mах_ref_for_literature_references_check': STD_MAX_LIT_REF, 'template_name': ('^\d+_[А-Яа-я]+\_[А-Я]{2}_NIR2', '1111_Иванов_ИИ_NIR2')