Skip to content

Implement sorensen_dice algorithm#14

Open
theotff wants to merge 7 commits intomainfrom
api
Open

Implement sorensen_dice algorithm#14
theotff wants to merge 7 commits intomainfrom
api

Conversation

@theotff
Copy link
Copy Markdown
Collaborator

@theotff theotff commented Oct 12, 2021

No description provided.

@theotff
Copy link
Copy Markdown
Collaborator Author

theotff commented Oct 12, 2021

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

Copy link
Copy Markdown
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.

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

Comment thread api/utils/scoring/sorensen.py Outdated
Comment thread models/sorensen/sorensens_dice.py Outdated
@@ -0,0 +1,9 @@
def comparison(first_phrase: str, second_phrase: str) -> float:
Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

theotff commented Oct 14, 2021

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

Copy link
Copy Markdown
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/

Comment thread api/utils/scoring/base_check.py Outdated
class BaseCheck():

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

Choose a reason for hiding this comment

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

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

Comment thread api/utils/scoring/base_check.py Outdated
raise NotImplementedError
return self.comparison_method(code, lab)

def name(self) -> str:
Copy link
Copy Markdown
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__

Comment thread api/utils/scoring/base_check.py Outdated
from models.base_algorithm import BaseAlgorithm


class BaseCheck():
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread api/utils/scoring/jaccard.py Outdated

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

Choose a reason for hiding this comment

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

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

Comment thread models/base_algorithm.py
- Move algorithm implementation to models
@theotff
Copy link
Copy Markdown
Collaborator Author

theotff commented Oct 15, 2021

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

Comment thread api/utils/lab_processing.py Outdated
Comment thread api/utils/lab_processing.py
self.connector = SQLiteConnector()
self.levenshtein = Levenshtein()
self.jaccard = Jaccard()
self.methods = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Comment thread models/jaccard.py Outdated
@theotff
Copy link
Copy Markdown
Collaborator Author

theotff commented Oct 17, 2021

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

Copy link
Copy Markdown
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.

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

Comment thread api/utils/lab_processing.py Outdated
Comment thread api/utils/lab_processing.py Outdated
Comment thread models/base_algorithm.py Outdated
@theotff
Copy link
Copy Markdown
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.

2 participants