Skip to content

Commit efc813c

Browse files
committed
working on entity samples, returning resource not found
1 parent 81b6423 commit efc813c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,6 @@ ENV/
9999

100100
# mypy
101101
.mypy_cache/
102+
103+
# idea
104+
.idea/

samples/search/entity_search_samples.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from azure.cognitiveservices.search.entitysearch import EntitySearchAPI
1+
from azure.cognitiveservices.search.entitysearch import EntitySearchClient
22
from azure.cognitiveservices.search.entitysearch.models import Place, ErrorResponseException
33
from msrest.authentication import CognitiveServicesCredentials
44

@@ -9,7 +9,10 @@ def dominant_entity_lookup(subscription_key):
99
1010
This will look up a single entity (Satya Nadella) and print out a short description about them.
1111
"""
12-
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))
12+
client = EntitySearchClient(
13+
endpoint="https://api.cognitive.microsoft.com/bing/v7.0",
14+
credentials=CognitiveServicesCredentials(subscription_key)
15+
)
1316

1417
try:
1518
entity_data = client.entities.search(query="satya nadella")
@@ -37,7 +40,10 @@ def handling_disambiguation(subscription_key):
3740
3841
"This will handle disambiguation results for an ambiguous query (William Gates)".
3942
"""
40-
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))
43+
client = EntitySearchClient(
44+
endpoint="https://api.cognitive.microsoft.com/bing/v7.0",
45+
credentials=CognitiveServicesCredentials(subscription_key)
46+
)
4147

4248
try:
4349
entity_data = client.entities.search(query="william gates")
@@ -81,7 +87,10 @@ def restaurant_lookup(subscription_key):
8187
8288
This will look up a single restaurant (john howie bellevue) and print out its phone number.
8389
"""
84-
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))
90+
client = EntitySearchClient(
91+
endpoint="https://api.cognitive.microsoft.com/bing/v7.0",
92+
credentials=CognitiveServicesCredentials(subscription_key)
93+
)
8594

8695
try:
8796
entity_data = client.entities.search(query="john howie bellevue")
@@ -123,7 +132,10 @@ def multiple_restaurant_lookup(subscription_key):
123132
This will look up a list of restaurants (seattle restaurants) and present their names and phone numbers.
124133
"""
125134

126-
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))
135+
client = EntitySearchClient(
136+
endpoint="https://api.cognitive.microsoft.com/bing/v7.0",
137+
credentials=CognitiveServicesCredentials(subscription_key)
138+
)
127139

128140
try:
129141
restaurants = client.entities.search(query="seattle restaurants")
@@ -163,7 +175,10 @@ def error(subscription_key):
163175
This triggers a bad request and shows how to read the error response.
164176
"""
165177

166-
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))
178+
client = EntitySearchClient(
179+
endpoint="https://api.cognitive.microsoft.com/bing/v7.0",
180+
credentials=CognitiveServicesCredentials(subscription_key)
181+
)
167182

168183
try:
169184
entity_data = client.entities.search(query="tom cruise", market="no-ty")
@@ -184,5 +199,5 @@ def error(subscription_key):
184199
if __name__ == "__main__":
185200
import sys, os.path
186201
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
187-
from tools import execute_samples
202+
from samples.tools import execute_samples
188203
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)

0 commit comments

Comments
 (0)