How to use the alephclient.services.entityextract_pb2.ExtractedEntity.IPADDRESS function in alephclient

To help you get started, we’ve selected a few alephclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alephdata / aleph / services / extract-entities / entityextractor / result.py View on Github external
def __init__(self, ctx, label, start, end):
        super(LocationResult, self).__init__(ctx, label, start, end)
        self.countries = self.resolver.get_countries(label)


class LanguageResult(Result):
    category = ExtractedEntity.LANGUAGE

    def __init__(self, ctx, label, start, end):
        label = label.strip().lower()
        super(LanguageResult, self).__init__(ctx, label, start, end)


class IPAddressResult(Result):
    """Pull IPv4, IPv6 - and validate using on-board Python tools."""
    category = ExtractedEntity.IPADDRESS

    def __init__(self, ctx, label, start, end):
        super(IPAddressResult, self).__init__(ctx, label, start, end)
        try:
            ip = ip_address(label)
            self.key = self.label = str(ip)
        except ValueError:
            self.valid = False


class EmailResult(Result):
    category = ExtractedEntity.EMAIL

    def __init__(self, ctx, label, start, end):
        super(EmailResult, self).__init__(ctx, label, start, end)
        self.key = self.label_key(self.label)