from dataclasses import dataclass @dataclass class Annotation: def __hash__(self) -> int: return (type(self), *(self.__dict__.values())).__hash__() class MorphosyntacticAnnotation(Annotation): def __init__(self, morphosyntactic_tag) -> None: self.morphosyntactic_tag = morphosyntactic_tag class NerAnnotation(Annotation): def __init__(self, ner_type: str) -> None: self.ner_type = ner_type