from dataclasses import dataclass from typing import Optional @dataclass class Detection: def __init__(self, type_name: str) -> None: self._type_name = type_name def __hash__(self) -> int: return (type(self), *(self.__dict__.values())).__hash__() class MorphosyntacticInfoMixin: def __init__(self, morpho_tag: str, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self._morpho_tag = morpho_tag @property def morpho_tag(self) -> str: return self._morpho_tag class NameDetection(MorphosyntacticInfoMixin, Detection): def __init__(self, morpho_tag: Optional[str] = None) -> None: super().__init__(morpho_tag=morpho_tag, type_name="name") class SurnameDetection(MorphosyntacticInfoMixin, Detection): def __init__(self, morpho_tag: Optional[str] = None) -> None: super().__init__(morpho_tag=morpho_tag, type_name="surname") class StreetNameDetection(MorphosyntacticInfoMixin, Detection): def __init__(self, morpho_tag: Optional[str] = None) -> None: super().__init__(morpho_tag=morpho_tag, type_name="street_name") class CityDetection(MorphosyntacticInfoMixin, Detection): def __init__(self, morpho_tag: Optional[str] = None) -> None: super().__init__(morpho_tag=morpho_tag, type_name="city") class CountryDetection(MorphosyntacticInfoMixin, Detection): def __init__(self, morpho_tag: Optional[str] = None) -> None: super().__init__(morpho_tag=morpho_tag, type_name="country") class UrlDetection(Detection): def __init__(self) -> None: super().__init__("url") class UserDetection(Detection): def __init__(self) -> None: super().__init__("user") class EmailDetection(Detection): def __init__(self) -> None: super().__init__("email") class NumberDetection(Detection): def __init__(self) -> None: super().__init__("number") class PhoneNumberDetection(NumberDetection): def __init__(self) -> None: super().__init__() self._type_name = "phone_number" class TINDetection(Detection): # Tax Identification Number def __init__(self) -> None: super().__init__("tin") class KRSDetection(Detection): # National Court Register def __init__(self) -> None: super().__init__("krs") class OtherDetection(Detection): # Non standard entity def __init__(self) -> None: super().__init__("other")