Skip to content

Commit 7ee6bda

Browse files
iscai-msftlmazuel
authored andcommitted
Cognitive services python custom search samples (#21)
* added working samples for common and detection * edited common and detection parameters and completed find_similar sample * edited find_similar sample and added group sample * added identify sample * added samples for verify * finished samples and edited retrieval method of environment variables * cleaned up samples, getting rid of unused imports and variables * consolidated the face samples into a single python file face_samples.py * edited Custom Search Samples, as CustomSearchAPI has been switched to CustomSearchClient * got rid of changes I accidentally made to text analytics and visual search samples * added .idea to gitignore and edited import for tools * updated custom web search to address requested changes * slight spacing formatting * Update requirements.txt
1 parent 33f36da commit 7ee6bda

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ azure-cognitiveservices-language-luis
22
azure-cognitiveservices-language-spellcheck
33
azure-cognitiveservices-language-textanalytics
44
azure-cognitiveservices-search-autosuggest
5-
azure-cognitiveservices-search-customsearch
5+
azure-cognitiveservices-search-customsearch>=0.2.0 # sample won't work with previous versions
66
azure-cognitiveservices-search-entitysearch
77
azure-cognitiveservices-search-imagesearch
88
azure-cognitiveservices-search-newssearch

samples/search/custom_search_samples.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from azure.cognitiveservices.search.customsearch import CustomSearchAPI
1+
from azure.cognitiveservices.search.customsearch import CustomSearchClient
22
from msrest.authentication import CognitiveServicesCredentials
33

44
SUBSCRIPTION_KEY_ENV_NAME = "CUSTOMSEARCH_SUBSCRIPTION_KEY"
@@ -8,7 +8,8 @@ def custom_search_web_page_result_lookup(subscription_key):
88
99
This will look up a single query (Xbox) and print out name and url for first web result.
1010
"""
11-
client = CustomSearchAPI(CognitiveServicesCredentials(subscription_key))
11+
12+
client = CustomSearchClient(CognitiveServicesCredentials(subscription_key))
1213

1314
try:
1415
web_data = client.custom_instance.search(query="xbox", custom_config=1)
@@ -25,8 +26,9 @@ def custom_search_web_page_result_lookup(subscription_key):
2526
except Exception as err:
2627
print("Encountered exception. {}".format(err))
2728

29+
2830
if __name__ == "__main__":
2931
import sys, os.path
30-
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
32+
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
3133
from tools import execute_samples
3234
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)

0 commit comments

Comments
 (0)