From b815f34513d75b4723fd300742aa191c9fd783d3 Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Fri, 5 Mar 2021 11:02:55 -0500 Subject: [PATCH] update samples to use actual role names --- .../sample_analyze_healthcare_entities_async.py | 6 +++--- .../samples/sample_analyze_healthcare_entities.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py index 40740f1ad8b9..1d66d6752213 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/async_samples/sample_analyze_healthcare_entities_async.py @@ -48,7 +48,7 @@ async def analyze_healthcare_entities_async(self): # [START analyze_healthcare_entities_async] import os from azure.core.credentials import AzureKeyCredential - from azure.ai.textanalytics import HealthcareEntityRelationType + from azure.ai.textanalytics import HealthcareEntityRelationType, HealthcareEntityRelationRoleType from azure.ai.textanalytics.aio import TextAnalyticsClient endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] @@ -115,8 +115,8 @@ async def analyze_healthcare_entities_async(self): for relation in dosage_of_medication_relations: # The DosageOfMedication relation should only contain the dosage and medication roles - dosage_role = next(filter(lambda x: x.name == "Attribute", relation.roles)) - medication_role = next(filter(lambda x: x.name == "Entity", relation.roles)) + dosage_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.DOSAGE, relation.roles)) + medication_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.MEDICATION, relation.roles)) try: dosage_value = int(re.findall(r"\d+", dosage_role.entity.text)[0]) # we find the numbers in the dosage diff --git a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py index 036f25cb561e..b8d0a08d2e5e 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py +++ b/sdk/textanalytics/azure-ai-textanalytics/samples/sample_analyze_healthcare_entities.py @@ -45,7 +45,7 @@ def analyze_healthcare_entities(self): # [START analyze_healthcare_entities] import os from azure.core.credentials import AzureKeyCredential - from azure.ai.textanalytics import TextAnalyticsClient, HealthcareEntityRelationType + from azure.ai.textanalytics import TextAnalyticsClient, HealthcareEntityRelationType, HealthcareEntityRelationRoleType endpoint = os.environ["AZURE_TEXT_ANALYTICS_ENDPOINT"] key = os.environ["AZURE_TEXT_ANALYTICS_KEY"] @@ -111,8 +111,8 @@ def analyze_healthcare_entities(self): for relation in dosage_of_medication_relations: # The DosageOfMedication relation should only contain the dosage and medication roles - dosage_role = next(filter(lambda x: x.name == "Attribute", relation.roles)) - medication_role = next(filter(lambda x: x.name == "Entity", relation.roles)) + dosage_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.DOSAGE, relation.roles)) + medication_role = next(filter(lambda x: x.name == HealthcareEntityRelationRoleType.MEDICATION, relation.roles)) try: dosage_value = int(re.findall(r"\d+", dosage_role.entity.text)[0]) # we find the numbers in the dosage