-
Notifications
You must be signed in to change notification settings - Fork 2
750 was were check #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
750 was were check #755
Conversation
detected[page_index] = [] | ||
detected[page_index].append(f'{sentence_index+1}: {sentence}') | ||
if len(detected): | ||
result_str = 'Обнаружены конструкции (Был/Была/Было/Были), которые можно удалить без потери смысла:<br><br>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот эта строчка повторяется и в критерии для слайдов. Ее необходимо вынести в константу в app/nlp/is_passive_was_were_sentence.py и импортировать в обоих критериях
if self.file.page_counter() < 4: | ||
return answer(False, 'В отчёте недостаточно страниц. Нечего проверять.') | ||
detected = {} | ||
for page_index, page_text in self.file.pdf_file.get_text_on_page().items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как будто бы сама обработка для слайдов и отчетов отличается по существу только контейнерами (мы достаем из слайдов или из страниц предложения), а также сообщением для детализации (или
Страница №{page_index+1}:<br>' + '<br>'.join(messages) + '<br><br>
или
'Слайд №{slide_index+1}:<br>' + '<br>'.join(messages) + '<br><br>'
Предлагаю максимум общей логики вынести в отдельную функцию в app/nlp/is_passive_was_were_sentence.py, указать ей параметрами информацию об источнике (слайды или страницы - для итогового сообщения) и поправить два критерия так, чтобы в них дублирующаяся логика заменилась на вызов этой функции
import pymorphy2 | ||
import string | ||
|
||
morph = pymorphy2.MorphAnalyzer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавьте в данном файле в виде комментария примеры хороших и плохих предложений, которые начинаются с Был*
for slide_index, slide_text in enumerate(self.file.get_text_from_slides()): | ||
mock_slide_text = "Было проведено исследование. Было бы здорово. Как бы было здорово. Была проделана работа. Были сделаны шаги..." | ||
sentences = re.split(r'(?<=[.!?…])\s+', mock_slide_text) | ||
for sentence_index, sentence in enumerate(sentences): | ||
if is_passive_was_were_sentece(sentence): | ||
if slide_index not in detected: | ||
detected[slide_index] = [] | ||
detected[slide_index].append(f'{sentence_index+1}: {sentence}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проверяется не текст слайда, а содержимое mock_slide_text
for slide_index, slide_text in enumerate(self.file.get_text_from_slides()): | ||
mock_slide_text = "Было проведено исследование. Было бы здорово. Как бы было здорово. Была проделана работа. Были сделаны шаги..." | ||
sentences = re.split(r'(?<=[.!?…])\s+', mock_slide_text) | ||
for sentence_index, sentence in enumerate(sentences): | ||
if is_passive_was_were_sentece(sentence): | ||
if slide_index not in detected: | ||
detected[slide_index] = [] | ||
detected[slide_index].append(f'{sentence_index+1}: {sentence}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предложения (и в слайдах, и тем более в отчетах) могут быть достаточно большими - ограничьте длину выводимой части sentence
(например до 30 символов)
if len(detected): | ||
result_str = 'Обнаружены конструкции (Был/Была/Было/Были), которые можно удалить без потери смысла:<br><br>' | ||
for slide_index, messages in detected.items(): | ||
result_str += f'Слайд №{slide_index+1}:<br>' + '<br>'.join(messages) + '<br><br>' | ||
result_score = 0 | ||
else: | ||
result_str = 'Пройдена!' | ||
result_score = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Введите логику с порогами оценивания (и для слайдов, и для отчетов): если количество обнаруженных предложений больше N -> 0 баллов, иначе 1
- N задается аргументом для конструктора, пригодится значение по умолчанию
Задача #750
Добавлен критерий для отчётов и презентаций. Критерий проверяет предложения в начале которых стоят избыточные по смыслу глаголы Был/Была/Были/Было.