An error occurred while loading the file. Please try again.
-
Michał Pogoda authoredc814a2c1
detection.py 2.34 KiB
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 tuple(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 PhoneNumberDetection(Detection):
def __init__(self) -> None:
super().__init__("phone_number")
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 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")