Cognitive Services SDK Samples (Ruby)
These samples will show you how to get up and running using the SDKs for various Cognitive Services. They'll cover a few rudimentary use cases and hopefully express best practices for interacting with the data from these APIs.
Features
This project framework provides examples for the following services:
- Using the Computer Vision SDK for the Computer Vision API
- Using the Content Moderator SDK for the Content Moderator API
- Using the Custom Search SDK for the Custom Search API
- Using the Entity Search SDK for the Entity Search API
- Using the Image Search SDK for the Image Search API
- Using the News Search SDK for the News Search API
- Using the Spell Check SDK for the Spell Check API
- Using the Text Analytics SDK for the Text Analytics API
- Using the Video Search SDK for the Video Search API
- Using the Web Search SDK for the Web Search API
Run this sample
If you don't already have it, get ruby.
Clone the repository.
git clone https://github.com/Azure-Samples/cognitive-services-ruby-sdk-samples.git
Install the dependencies.
cd cognitive-services-ruby-sdk-samples bundle install
Get a cognitive services API key with which to authenticate the SDK's calls. Sign up here by navigating to the right service and acquiring an API key. You can get a trial key for free which will expire after 30 days.
Set the following environment variables. You only need to set the environment variables for which you want to run the samples.
No. | Service Name | Environment Variable to set | Notes |
---|---|---|---|
1 | azure_cognitiveservices_computervision | COMPUTERVISION_SUBSCRIPTION_KEY | Your Service Key |
2 | azure_cognitiveservices_customsearch | CUSTOMSEARCH_SUBSCRIPTION_KEY | Your Service Key |
CUSTOMSEARCH_SEARCH_CONFIG | You can set up the search config here | ||
3 | azure_cognitiveservices_entitysearch | ENTITYSEARCH_SUBSCRIPTION_KEY | Your Service Key |
4 | azure_cognitiveservices_imagesearch | IMAGESEARCH_SUBSCRIPTION_KEY | Your Service Key |
5 | azure_cognitiveservices_newssearch | NEWSSEARCH_SUBSCRIPTION_KEY | Your Service Key |
6 | azure_cognitiveservices_spellcheck | SPELLCHECK_SUBSCRIPTION_KEY | Your Service Key |
7 | azure_cognitiveservices_textanalytics | TEXTANALYTICS_SUBSCRIPTION_KEY | Your Service Key |
8 | azure_cognitiveservices_videosearch | VIDEOSEARCH_SUBSCRIPTION_KEY | Your Service Key |
9 | azure_cognitiveservices_websearch | WEBSEARCH_SUBSCRIPTION_KEY | Your Service Key |
10 | azure_cognitiveservices_contentmoderator | CONTENTMODERATOR_SUBSCRIPTION_KEY | Your Service Key |
CONTENTMODERATOR_TEAM_NAME | You can create and get the team name here |
You can set the environment variable as:
```
export {your key}={your value}
```
> [AZURE.NOTE] On Windows, use `set` instead of `export`.
Run the sample.
ruby run_samples.rb --sdk={sample_to_run}
To know the possible values of
sdk
, you can run the following command:ruby run_samples.rb --help
To see the code of each example, simply look at the examples in the Samples folder. They are written to be isolated in scope so that you can see only what you're interested in.