Closed siminchengithub closed 4 years ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dfulcer
Hi @siminchengithub, Please update "if entity_data.entities.value:" to "if entity_data.places.value:" in code.
Because the Entity Search API lets you send a search query to Bing and get back search results that include entities and places:
The detailed code is shown below for how to use rename_file (here is the official sample ):
from azure.cognitiveservices.search.entitysearch import EntitySearchClient
from msrest.authentication import CognitiveServicesCredentials
key = <your-key>
client = EntitySearchClient('https://api.cognitive.microsoft.com', CognitiveServicesCredentials(key))
entity_data = client.entities.search(query="RED BAY HOSPITAL",market = 'en-US')
# Your question appears this step.
if entity_data.places.value:
hospital = entity_data.places.value[0]
try:
telephone = hospital.telephone
print(
'Searched for "RED BAY HOSPITAL" and found a hospital with this phone number:')
print(telephone)
except AttributeError:
print("Couldn't find a place!")
else:
print("Didn't see any data..")
@jongio
Hi @siminchengithub , How is this issue going? Feel free to let us know if further help is needed.
We are going to close this issue because we haven’t heard from you in a few days, but please re-open it if the issue still persists.
Describe the bug The EntitySearch python sdk returns NoneType as entity search results for query "RED BAY HOSPITAL". However on https://azure.microsoft.com/en-us/services/cognitive-services/bing-entity-search-api/ it returns the correct entity.
To Reproduce Steps to reproduce the behavior:
from azure.cognitiveservices.search.entitysearch import EntitySearchClient from msrest.authentication import CognitiveServicesCredentials key = <your-key> client = EntitySearchClient('https://api.cognitive.microsoft.com', CognitiveServicesCredentials(key)) entity_data = client.entities.search(query="RED BAY HOSPITAL", market = 'en-US') if entity_data.entities.value: main_entities = [entity for entity in entity_data.entities.value if entity.entity_presentation_info.entity_scenario == "DominantEntity"] if main_entities: print(main_entities[0].description)
Expected behavior I expect no error
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.