Conversation
|
Запрещенные домены не добавлял проверку, так как есть уже критерий banned_words_in_lit, который уже проверяет это момент (тестировал). |
HadronCollider
left a comment
There was a problem hiding this comment.
Исправьте логику в #776 и подтяните изменения
После поставьте лейбл "need_review"
| return start_index | ||
|
|
||
| def find_domains(self, sources: str): | ||
| pattern = r'(?:https?|ftp)?://([^/\s?#]+)' |
There was a problem hiding this comment.
Вынесите в поле класса
| if match and match.group(1): | ||
| self.literature_domains.append(match.group(1)) | ||
| else: | ||
| self.literature_domains.append('') #чтобы можно было определить номер |
There was a problem hiding this comment.
Сократите до 1 строки (тернарный оператор)
| break | ||
| return start_index | ||
|
|
||
| def find_domains(self, sources: str): |
There was a problem hiding this comment.
смысла в этой функции как методе класса - 0 (он ещё и меняет состояние объекта, хотя вроде как должен просто найти домены) - проще regexp использовать в count_sources_*, и self.literature_domains.append делать там же (там будет и доступ к индексу)
| if match and match.group(1): | ||
| self.literature_domains.append(match.group(1)) | ||
| else: | ||
| self.literature_domains.append('') #чтобы можно было определить номер |
There was a problem hiding this comment.
Чтобы определить номер, достаточно хранить его - вместе с доменом, иначе у вас есть список из 100 пустых строк (=много источников), потому что доменов среди нет нет
| counter = Counter([text.lower() for text in self.literature_reference_text]) | ||
| def checking_duplicate_sources(self, sources: list[str], max_count: int) -> list: | ||
| """Функция нахождения дубликатов в определенных позициях""" | ||
| counter = Counter([text.lower() for text in sources]) |
There was a problem hiding this comment.
замените лист на генератор - он будет работать быстрее и меньше займет памяти
| for text, count in counter.items(): | ||
| if count >= 2: | ||
| positions_duplicates = [i + 1 for i, text_in_ref in enumerate(self.literature_reference_text) if text == text_in_ref.lower()] | ||
| if count >= max_count and text != '': |
There was a problem hiding this comment.
Чтобы не делать на каждом шаге итерации сравнение text != '' - можно ещё на этапе формирования Counter не добавлять эти строки (например, фильтруя text.lower() for text in sources if text.strip())
| def checking_duplicate_sources(self) -> list: | ||
| """Функция нахождения дубликатов в источниках""" | ||
| counter = Counter([text.lower() for text in self.literature_reference_text]) | ||
| def checking_duplicate_sources(self, sources: list[str], max_count: int) -> list: |
There was a problem hiding this comment.
добавьте для max_count значение по умолчанию (= исходная логика с дубликатами источников)
No description provided.