docs = [doc for doc in result if not doc.is_error] RETURNING 'NoneType' object has no attribute 'errors'

Thomas White 1 Reputation point
2022-05-05T03:03:41.46+00:00

Hi there,

I'm using text_analytics_client.begin_analyze_healthcare_entities and am getting this error on line 14: 'NoneType' object has no attribute 'errors'.

Anyone else experiencing this issue? Guidance?

from azure.core.credentials import AzureKeyCredential
from azure.ai.textanalytics import TextAnalyticsClient

credential = AzureKeyCredential("00000000000000000000000")
endpoint="https://blablabla.cognitiveservices.azure.com/"

text_analytics_client = TextAnalyticsClient(endpoint, credential)

documents = ["Subject is taking 100mg of ibuprofen twice daily"]

poller = text_analytics_client.begin_analyze_healthcare_entities(documents)
result = poller.result()

docs = [doc for doc in result if not doc.is_error]

print("Results of Healthcare Entities Analysis:")
for idx, doc in enumerate(docs):
for entity in doc.entities:
print("Entity: {}".format(entity.text))
print("...Normalized Text: {}".format(entity.normalized_text))
print("...Category: {}".format(entity.category))
print("...Subcategory: {}".format(entity.subcategory))
print("...Offset: {}".format(entity.offset))
print("...Confidence score: {}".format(entity.confidence_score))
if entity.data_sources is not None:
print("...Data Sources:")
for data_source in entity.data_sources:
print("......Entity ID: {}".format(data_source.entity_id))
print("......Name: {}".format(data_source.name))
if entity.assertion is not None:
print("...Assertion:")
print("......Conditionality: {}".format(entity.assertion.conditionality))
print("......Certainty: {}".format(entity.assertion.certainty))
print("......Association: {}".format(entity.assertion.association))
for relation in doc.entity_relations:
print("Relation of type: {} has the following roles".format(relation.relation_type))
for role in relation.roles:
print("...Role '{}' with entity '{}'".format(role.name, role.entity.text))
print("------------------------------------------")

Azure Health Data Services
Azure Health Data Services
An Azure offering that provides a suite of purpose-built technologies for protected health information in the cloud.
155 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,642 questions
{count} votes