Newer
Older
from typing import Optional

Michał Pogoda
committed
class Detection:
"""Interface for detections.
Should be used as base class for all detections.
It should not be used directly. For other detections see: OtherDetection class
"""
return (type(self), *(self.__dict__.values())).__hash__()
"""Mixin for detections with morphosyntactic information.
Eg. detection of "Rolexes" can be thought of as "Rolex"
with morphosyntactic tag "NNS" (noun, plural).
"""
def __init__(
self,
morpho_tag: Optional[str] = None,
lemma: Optional[str] = None,
*args,
**kwargs
) -> None:
"""Initialization of MorphosyntacticInfoMixin.
Args:
morpho_tag (str): Morphosyntactic tag of detection, eg. "NNS",
"sg:nom:m1" etc.
lemma (str): Lemma of detection, eg. "Rolex", "Warszawa" etc.
super().__init__(*args, **kwargs)
self._morpho_tag = morpho_tag
@property
def lemma(self) -> str:
"""Lemma of detection."""
return self._lemma

Michał Pogoda
committed
class NameDetection(MorphosyntacticInfoMixin, Detection):

Michał Pogoda
committed
class SurnameDetection(MorphosyntacticInfoMixin, Detection):
"""Class representing surname detection.
Eg.: "Smith", "Johnson"
"""
class LocationDetection(MorphosyntacticInfoMixin, Detection):
Eg.: "Park Narodowy Białowieski", "Tatry"
"""
TYPE_NAME = "location"
class OrganizationNameDetection(MorphosyntacticInfoMixin, Detection):
"""Class for organization name detection.
Eg.: "Apple", "Microsoft"
"""
class ProperNameDetection(MorphosyntacticInfoMixin, Detection):
class TitleDetection(MorphosyntacticInfoMixin, Detection):
"""Class representing title detection.
Eg.: "Fast and Furious", "The Lord of the Rings"
"""
class HydronymDetection(MorphosyntacticInfoMixin, Detection):

Michał Pogoda
committed
class StreetNameDetection(MorphosyntacticInfoMixin, Detection):
"""Class representing street name detection.
Eg.: "Marszałkowska", "Kościuszki"
"""

Michał Pogoda
committed
class CityDetection(MorphosyntacticInfoMixin, Detection):

Michał Pogoda
committed
class CountryDetection(MorphosyntacticInfoMixin, Detection):
"""Class representing country detection.
Eg.: "Poland", "Germany"
"""

Michał Pogoda
committed
class UrlDetection(Detection):
Eg.: "https://www.google.com", "www.google.com"
"""
TYPE_NAME = "url"

Michał Pogoda
committed
class UserDetection(Detection):
"""Class for user detection.
Eg.: "@bob25", "@angelica111"
"""

Michał Pogoda
committed
class EmailDetection(Detection):
Eg.: "123-456-789", "+49 123 456 789"
"""
TYPE_NAME = "phone_number"
class TINDetection(Detection): # Tax Identification Number
"""Class for NIP (Tax Identification Number) detection.
Eg.: "123-456-32-18", "1234563218"
"""
class KRSDetection(Detection): # National Court Register
Eg.: "AB1234567890"
"""
TYPE_NAME = "serial_number"
class OtherDetection(Detection): # Non standard entity
"""Detection of an entity that does not fit into other categories."""