How to use the alephclient.services.geoextract_pb2_grpc.GeoExtractStub 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 / aleph / analyze / extract_country.py View on Github external
def analyze(self, document):
        if not document.supports_nlp or len(document.countries):
            return

        try:
            service = GeoExtractStub(self.channel)
            texts = self.text_iterator(document)
            countries = service.ExtractCountries(texts)
            for country in countries.countries:
                document.add_country(country)

            log.info("Countries [%s]: %r", document.id, document.countries)
        except self.Error as exc:
            log.exception("gRPC Error: %s", self.SERVICE)
            self.reset_channel()