From 2aea76b5b3ba22f95b64c4d842f5519633e3f398 Mon Sep 17 00:00:00 2001 From: Marina Date: Tue, 27 Aug 2024 10:48:22 +0300 Subject: [PATCH 01/12] change structure of style_settings --- .../report_checks/needed_headers_check.py | 16 ++-- .../report_checks/style_check_settings.py | 79 +++++++++++++------ 2 files changed, 67 insertions(+), 28 deletions(-) diff --git a/app/main/checks/report_checks/needed_headers_check.py b/app/main/checks/report_checks/needed_headers_check.py index 14223ebe..dc584de6 100644 --- a/app/main/checks/report_checks/needed_headers_check.py +++ b/app/main/checks/report_checks/needed_headers_check.py @@ -18,18 +18,22 @@ def __init__(self, file_info, main_heading_style="heading 2", headers_map=None): self.config = headers_map else: self.config = 'VKR_HEADERS' if (self.file_type['report_type'] == 'VKR') else 'LR_HEADERS' - self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"] + # self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"] def late_init(self): self.headers = self.file.make_chapters(self.file_type['report_type']) self.headers_page = self.file.find_header_page(self.file_type['report_type']) self.chapters_str = self.file.show_chapters(self.file_type['report_type']) - # TODO: change self.headers_main = self.file.get_main_headers(self.file_type['report_type']) - if self.headers_main == "Задание 1": - self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"] - elif self.headers_main == "Задание 2": - self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[1]["headers"] + print(self.headers_main) + if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): + self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['headers'] + else: + self.patterns = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['headers'] + # if self.headers_main == "Задание 1": + # self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"] + # elif self.headers_main == "Задание 2": + # self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[1]["headers"] 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 23c6a346..5723e5fd 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -82,14 +82,14 @@ class StyleCheckSettings: } # Order of styles may be significant! First level 1, then level 2 and so on. - LR_CONFIG = [ + LR_CONFIG = {'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 1"], "headers": ["Исходный код программы"], "unify_regex": APPENDIX_UNIFY_REGEX, "regex": APPENDIX_REGEX, - }, + },'second_header': { "style": HEADER_2_STYLE, "docx_style": ["heading 2"], @@ -97,16 +97,16 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_1_REGEX } - ] + } - VKR_CONFIG = [ + VKR_CONFIG = {'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], "headers": ["ВВЕДЕНИЕ", "ЗАКЛЮЧЕНИЕ", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], "unify_regex": None, "regex": HEADER_REGEX - }, + },'second_header': { "style": HEADER_1_NUM_STYLE, "docx_style": ["heading 2", "heading 3", "heading 4"], @@ -114,9 +114,9 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_NUM_REGEX } - ] + } - NIR_CONFIG = [ + NIR_CONFIG = {'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], @@ -124,7 +124,7 @@ class StyleCheckSettings: "ПЛАН РАБОТЫ НА ОСЕННИЙ СЕМЕСТР", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], "unify_regex": None, "regex": HEADER_REGEX - }, + }, 'second_header': { "style": HEADER_1_NUM_STYLE, "docx_style": ["heading 3", "heading 4"], @@ -132,9 +132,10 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_NUM_REGEX } - ] + } - MD_CONFIG = [ + MD_CONFIG = { + 'Задание 1': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], @@ -146,6 +147,7 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_REGEX }, + 'Задание 2': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], @@ -155,22 +157,54 @@ class StyleCheckSettings: ], "unify_regex": None, "regex": HEADER_REGEX - }, + } + # },'': + # { + # "style": HEADER_1_NUM_STYLE, + # "docx_style": ["heading 2", "heading 3", "heading 4"], + # "headers": [], + # "unify_regex": None, + # "regex": HEADER_NUM_REGEX + # },'': + # { + # "style": "Main_header", + # "docx_style": ["heading 1"], + # "headers": ["Задание"], + # "unify_regex": None, + # "regex": HEADER_NUM_REGEX + # } + } + + OPNP_CONFIG = { + 'Сравнение аналогов': { - "style": HEADER_1_NUM_STYLE, - "docx_style": ["heading 2", "heading 3", "heading 4"], - "headers": [], + "style": HEADER_1_STYLE, + "docx_style": ["heading 2"], + "headers": ["Принцип отбора аналогов", + "Критерии сравнения аналогов", + "Выводы по итогам сравнения", + "Выбор метода решения", + ], "unify_regex": None, - "regex": HEADER_NUM_REGEX + "regex": HEADER_REGEX }, + 'any_header': { - "style": "Main_header", - "docx_style": ["heading 1"], - "headers": ["Задание"], + "style": HEADER_1_STYLE, + "docx_style": ["heading 2"], + "headers": ["Аннотация", + "Введение", + "Обзор предметной области == Сравнение аналогов", + "Выбор метода решения", + "Заключение" + "Список литературы" + ], "unify_regex": None, - "regex": HEADER_NUM_REGEX - } - ] + "regex": HEADER_REGEX + }, + + } + LR_MAIN_TEXT_CONFIG = [ { @@ -216,5 +250,6 @@ class StyleCheckSettings: 'VKR_HEADERS': VKR_CONFIG, 'VKR_MAIN_TEXT': VKR_MAIN_TEXT_CONFIG, 'NIR_HEADERS': NIR_CONFIG, - 'MD_HEADERS' : MD_CONFIG + 'MD_HEADERS' : MD_CONFIG, + 'OPNP_HEADERS' : OPNP_CONFIG, } From 1389104e17acff0b912079ac831449afb2738d79 Mon Sep 17 00:00:00 2001 From: Marina Date: Tue, 27 Aug 2024 21:31:09 +0300 Subject: [PATCH 02/12] checks are changed(because of list --> dict), needed_headers added --- app/main/checks/report_checks/chapters.py | 4 ++-- .../checks/report_checks/needed_headers_check.py | 14 ++++++-------- app/main/checks/report_checks/sections_check.py | 2 +- .../checks/report_checks/short_sections_check.py | 2 +- app/main/checks/report_checks/style_check.py | 2 +- .../checks/report_checks/style_check_settings.py | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/main/checks/report_checks/chapters.py b/app/main/checks/report_checks/chapters.py index ad181135..e822d7fc 100644 --- a/app/main/checks/report_checks/chapters.py +++ b/app/main/checks/report_checks/chapters.py @@ -16,13 +16,13 @@ def __init__(self, file_info): self.target_styles = StyleCheckSettings.VKR_CONFIG self.target_styles = list(map(lambda elem: { "style": self.construct_style_from_description(elem["style"]) - }, self.target_styles)) + }, self.target_styles.values())) self.docx_styles = {} self.style_regex = {} self.config = 'VKR_HEADERS' if (self.file_type['report_type'] == 'VKR') else 'LR_HEADERS' self.presets = StyleCheckSettings.CONFIGS.get(self.config) level = 0 - for format_description in self.presets: + for _, format_description in self.presets.items(): self.docx_styles.update({level: format_description["docx_style"]}) pattern = re.compile(format_description["regex"]) self.style_regex.update({level: pattern}) diff --git a/app/main/checks/report_checks/needed_headers_check.py b/app/main/checks/report_checks/needed_headers_check.py index dc584de6..64c815ef 100644 --- a/app/main/checks/report_checks/needed_headers_check.py +++ b/app/main/checks/report_checks/needed_headers_check.py @@ -25,20 +25,18 @@ def late_init(self): self.headers_page = self.file.find_header_page(self.file_type['report_type']) self.chapters_str = self.file.show_chapters(self.file_type['report_type']) self.headers_main = self.file.get_main_headers(self.file_type['report_type']) - print(self.headers_main) if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['headers'] else: - self.patterns = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['headers'] - # if self.headers_main == "Задание 1": - # self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[0]["headers"] - # elif self.headers_main == "Задание 2": - # self.patterns = StyleCheckSettings.CONFIGS.get(self.config)[1]["headers"] + if 'any_header' in StyleCheckSettings.CONFIGS.get(self.config): + self.patterns = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['headers'] def check(self): if self.file.page_counter() < 4: return answer(False, "В отчете недостаточно страниц. Нечего проверять.") self.late_init() + if not self.patterns: + return answer(False, "Не удалось сформировать требуемые заголовки исходя из названия работы. Проверьте наименование работы.") result_string = '' patterns = [] for pattern in self.patterns: @@ -59,7 +57,7 @@ def check(self): if not result_string: result_str = f'Все необходимые заголовки обнаружены!' result_str += f'

Ниже представлена иерархия обработанных заголовков, ' \ - f'сравните с Содержанием {self.format_page_link([self.headers_page])}:' + f'сравните с Содержанием {self.format_page_link([self.headers_page])}:' result_str += self.chapters_str result_str += '
Если список не точный, убедитесь, что для каждого заголовка указан верный стиль.' return answer(True, result_str) @@ -74,7 +72,7 @@ def check(self): ''' result_str += f'

Ниже представлена иерархия обработанных заголовков, ' \ - f'сравните с Содержанием {self.format_page_link([self.headers_page])}:' + f'сравните с Содержанием {self.format_page_link([self.headers_page])}:' result_str += self.chapters_str result_str += '
Если список не точный, убедитесь, что для каждого заголовка указан верный стиль.' return answer(False, result_str) diff --git a/app/main/checks/report_checks/sections_check.py b/app/main/checks/report_checks/sections_check.py index 887eabb2..8fc03139 100644 --- a/app/main/checks/report_checks/sections_check.py +++ b/app/main/checks/report_checks/sections_check.py @@ -32,7 +32,7 @@ def check(self): self.file.parse_effective_styles() result = True result_str = "" - for preset in self.presets: + for _, preset in self.presets.items(): full_style = self.construct_style_from_description(preset["style"]) precheck_dict = {key: preset["style"].get(key) for key in self.prechecked_props} precheck_style = self.construct_style_from_description(precheck_dict) diff --git a/app/main/checks/report_checks/short_sections_check.py b/app/main/checks/report_checks/short_sections_check.py index df9d3360..35d76b6e 100644 --- a/app/main/checks/report_checks/short_sections_check.py +++ b/app/main/checks/report_checks/short_sections_check.py @@ -25,7 +25,7 @@ def __init__(self, file_info, min_section_count=5, min_section_len=20, main_head if prechecked_props_lst is None: prechecked_props_lst = StyleCheckSettings.PRECHECKED_PROPS self.styles: List[Style] = [] - for format_description in self.presets: + for _, format_description in self.presets.items(): prechecked_dict = {key: format_description["style"].get(key) for key in prechecked_props_lst} style = Style() style.__dict__.update(prechecked_dict) diff --git a/app/main/checks/report_checks/style_check.py b/app/main/checks/report_checks/style_check.py index 94e06453..e421a828 100644 --- a/app/main/checks/report_checks/style_check.py +++ b/app/main/checks/report_checks/style_check.py @@ -25,7 +25,7 @@ def __init__(self, file_info, header_styles=None, target_styles=None, key_proper self.target_styles)) if header_styles is None: self.header_styles = [] - for style_dict in StyleCheckSettings.LR_CONFIG: + for _, style_dict in StyleCheckSettings.LR_CONFIG.items(): header_style = {key: style_dict["style"].get(key) for key in StyleCheckSettings.PRECHECKED_PROPS} style = Style() style.__dict__.update(header_style) diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index 5723e5fd..f327d823 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -196,7 +196,7 @@ class StyleCheckSettings: "Введение", "Обзор предметной области == Сравнение аналогов", "Выбор метода решения", - "Заключение" + "Заключение", "Список литературы" ], "unify_regex": None, From 3057424a02d2fcfda1c2c197c59ba9a5fca60875 Mon Sep 17 00:00:00 2001 From: Marina Date: Tue, 27 Aug 2024 21:34:17 +0300 Subject: [PATCH 03/12] fix actions (remove"-" from docker-compose) --- .github/workflows/build.yml | 6 +++--- .github/workflows/selenium_tests.yml | 8 ++++---- tests/scripts/docker_check_tests.sh | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ff659da..0be14874 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build system images (non-pulling) run: | @@ -16,10 +16,10 @@ jobs: - name: Build docker-compose run: | cp .env_example .env - docker-compose build + docker compose build - name: Run docker-compose run: | - docker-compose up -d + docker compose up -d sleep 10 - name: Run tests run: | diff --git a/.github/workflows/selenium_tests.yml b/.github/workflows/selenium_tests.yml index a31e1253..aa850300 100644 --- a/.github/workflows/selenium_tests.yml +++ b/.github/workflows/selenium_tests.yml @@ -7,17 +7,17 @@ jobs: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: Build docker-compose with docker-compose-selenium (tests) + - name: Build docker compose with docker-compose-selenium (tests) run: | cp .env_example .env cp app/VERSION_example.json app/VERSION.json - docker-compose -f docker-compose.yml -f docker-compose-selenium.yml build + docker compose -f docker-compose.yml -f docker-compose-selenium.yml build - name: Run docker-compose with docker-compose-selenium (tests) run: | - docker-compose -f docker-compose.yml -f docker-compose-selenium.yml up -d + docker compose -f docker-compose.yml -f docker-compose-selenium.yml up -d chmod +x tests/scripts/docker_check_tests.sh ./tests/scripts/docker_check_tests.sh diff --git a/tests/scripts/docker_check_tests.sh b/tests/scripts/docker_check_tests.sh index 67deee05..b09d55f9 100755 --- a/tests/scripts/docker_check_tests.sh +++ b/tests/scripts/docker_check_tests.sh @@ -1,7 +1,7 @@ # !/bin/bash service="selenium-tests" -container_id=$(docker-compose -f docker-compose.yml -f docker-compose-selenium.yml ps -q $service) +container_id=$(docker compose -f docker-compose.yml -f docker-compose-selenium.yml ps -q $service) if [ -z "$container_id" ]; then echo "Контейнер сервиса $service не найден." @@ -17,11 +17,11 @@ echo "tests are finished" EXIT_CODE=$(docker inspect "$container_id" --format='{{.State.ExitCode}}') echo "tests logs:" -docker-compose -f docker-compose.yml -f docker-compose-selenium.yml logs selenium-tests +docker compose -f docker-compose.yml -f docker-compose-selenium.yml logs selenium-tests echo "web logs:" -docker-compose logs web +docker compose logs web echo "worker logs:" -docker-compose logs worker +docker compose logs worker if [ "$EXIT_CODE" -eq 0 ]; then echo "tests finished with code $EXIT_CODE (OK)" From 3d4d6be1dd0c3c42e021122ac8a789865ea4c636 Mon Sep 17 00:00:00 2001 From: Marina Date: Wed, 28 Aug 2024 11:57:12 +0300 Subject: [PATCH 04/12] impoving of section check --- app/main/checks/report_checks/section_component.py | 8 +++++++- app/main/checks/report_checks/style_check_settings.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/main/checks/report_checks/section_component.py b/app/main/checks/report_checks/section_component.py index ac049e15..6dba0813 100644 --- a/app/main/checks/report_checks/section_component.py +++ b/app/main/checks/report_checks/section_component.py @@ -11,7 +11,8 @@ def __init__(self, file_info, chapter='Введение', patterns=('цель', super().__init__(file_info) self.intro = {} if headers_map: - self.chapter = StyleCheckSettings.CONFIGS.get(headers_map)[0]["headers"][0] + self.config = headers_map + self.chapter = None patterns = ('цель', 'задач') else: self.chapter = chapter @@ -21,12 +22,17 @@ def __init__(self, file_info, chapter='Введение', patterns=('цель', self.patterns.append({"name": pattern.capitalize(), "text": pattern, "marker": 0}) def late_init(self): + if self.chapter is None: + self.headers_main = self.file.get_main_headers(self.file_type['report_type']) + self.chapter = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]["header_for_report_section_component"] self.chapters = self.file.make_chapters(self.file_type['report_type']) def check(self): if self.file.page_counter() < 4: return answer(False, "В отчете недостаточно страниц. Нечего проверять.") self.late_init() + if not self.chapter: + return answer(True, f'Данная проверка не предусмотрена для работы с темой "{self.headers_main}"') result_str = '' for intro in self.chapters: header = intro["text"].lower() diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index f327d823..a7d9308f 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -144,6 +144,7 @@ class StyleCheckSettings: "Методы обоснования", "Статья", ], + "header_for_report_section_component": "Поставленная цель и задачи", "unify_regex": None, "regex": HEADER_REGEX }, @@ -155,6 +156,7 @@ class StyleCheckSettings: "Характеристика выводов", "Статья", ], + "header_for_report_section_component": "", "unify_regex": None, "regex": HEADER_REGEX } From a699df427911e81d225d984fa3564e9d463f9c60 Mon Sep 17 00:00:00 2001 From: Marina Date: Wed, 28 Aug 2024 12:57:30 +0300 Subject: [PATCH 05/12] add new check^ key_words --- app/main/check_packs/pack_config.py | 1 + app/main/checks/report_checks/__init__.py | 3 ++- .../checks/report_checks/key_words_check.py | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/main/checks/report_checks/key_words_check.py diff --git a/app/main/check_packs/pack_config.py b/app/main/check_packs/pack_config.py index 598c3cc2..051cb20a 100644 --- a/app/main/check_packs/pack_config.py +++ b/app/main/check_packs/pack_config.py @@ -43,6 +43,7 @@ ["spelling_check"], ["max_abstract_size_check"], ["theme_in_report_check"], + ['Key_words_report_check'], ] DEFAULT_TYPE = 'pres' diff --git a/app/main/checks/report_checks/__init__.py b/app/main/checks/report_checks/__init__.py index 50729335..c917b31b 100644 --- a/app/main/checks/report_checks/__init__.py +++ b/app/main/checks/report_checks/__init__.py @@ -23,4 +23,5 @@ from .style_check import ReportStyleCheck from .spelling_check import SpellingCheck from .max_abstract_size_check import ReportMaxSizeOfAbstractCheck -from .template_name import ReportTemplateNameCheck \ No newline at end of file +from .template_name import ReportTemplateNameCheck +from .key_words_check import KeyWordsReportCheck diff --git a/app/main/checks/report_checks/key_words_check.py b/app/main/checks/report_checks/key_words_check.py new file mode 100644 index 00000000..999f03ed --- /dev/null +++ b/app/main/checks/report_checks/key_words_check.py @@ -0,0 +1,24 @@ +import re +from ..base_check import BaseReportCriterion, answer + + +class KeyWordsReportCheck(BaseReportCriterion): + label = 'Проверка наличия раздела "Ключевые слова"' + description = 'Раздел идет сразу после названия работы и содержит не менее трех ключевых слов' + id = 'Key_words_report_check' + + def __init__(self, file_info, min_key_words = 3): + super().__init__(file_info) + self.min_key_words = min_key_words + + def check(self): + key_words_chapter = self.file.paragraphs[1].lower() + if 'ключевые слова' not in key_words_chapter: + return answer(False, 'Раздел "Ключевые слова" не найден') + cleaned_str = re.sub(r'<[^>]*>', '', key_words_chapter) + final_str = cleaned_str.replace('ключевые слова', '').replace(':','').replace(' ', '') + key_words = final_str.split(',') + if len(key_words) >= self.min_key_words: + return answer(True, 'Пройдена!') + else: + return answer(False, f'Не пройдена! Количество ключевых слов должно быть не менее {self.min_key_words}') From 392de37c9e9215d628e0a4fab6dba48c533a433f Mon Sep 17 00:00:00 2001 From: Marina Date: Thu, 29 Aug 2024 11:49:21 +0300 Subject: [PATCH 06/12] fix count of paragraphs, lit_ref and section_component --- app/main/checks/report_checks/literature_references.py | 1 + app/main/checks/report_checks/section_component.py | 7 ++++--- app/main/reports/md_uploader/md_uploader.py | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index e271ba4c..96f71791 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -71,6 +71,7 @@ def check(self):
  • Убедитесь, что для ссылки на источник используются квадратные скобки;
  • Убедитесь, что для оформления списка литературы был использован нумированный список;
  • Убедитесь, что после и перед нумированным списком отсутствуют непустые абзацы.
  • +
  • Убедитесь, что один источник не разбит на двае строки клавишей "Enter".
  • ''' return answer(False, result_str) diff --git a/app/main/checks/report_checks/section_component.py b/app/main/checks/report_checks/section_component.py index 6dba0813..68781533 100644 --- a/app/main/checks/report_checks/section_component.py +++ b/app/main/checks/report_checks/section_component.py @@ -12,7 +12,7 @@ def __init__(self, file_info, chapter='Введение', patterns=('цель', self.intro = {} if headers_map: self.config = headers_map - self.chapter = None + self.chapter = '' patterns = ('цель', 'задач') else: self.chapter = chapter @@ -22,9 +22,10 @@ def __init__(self, file_info, chapter='Введение', patterns=('цель', self.patterns.append({"name": pattern.capitalize(), "text": pattern, "marker": 0}) def late_init(self): - if self.chapter is None: + if not self.chapter: self.headers_main = self.file.get_main_headers(self.file_type['report_type']) - self.chapter = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]["header_for_report_section_component"] + if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): + self.chapter = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]["header_for_report_section_component"] self.chapters = self.file.make_chapters(self.file_type['report_type']) def check(self): diff --git a/app/main/reports/md_uploader/md_uploader.py b/app/main/reports/md_uploader/md_uploader.py index ce55fb44..ec337830 100644 --- a/app/main/reports/md_uploader/md_uploader.py +++ b/app/main/reports/md_uploader/md_uploader.py @@ -73,7 +73,7 @@ def parse(self, md_text): def make_paragraphs(self, html_text): html_text = html_text.replace("
  • ", "").replace("
  • ", "").replace("", "").replace("
      ", "") - self.paragraphs = html_text.split('\n') + self.paragraphs = [paragraph for paragraph in html_text.split('\n') if paragraph.strip()] return self.paragraphs def page_counter(self): # we need this just to find a last page and make link to the literature in banned_words_in_literature @@ -121,7 +121,6 @@ def parse_effective_styles(self): else: paragraph["runs"].append({"text": par, "style": 'body text'}) self.styled_paragraphs.append(paragraph) - return self.styled_paragraphs def make_chapters(self, work_type): From f0cd5408e30ff8c27c0b6192db02716a9390e4ee Mon Sep 17 00:00:00 2001 From: Marina Date: Thu, 29 Aug 2024 20:11:47 +0300 Subject: [PATCH 07/12] check min and max literature ref is added --- .../checks/report_checks/literature_references.py | 14 +++++++++----- .../checks/report_checks/style_check_settings.py | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index 96f71791..4be154ab 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -1,5 +1,5 @@ import re - +from .style_check_settings import StyleCheckSettings from ..base_check import BaseReportCriterion, answer @@ -8,13 +8,17 @@ class ReferencesToLiteratureCheck(BaseReportCriterion): description = '' id = 'literature_references' - def __init__(self, file_info, min_ref=1, max_ref=1000): + def __init__(self, file_info, min_ref=1, max_ref=1000, headers_map=None): super().__init__(file_info) self.headers = [] self.literature_header = [] self.name_pattern = r'список[ \t]*(использованных|использованной|)[ \t]*(источников|литературы)' - self.min_ref = min_ref - self.max_ref = max_ref + if headers_map: + self.min_ref = StyleCheckSettings.CONFIGS.get(headers_map)['min_ref_for_literature_references_check'] + self.max_ref = StyleCheckSettings.CONFIGS.get(headers_map)['mах_ref_for_literature_references_check'] + else: + self.min_ref = min_ref + self.max_ref = max_ref def late_init_vkr(self): self.headers = self.file.make_chapters(self.file_type['report_type']) @@ -51,7 +55,7 @@ def check(self): all_numbers.add(i) if len(references.symmetric_difference(all_numbers)) == 0: if not self.min_ref <= number_of_sources <= self.max_ref: - return answer(False, f'Список источников оформлен верно, однако их количество ({number_of_sources}) не удовлетворяет необходимому критерию.
      Количество источников должно быть от {self.min_ref} до {self.max_ref}.') + return answer(False, f'Список источников оформлен верно, однако их количество ({number_of_sources}) не удовлетворяет необходимому критерию.
      Количество источников должно быть не менее {self.min_ref}.') else: return answer(True, f"Пройдена!") elif len(references.difference(all_numbers)): diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index a7d9308f..0462d950 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -204,6 +204,8 @@ class StyleCheckSettings: "unify_regex": None, "regex": HEADER_REGEX }, + 'min_ref_for_literature_references_check': 5, + 'mах_ref_for_literature_references_check': 1000, #just for future possible edit } From d3cdd872ceaea25133843023b986d9a5d86416ca Mon Sep 17 00:00:00 2001 From: Marina Date: Fri, 30 Aug 2024 13:27:35 +0300 Subject: [PATCH 08/12] banned_words_check is added --- .../report_checks/banned_words_check.py | 27 ++++++-- .../report_checks/literature_references.py | 5 +- .../report_checks/style_check_settings.py | 68 ++++++++++++++----- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/app/main/checks/report_checks/banned_words_check.py b/app/main/checks/report_checks/banned_words_check.py index e88dedab..ec18d4a9 100644 --- a/app/main/checks/report_checks/banned_words_check.py +++ b/app/main/checks/report_checks/banned_words_check.py @@ -1,5 +1,5 @@ import re - +from .style_check_settings import StyleCheckSettings from ..base_check import BaseReportCriterion, answer, morph @@ -8,15 +8,32 @@ class ReportBannedWordsCheck(BaseReportCriterion): description = 'Запрещено упоминание слова "мы"' id = 'banned_words_check' - def __init__(self, file_info, words=["мы"], min_count=3, max_count=6): + def __init__(self, file_info, headers_map=None): super().__init__(file_info) - self.words = [morph.normal_forms(word)[0] for word in words] - self.min_count = min_count - self.max_count = max_count + self.words = [] + self.min_count = 0 + self.max_count = 0 + if headers_map: + self.config = headers_map + else: + self.config = 'VKR_HEADERS' if (self.file_type['report_type'] == 'VKR') else 'LR_HEADERS' + + def late_init(self): + self.headers_main = self.file.get_main_headers(self.file_type['report_type']) + if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): + self.words = [morph.normal_forms(word)[0] for word in StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['banned_words']] + self.min_count = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['min_count_for_banned_words_check'] + self.max_count = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['min_count_for_banned_words_check'] + else: + if 'any_header' in StyleCheckSettings.CONFIGS.get(self.config): + self.words = [morph.normal_forms(word)[0] for word in StyleCheckSettings.CONFIGS.get(self.config)['any_header']['banned_words']] + self.min_count = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['min_count_for_banned_words_check'] + self.max_count = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['min_count_for_banned_words_check'] def check(self): if self.file.page_counter() < 4: return answer(False, "В отчете недостаточно страниц. Нечего проверять.") + self.late_init() detected_lines = {} result_str = f'Запрещенные слова: {"; ".join(self.words)}
      ' count = 0 diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index 4be154ab..719346dc 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -14,8 +14,9 @@ def __init__(self, file_info, min_ref=1, max_ref=1000, headers_map=None): self.literature_header = [] self.name_pattern = r'список[ \t]*(использованных|использованной|)[ \t]*(источников|литературы)' if headers_map: - self.min_ref = StyleCheckSettings.CONFIGS.get(headers_map)['min_ref_for_literature_references_check'] - self.max_ref = StyleCheckSettings.CONFIGS.get(headers_map)['mах_ref_for_literature_references_check'] + if StyleCheckSettings.CONFIGS.get(headers_map)['limits']: + self.min_ref = int(StyleCheckSettings.CONFIGS.get(headers_map)['any_header']['min_ref_for_literature_references_check']) + self.max_ref = int(StyleCheckSettings.CONFIGS.get(headers_map)['any_header']['mах_ref_for_literature_references_check']) else: self.min_ref = min_ref self.max_ref = max_ref diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index 0462d950..b4c9a093 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -82,49 +82,61 @@ class StyleCheckSettings: } # Order of styles may be significant! First level 1, then level 2 and so on. - LR_CONFIG = {'any_header': + LR_CONFIG = { + 'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 1"], "headers": ["Исходный код программы"], "unify_regex": APPENDIX_UNIFY_REGEX, "regex": APPENDIX_REGEX, - },'second_header': + "banned_words": ['мы'], + 'min_count_for_banned_words_check': 3, + 'max_count_for_banned_words_check': 6, + }, + 'second_header': { "style": HEADER_2_STYLE, "docx_style": ["heading 2"], "headers": ["Цель работы", "Выполнение работы", "Выводы"], "unify_regex": None, - "regex": HEADER_1_REGEX + "regex": HEADER_1_REGEX, } } - VKR_CONFIG = {'any_header': + VKR_CONFIG = { + 'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], "headers": ["ВВЕДЕНИЕ", "ЗАКЛЮЧЕНИЕ", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], "unify_regex": None, - "regex": HEADER_REGEX - },'second_header': + "regex": HEADER_REGEX, + "banned_words": ['мы'], + 'min_count_for_banned_words_check': 3, + 'max_count_for_banned_words_check': 6, + }, + 'second_header': { "style": HEADER_1_NUM_STYLE, "docx_style": ["heading 2", "heading 3", "heading 4"], "headers": [], "unify_regex": None, - "regex": HEADER_NUM_REGEX + "regex": HEADER_NUM_REGEX, } } - NIR_CONFIG = {'any_header': + NIR_CONFIG = { + 'any_header': { "style": HEADER_1_STYLE, "docx_style": ["heading 2"], "headers": ["ПОСТАНОВКА ЗАДАЧИ", "РЕЗУЛЬТАТЫ РАБОТЫ В ВЕСЕННЕМ СЕМЕСТРЕ", "ОПИСАНИЕ ПРЕДПОЛАГАЕМОГО МЕТОДА РЕШЕНИЯ", "ПЛАН РАБОТЫ НА ОСЕННИЙ СЕМЕСТР", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], "unify_regex": None, - "regex": HEADER_REGEX - }, 'second_header': + "regex": HEADER_REGEX, + }, + 'second_header': { "style": HEADER_1_NUM_STYLE, "docx_style": ["heading 3", "heading 4"], @@ -146,7 +158,10 @@ class StyleCheckSettings: ], "header_for_report_section_component": "Поставленная цель и задачи", "unify_regex": None, - "regex": HEADER_REGEX + "regex": HEADER_REGEX, + "banned_words": ['мы'], + 'min_count_for_banned_words_check': 3, + 'max_count_for_banned_words_check': 6, }, 'Задание 2': { @@ -158,8 +173,13 @@ class StyleCheckSettings: ], "header_for_report_section_component": "", "unify_regex": None, - "regex": HEADER_REGEX + "regex": HEADER_REGEX, + "banned_words": ['мы'], + 'min_count_for_banned_words_check': 3, + 'max_count_for_banned_words_check': 6, } + } + # },'': # { # "style": HEADER_1_NUM_STYLE, @@ -175,7 +195,7 @@ class StyleCheckSettings: # "unify_regex": None, # "regex": HEADER_NUM_REGEX # } - } + OPNP_CONFIG = { 'Сравнение аналогов': @@ -188,7 +208,16 @@ class StyleCheckSettings: "Выбор метода решения", ], "unify_regex": None, - "regex": HEADER_REGEX + "regex": HEADER_REGEX, + "banned_words": ['аттач', 'билдить', 'бинарник', 'валидный', 'дебаг', 'деплоить', 'десктопное', 'железо', + 'исходники', 'картинка', 'консольное', 'конфиг', 'кусок', 'либа', 'лог', 'мануал', 'машина', + 'отнаследованный', 'парсинг', 'пост', 'распаковать', 'сбоит', 'скачать', 'склонировать', 'скрипт', + 'тестить', 'тул', 'тула', 'тулза', 'фиксить', 'флажок', 'флаг', 'юзкейс', 'продакт', 'продакшн', + 'прод', 'фидбек', 'дедлайн', 'дэдлайн'], + 'min_ref_for_literature_references_check': 5, + 'mах_ref_for_literature_references_check': 1000, #just for future possible edit + 'min_count_for_banned_words_check': 0, + 'max_count_for_banned_words_check': 0 }, 'any_header': { @@ -202,10 +231,13 @@ class StyleCheckSettings: "Список литературы" ], "unify_regex": None, - "regex": HEADER_REGEX - }, - 'min_ref_for_literature_references_check': 5, - 'mах_ref_for_literature_references_check': 1000, #just for future possible edit + "regex": HEADER_REGEX, + "banned_words": ['оптимально', 'оптимальный', 'надежный', 'интуитивный'], + 'min_ref_for_literature_references_check': 5, + 'mах_ref_for_literature_references_check': 1000, #just for future possible edit + 'min_count_for_banned_words_check': 0, + 'max_count_for_banned_words_check': 0 + } } From 0f316c48c5311f66b8f977b020daa8c27625e891 Mon Sep 17 00:00:00 2001 From: Marina Date: Sat, 31 Aug 2024 17:11:37 +0300 Subject: [PATCH 09/12] added searching of key words --- .../checks/report_checks/key_words_check.py | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/app/main/checks/report_checks/key_words_check.py b/app/main/checks/report_checks/key_words_check.py index 999f03ed..adaabfc5 100644 --- a/app/main/checks/report_checks/key_words_check.py +++ b/app/main/checks/report_checks/key_words_check.py @@ -1,24 +1,66 @@ import re +import string + +from nltk.tokenize import word_tokenize +from nltk.corpus import stopwords +from pymorphy2 import MorphAnalyzer from ..base_check import BaseReportCriterion, answer +MORPH_ANALYZER = MorphAnalyzer() + class KeyWordsReportCheck(BaseReportCriterion): - label = 'Проверка наличия раздела "Ключевые слова"' - description = 'Раздел идет сразу после названия работы и содержит не менее трех ключевых слов' + label = 'Проверка наличия раздела "Ключевые слова" и упоминание их в тексте' + description = 'Раздел идет сразу после названия работы и содержит не менее трех ключевых слов. Слова упоминаются в тексте' id = 'Key_words_report_check' def __init__(self, file_info, min_key_words = 3): super().__init__(file_info) self.min_key_words = min_key_words + self.chapters = [] + self.text_par = [] + self.lemme_list = [] + + def late_init(self): + self.chapters = self.file.make_chapters(self.file_type['report_type']) def check(self): key_words_chapter = self.file.paragraphs[1].lower() if 'ключевые слова' not in key_words_chapter: return answer(False, 'Раздел "Ключевые слова" не найден') cleaned_str = re.sub(r'<[^>]*>', '', key_words_chapter) - final_str = cleaned_str.replace('ключевые слова', '').replace(':','').replace(' ', '') - key_words = final_str.split(',') - if len(key_words) >= self.min_key_words: - return answer(True, 'Пройдена!') - else: + final_str = cleaned_str.replace('ключевые слова', '').replace(':','') + key_words_result = [word.strip() for word in final_str.split(',')] + if len(key_words_result) < self.min_key_words: return answer(False, f'Не пройдена! Количество ключевых слов должно быть не менее {self.min_key_words}') + stop_words = set(stopwords.words("russian")) + if self.file.page_counter() < 4: + return answer(False, "В отчете недостаточно страниц. Нечего проверять.") + self.late_init() + for intro in self.chapters: + header = intro["text"].lower() + if header not in ['аннотация', "ключевые слова"]: + self.intro = intro + for intro_par in self.intro['child']: + par = intro_par['text'].lower() + self.text_par.append(par) + for phrase in key_words_result: + words = word_tokenize(phrase) + words_lemma = [MORPH_ANALYZER.parse(w)[0].normal_form for w in words if w.lower() not in stop_words] + phrase_lemma = ' '.join(words_lemma) + self.lemme_list.append(phrase) + for text in self.text_par: + cleaned_text = re.sub(r'<[^>]*>', '', text) + translator = str.maketrans('', '', string.punctuation) + text_without_punct = cleaned_text.translate(translator) + word_in_text = word_tokenize(text_without_punct) + lemma_text = [MORPH_ANALYZER.parse(w)[0].normal_form for w in word_in_text if w.lower() not in stop_words] + lemma_text_str = ' '.join(lemma_text) + if phrase_lemma in lemma_text_str: + del self.lemme_list[-1] + break + + if self.lemme_list: + return answer(False, f"Не пройдена! В тексте не найдены следующие ключевые слова: «{'», «'.join(self.lemme_list)}»") + else: + return answer(True, f'Пройдена!') From 1be94cd813c0da5c341186169096ea85e9d59a59 Mon Sep 17 00:00:00 2001 From: Marina Date: Sat, 31 Aug 2024 17:16:29 +0300 Subject: [PATCH 10/12] config improving --- .../report_checks/style_check_settings.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index b4c9a093..971fd548 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -180,23 +180,6 @@ class StyleCheckSettings: } } - # },'': - # { - # "style": HEADER_1_NUM_STYLE, - # "docx_style": ["heading 2", "heading 3", "heading 4"], - # "headers": [], - # "unify_regex": None, - # "regex": HEADER_NUM_REGEX - # },'': - # { - # "style": "Main_header", - # "docx_style": ["heading 1"], - # "headers": ["Задание"], - # "unify_regex": None, - # "regex": HEADER_NUM_REGEX - # } - - OPNP_CONFIG = { 'Сравнение аналогов': { @@ -225,7 +208,7 @@ class StyleCheckSettings: "docx_style": ["heading 2"], "headers": ["Аннотация", "Введение", - "Обзор предметной области == Сравнение аналогов", + "Обзор предметной области", "Выбор метода решения", "Заключение", "Список литературы" From 62428c73ad87380a3632907eabb3896b096ce0cd Mon Sep 17 00:00:00 2001 From: Marina Date: Wed, 4 Sep 2024 18:19:38 +0300 Subject: [PATCH 11/12] fix mistakes --- app/main/check_packs/pack_config.py | 2 +- .../checks/report_checks/banned_words_check.py | 4 ++-- app/main/checks/report_checks/key_words_check.py | 2 +- .../report_checks/literature_references.py | 16 ++++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/main/check_packs/pack_config.py b/app/main/check_packs/pack_config.py index 1ff5d434..c053ce0a 100644 --- a/app/main/check_packs/pack_config.py +++ b/app/main/check_packs/pack_config.py @@ -44,7 +44,7 @@ ["spelling_check"], ["max_abstract_size_check"], ["theme_in_report_check"], - ['Key_words_report_check'], + ['key_words_report_check'], ["empty_task_page_check"], ] diff --git a/app/main/checks/report_checks/banned_words_check.py b/app/main/checks/report_checks/banned_words_check.py index ec18d4a9..351b403e 100644 --- a/app/main/checks/report_checks/banned_words_check.py +++ b/app/main/checks/report_checks/banned_words_check.py @@ -23,12 +23,12 @@ def late_init(self): if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): self.words = [morph.normal_forms(word)[0] for word in StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['banned_words']] self.min_count = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['min_count_for_banned_words_check'] - self.max_count = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['min_count_for_banned_words_check'] + self.max_count = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['max_count_for_banned_words_check'] else: if 'any_header' in StyleCheckSettings.CONFIGS.get(self.config): self.words = [morph.normal_forms(word)[0] for word in StyleCheckSettings.CONFIGS.get(self.config)['any_header']['banned_words']] self.min_count = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['min_count_for_banned_words_check'] - self.max_count = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['min_count_for_banned_words_check'] + self.max_count = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['max_count_for_banned_words_check'] def check(self): if self.file.page_counter() < 4: diff --git a/app/main/checks/report_checks/key_words_check.py b/app/main/checks/report_checks/key_words_check.py index adaabfc5..9a403613 100644 --- a/app/main/checks/report_checks/key_words_check.py +++ b/app/main/checks/report_checks/key_words_check.py @@ -12,7 +12,7 @@ class KeyWordsReportCheck(BaseReportCriterion): label = 'Проверка наличия раздела "Ключевые слова" и упоминание их в тексте' description = 'Раздел идет сразу после названия работы и содержит не менее трех ключевых слов. Слова упоминаются в тексте' - id = 'Key_words_report_check' + id = 'key_words_report_check' def __init__(self, file_info, min_key_words = 3): super().__init__(file_info) diff --git a/app/main/checks/report_checks/literature_references.py b/app/main/checks/report_checks/literature_references.py index ba5482b5..32be66ed 100644 --- a/app/main/checks/report_checks/literature_references.py +++ b/app/main/checks/report_checks/literature_references.py @@ -14,16 +14,20 @@ def __init__(self, file_info, min_ref=1, max_ref=1000, headers_map=None): self.literature_header = [] self.name_pattern = r'список[ \t]*(использованных|использованной|)[ \t]*(источников|литературы)' if headers_map: - if StyleCheckSettings.CONFIGS.get(headers_map)['limits']: - self.min_ref = int(StyleCheckSettings.CONFIGS.get(headers_map)['any_header']['min_ref_for_literature_references_check']) - self.max_ref = int(StyleCheckSettings.CONFIGS.get(headers_map)['any_header']['mах_ref_for_literature_references_check']) + self.config = headers_map else: - self.min_ref = min_ref - self.max_ref = max_ref + self.config = 'VKR_HEADERS' if (self.file_type['report_type'] == 'VKR') else 'LR_HEADERS' def late_init_vkr(self): self.headers = self.file.make_chapters(self.file_type['report_type']) - self.literature_header = self.file.find_literature_vkr(self.file_type['report_type']) + self.headers_main = self.file.get_main_headers(self.file_type['report_type']) + if self.headers_main in StyleCheckSettings.CONFIGS.get(self.config): + self.min_ref = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['min_ref_for_literature_references_check'] + self.max_ref = StyleCheckSettings.CONFIGS.get(self.config)[self.headers_main]['mах_ref_for_literature_references_check'] + 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.max_ref = StyleCheckSettings.CONFIGS.get(self.config)['any_header']['mах_ref_for_literature_references_check'] def check(self): if self.file.page_counter() < 4: From 6c78e3a5507ce288bdf60c14141158235f331435 Mon Sep 17 00:00:00 2001 From: Marina Date: Fri, 20 Sep 2024 16:32:27 +0300 Subject: [PATCH 12/12] style setting improving and fix lit_ref for VKR and LR --- .../checks/report_checks/style_check_settings.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/main/checks/report_checks/style_check_settings.py b/app/main/checks/report_checks/style_check_settings.py index 971fd548..88e1a7ad 100644 --- a/app/main/checks/report_checks/style_check_settings.py +++ b/app/main/checks/report_checks/style_check_settings.py @@ -10,6 +10,9 @@ class StyleCheckSettings: HEADER_REGEX = "^\\D+.+$" HEADER_1_REGEX = "^()([\\w\\s]+)$" HEADER_2_REGEX = "^()([\\w\\s]+)\\.$" + STD_BANNED_WORDS = ['мы'] + STD_MIN_LIT_REF = 1 + STD_MAX_LIT_REF = 1000 #just in case for future edit HEADER_1_STYLE = { "bold": True, "italic": False, @@ -90,9 +93,11 @@ class StyleCheckSettings: "headers": ["Исходный код программы"], "unify_regex": APPENDIX_UNIFY_REGEX, "regex": APPENDIX_REGEX, - "banned_words": ['мы'], + "banned_words": STD_BANNED_WORDS, 'min_count_for_banned_words_check': 3, 'max_count_for_banned_words_check': 6, + 'min_ref_for_literature_references_check': STD_MIN_LIT_REF, + 'mах_ref_for_literature_references_check': STD_MAX_LIT_REF }, 'second_header': { @@ -112,9 +117,11 @@ class StyleCheckSettings: "headers": ["ВВЕДЕНИЕ", "ЗАКЛЮЧЕНИЕ", "СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ"], "unify_regex": None, "regex": HEADER_REGEX, - "banned_words": ['мы'], + "banned_words": STD_BANNED_WORDS, 'min_count_for_banned_words_check': 3, 'max_count_for_banned_words_check': 6, + 'min_ref_for_literature_references_check': STD_MIN_LIT_REF, + 'mах_ref_for_literature_references_check': STD_MAX_LIT_REF }, 'second_header': { @@ -159,7 +166,7 @@ class StyleCheckSettings: "header_for_report_section_component": "Поставленная цель и задачи", "unify_regex": None, "regex": HEADER_REGEX, - "banned_words": ['мы'], + "banned_words": STD_BANNED_WORDS, 'min_count_for_banned_words_check': 3, 'max_count_for_banned_words_check': 6, }, @@ -174,7 +181,7 @@ class StyleCheckSettings: "header_for_report_section_component": "", "unify_regex": None, "regex": HEADER_REGEX, - "banned_words": ['мы'], + "banned_words": STD_BANNED_WORDS, 'min_count_for_banned_words_check': 3, 'max_count_for_banned_words_check': 6, }