From 5ec5e42fa1f5909bf3adf6415debb6514022273d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pogoda?= <mipo57@e-science.pl> Date: Tue, 7 Mar 2023 08:28:52 +0100 Subject: [PATCH] [WIP] Style optimizations --- src/annotations/annotations.py | 8 ++++---- src/detections/detection.py | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/annotations/annotations.py b/src/annotations/annotations.py index 4ba6feb..584f33f 100644 --- a/src/annotations/annotations.py +++ b/src/annotations/annotations.py @@ -1,3 +1,5 @@ +from dataclasses import dataclass +@dataclass class Annotation: def __hash__(self) -> int: return (type(self), *(self.__dict__.values())).__hash__() @@ -6,8 +8,6 @@ class Annotation: class MorphosyntacticAnnotation(Annotation): def __init__(self, morphosyntactic_tag) -> None: self.morphosyntactic_tag = morphosyntactic_tag - - +@dataclass class NerAnnotation(Annotation): - def __init__(self, ner_type: str) -> None: - self.ner_type = ner_type + ner_type: str \ No newline at end of file diff --git a/src/detections/detection.py b/src/detections/detection.py index fad8a6d..96e60c7 100644 --- a/src/detections/detection.py +++ b/src/detections/detection.py @@ -1,12 +1,10 @@ from typing import Optional +from dataclasses import dataclass - +@dataclass class Detection: TYPE_NAME = "detection" - def __init__(self) -> None: - pass - def __hash__(self) -> int: return (type(self), *(self.__dict__.values())).__hash__() -- GitLab