Skip to content

Conversation

@theotff
Copy link
Collaborator

@theotff theotff commented Oct 12, 2021

No description provided.

@theotff
Copy link
Collaborator Author

theotff commented Oct 12, 2021

Сделал привязку алгоритма соренсена. Поправил алгоритм так, как сказал @LiceyMaxim

Copy link
Member

@ARQtty ARQtty left a comment

Choose a reason for hiding this comment

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

Нужен рефактор алгоритмов сравнения

@@ -0,0 +1,9 @@
def comparison(first_phrase: str, second_phrase: str) -> float:
Copy link
Member

Choose a reason for hiding this comment

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

Раньше у нас был план сделать базовый класс алгоритма проверки. Сейчас добавился третий алгоритм сравнения, и всё начало быть несистемно и хаотично. Сделай пожалуйста базовый класс проверки в models/ и отнаследуй от него все текущие алгоритмы сравнения

- Create BaseAlgorithm
- Inherit algorithms from it
- Rename test files to single standart
@theotff
Copy link
Collaborator Author

theotff commented Oct 14, 2021

  • Вынес algorithm в базовый класс
  • Сделал рефактор алгоритмов сравнения
    • Сделал базовый класс алгоритма
    • Отнаследовал все текущие алгоритмы сравнения от него
  • Переименовал тесты по единому образцу

Copy link
Member

@ARQtty ARQtty left a comment

Choose a reason for hiding this comment

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

Базовый Алгоритм должен быть только один. Нужно переместить бизнес-логику работы с файлами лабы в специальный для этого класс, а сравнение лаб как строк оставить в models/

class BaseCheck():

def __init__(self) -> None:
def __init__(self, comparison_method: BaseAlgorithm.comparison) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

не стоит прокидывать конкретный метод класса. Достаточно прокинуть класс

raise NotImplementedError
return self.comparison_method(code, lab)

def name(self) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

тут можно сделать магию вроде return self.__class__.__name__

from models.base_algorithm import BaseAlgorithm


class BaseCheck():
Copy link
Member

Choose a reason for hiding this comment

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

Базовая Проверка? Что за проверка? Вне контекста непонятно. Базовый Алгоритм Сравнения был бы более трактуем


def name(self) -> str:
return self.__class__.__name__.lower()
return self.__class__.__name__.lower()[:-5]
Copy link
Member

Choose a reason for hiding this comment

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

хочется не заниматься таким переопределением. Можно делать это в базовом классе

- Move algorithm implementation to models
@theotff
Copy link
Collaborator Author

theotff commented Oct 15, 2021

Перекинул обработку алгоритмов в models

self.connector = SQLiteConnector()
self.levenshtein = Levenshtein()
self.jaccard = Jaccard()
self.methods = [
Copy link
Member

Choose a reason for hiding this comment

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

тут не хватает коммента о том, зачем сохранять именно такие туплы

@theotff
Copy link
Collaborator Author

theotff commented Oct 17, 2021

  • Убрал name в BaseAlgorithm
  • Добавил hint для tuple в get_labs
  • Добавил коммент про булеан
  • Убрал обработку лабы из цикла в отдельную функцию

Copy link
Member

@ARQtty ARQtty left a comment

Choose a reason for hiding this comment

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

гуд. Чуть уточнить типы - и можно мержить

@theotff
Copy link
Collaborator Author

theotff commented Oct 18, 2021

Поправил типизацию

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants