How to use the alephclient.services.entityextract_pb2.ExtractedEntity.LANGUAGE 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 / service.py View on Github external
def extract_polyglot(self, text):
        try:
            parsed = Text(text)
            lang = parsed.language
            if lang.confidence > 90:
                yield self.make_entity(lang.code,
                                       ExtractedEntity.LANGUAGE,
                                       0, len(text))
            if lang.code not in POLYGLOT_LANGUAGES:
                return
            for entity in parsed.entities:
                label = ' '.join(entity)
                type_ = POLYGLOT_TYPES.get(entity.tag)
                if type_ is not None:
                    yield self.make_entity(label, type_,
                                           entity.start,
                                           entity.end)
        except Exception as ex:
            log.warning("Polyglot failed: %s" % ex)
github alephdata / aleph / services / extract-entities / entityextractor / result.py View on Github external
if self.valid and ' ' not in self.label:
            self.valid = False


class LocationResult(NamedResult):
    """Locations are being mapped to countries."""
    resolver = LocationResolver()
    category = ExtractedEntity.LOCATION

    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: