Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()