1- from azure .cognitiveservices .search .entitysearch import EntitySearchAPI
1+ from azure .cognitiveservices .search .entitysearch import EntitySearchClient
22from azure .cognitiveservices .search .entitysearch .models import Place , ErrorResponseException
33from msrest .authentication import CognitiveServicesCredentials
44
@@ -11,7 +11,10 @@ def dominant_entity_lookup(subscription_key):
1111
1212 This will look up a single entity (Satya Nadella) and print out a short description about them.
1313 """
14- client = EntitySearchAPI (CognitiveServicesCredentials (subscription_key ))
14+ client = EntitySearchClient (
15+ endpoint = "https://api.cognitive.microsoft.com" ,
16+ credentials = CognitiveServicesCredentials (subscription_key )
17+ )
1518
1619 try :
1720 entity_data = client .entities .search (query = "satya nadella" )
@@ -41,7 +44,10 @@ def handling_disambiguation(subscription_key):
4144
4245 "This will handle disambiguation results for an ambiguous query (William Gates)".
4346 """
44- client = EntitySearchAPI (CognitiveServicesCredentials (subscription_key ))
47+ client = EntitySearchClient (
48+ endpoint = "https://api.cognitive.microsoft.com" ,
49+ credentials = CognitiveServicesCredentials (subscription_key )
50+ )
4551
4652 try :
4753 entity_data = client .entities .search (query = "william gates" )
@@ -89,7 +95,10 @@ def restaurant_lookup(subscription_key):
8995
9096 This will look up a single restaurant (john howie bellevue) and print out its phone number.
9197 """
92- client = EntitySearchAPI (CognitiveServicesCredentials (subscription_key ))
98+ client = EntitySearchClient (
99+ endpoint = "https://api.cognitive.microsoft.com" ,
100+ credentials = CognitiveServicesCredentials (subscription_key )
101+ )
93102
94103 try :
95104 entity_data = client .entities .search (query = "john howie bellevue" )
@@ -133,7 +142,10 @@ def multiple_restaurant_lookup(subscription_key):
133142 This will look up a list of restaurants (seattle restaurants) and present their names and phone numbers.
134143 """
135144
136- client = EntitySearchAPI (CognitiveServicesCredentials (subscription_key ))
145+ client = EntitySearchClient (
146+ endpoint = "https://api.cognitive.microsoft.com" ,
147+ credentials = CognitiveServicesCredentials (subscription_key )
148+ )
137149
138150 try :
139151 restaurants = client .entities .search (query = "seattle restaurants" )
@@ -176,7 +188,10 @@ def error(subscription_key):
176188 This triggers a bad request and shows how to read the error response.
177189 """
178190
179- client = EntitySearchAPI (CognitiveServicesCredentials (subscription_key ))
191+ client = EntitySearchClient (
192+ endpoint = "https://api.cognitive.microsoft.com" ,
193+ credentials = CognitiveServicesCredentials (subscription_key )
194+ )
180195
181196 try :
182197 entity_data = client .entities .search (
@@ -199,8 +214,8 @@ def error(subscription_key):
199214
200215
201216if __name__ == "__main__" :
202- import sys
203- import os .path
204- sys . path . append ( os . path . abspath ( os . path . join ( __file__ , ".." , ".." )))
205- from tools import execute_samples
217+ import sys , os . path
218+ sys . path . append ( os .path . abspath ( os . path . join ( __file__ , ".." , ".." )))
219+ from samples . tools import execute_samples
220+ import execute_samples
206221 execute_samples (globals (), SUBSCRIPTION_KEY_ENV_NAME )
0 commit comments