Skip to content

Commit

Permalink
Update sample code in readme files for the Cognitive Services auto ge…
Browse files Browse the repository at this point in the history
…nerated packages to use JavaScript (#10301)

* Change TS Samples to JS Samples

* Updated Minor Versions in Package JSON Files

* Addressing PR Comments
  • Loading branch information
sarangan12 authored Jul 27, 2020
1 parent 5153500 commit 9291f8e
Show file tree
Hide file tree
Showing 59 changed files with 155 additions and 194 deletions.
10 changes: 5 additions & 5 deletions sdk/cognitiveservices/cognitiveservices-autosuggest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample gets suggestions from Bing for the given query **Microsoft Azure**. To know more, refer to the [Azure Documentation on Bing Auto Suggest](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-autosuggest/)

```typescript
import { AutoSuggestClient, AutoSuggestModels } from "@azure/cognitiveservices-autosuggest";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
```javascript
const { AutoSuggestClient } = require("@azure/cognitiveservices-autosuggest");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main(): Promise<void> {
async function main() {
const autoSuggestKey = process.env["autoSuggestKey"] || "<autoSuggestKey>";
const cognitiveServiceCredentials = new CognitiveServicesCredentials(autoSuggestKey);
const client = new AutoSuggestClient(cognitiveServiceCredentials);

const query = "Microsoft Azure";
const options: AutoSuggestModels.AutoSuggestClientAutoSuggestOptionalParams = {
const options = {
acceptLanguage: "en-US",
pragma: "no-cache",
clientId: "testclientId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-autosuggest",
"author": "Microsoft Corporation",
"description": "AutoSuggestClient Library with typescript type definitions for node.js and browser.",
"version": "2.0.0",
"version": "2.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";

const packageName = "@azure/cognitiveservices-autosuggest";
const packageVersion = "2.0.0";
const packageVersion = "2.0.1";

export class AutoSuggestClientContext extends msRest.ServiceClient {
endpoint?: string;
Expand Down
15 changes: 6 additions & 9 deletions sdk/cognitiveservices/cognitiveservices-computervision/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample describes a given image using Computer Vision. To know more, refer to the [Azure Documentation on Computer Vision](https://docs.microsoft.com/en-us/azure/cognitive-services/computer-vision/home)

```typescript
import {
ComputerVisionClient,
ComputerVisionModels
} from "@azure/cognitiveservices-computervision";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";

async function main(): Promise<void> {
```javascript
const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const computerVisionKey = process.env["computerVisionKey"] || "<computerVisionKey>";
const computerVisionEndPoint =
process.env["computerVisionEndPoint"] || "<computerVisionEndPoint>";
Expand All @@ -42,7 +39,7 @@ async function main(): Promise<void> {

const url =
"https://docs.microsoft.com/en-us/azure/includes/media/shared-image-galleries/shared-image-gallery.png";
const options: ComputerVisionModels.ComputerVisionClientDescribeImageOptionalParams = {
const options = {
maxCandidates: 5,
language: "en"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-computervision",
"author": "Microsoft Corporation",
"description": "ComputerVisionClient Library with typescript type definitions for node.js and browser.",
"version": "7.0.0",
"version": "7.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as msRest from "@azure/ms-rest-js";

const packageName = "@azure/cognitiveservices-computervision";
const packageVersion = "7.0.0";
const packageVersion = "7.0.1";

export class ComputerVisionClientContext extends msRest.ServiceClient {
endpoint: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample detects the langauge of text provided using text moderator APIs. To know more, refer to the [Azure Documentation on Content Moderator](https://docs.microsoft.com/en-us/azure/cognitive-services/content-moderator/overview)

```typescript
import { ContentModeratorClient } from "@azure/cognitiveservices-contentmoderator";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
```javascript
const { ContentModeratorClient } = require("@azure/cognitiveservices-contentmoderator");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main(): Promise<void> {
async function main() {
const contentModeratorKey = process.env["contentModeratorKey"] || "<contentModeratorKey>";
const contentModeratorEndPoint =
process.env["contentModeratorEndPoint"] || "<contentModeratorEndPoint>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-contentmoderator",
"author": "Microsoft Corporation",
"description": "ContentModeratorClient Library with typescript type definitions for node.js and browser.",
"version": "5.0.0",
"version": "5.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as msRest from "@azure/ms-rest-js";

const packageName = "@azure/cognitiveservices-contentmoderator";
const packageVersion = "5.0.0";
const packageVersion = "5.0.1";

export class ContentModeratorClientContext extends msRest.ServiceClient {
endpoint: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample performs an image search for given query on a custom configuration. The custom configuration can be setup using the Custom search portal. To know more, refer to the [Azure Documentation on Bing Custom Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-custom-search/)

```typescript
import {
CustomImageSearchClient,
CustomImageSearchModels
} from "@azure/cognitiveservices-customimagesearch";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";

async function main(): Promise<void> {
```javascript
const { CustomImageSearchClient } = require("@azure/cognitiveservices-customimagesearch");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const customImageSearchKey =
process.env["customImageSearchKey"] || "<customImageSearchKey>";
const customImageSearchEndPoint =
Expand All @@ -47,7 +44,7 @@ async function main(): Promise<void> {
endpoint: customImageSearchEndPoint
});
const query = "Olympics";
const options: CustomImageSearchModels.CustomInstanceImageSearchOptionalParams = {
const options = {
count: 10,
safeSearch: "Moderate"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-customimagesearch",
"author": "Microsoft Corporation",
"description": "CustomImageSearchClient Library with typescript type definitions for node.js and browser.",
"version": "2.0.0",
"version": "2.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";

const packageName = "@azure/cognitiveservices-customimagesearch";
const packageVersion = "2.0.0";
const packageVersion = "2.0.1";

export class CustomImageSearchClientContext extends msRest.ServiceClient {
endpoint?: string;
Expand Down
15 changes: 6 additions & 9 deletions sdk/cognitiveservices/cognitiveservices-customsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample performs a search for given query on a custom configuration. The custom configuration can be setup using the Custom search portal. To know more, refer to the [Azure Documentation Bing Custom Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-custom-search/)

```typescript
import {
CustomSearchClient,
CustomSearchModels
} from "@azure/cognitiveservices-customsearch";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";

async function main(): Promise<void> {
```javascript
const { CustomSearchClient } = require("@azure/cognitiveservices-customsearch");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const customSearchKey = process.env["customSearchKey"] || "<customSearchKey>";
const customSearchEndPoint =
process.env["customSearchEndPoint"] || "<customSearchEndPoint>";
Expand All @@ -45,7 +42,7 @@ async function main(): Promise<void> {
endpoint: customSearchEndPoint
});
const query = "World Peace";
const options: CustomSearchModels.CustomInstanceSearchOptionalParams = {
const options = {
count: 10,
safeSearch: "Moderate"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-customsearch",
"author": "Microsoft Corporation",
"description": "CustomSearchClient Library with typescript type definitions for node.js and browser.",
"version": "3.0.0",
"version": "3.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";

const packageName = "@azure/cognitiveservices-customsearch";
const packageVersion = "3.0.0";
const packageVersion = "3.0.1";

export class CustomSearchClientContext extends msRest.ServiceClient {
endpoint?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ npm install @azure/cognitiveservices-customvision-prediction
##### Sample code
The following sample predicts and classifies the given image based on your custom vision training. To know more, refer to the [Azure Documentation on Custom Vision Services](https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/home).

```typescript
import { PredictionAPIClient } from "@azure/cognitiveservices-customvision-prediction";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
```javascript
const { PredictionAPIClient } = require("@azure/cognitiveservices-customvision-prediction");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main(): Promise<void> {
async function main() {
const customVisionPredictionKey =
process.env["customVisionPredictionKey"] || "<customVisionPredictionKey>";
const customVisionPredictionEndPoint =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-customvision-prediction",
"author": "Microsoft Corporation",
"description": "PredictionAPIClient Library with typescript type definitions for node.js and browser.",
"version": "5.1.0",
"version": "5.1.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as msRest from "@azure/ms-rest-js";

const packageName = "@azure/cognitiveservices-customvision-prediction";
const packageVersion = "5.1.0";
const packageVersion = "5.1.1";

export class PredictionAPIClientContext extends msRest.ServiceClient {
endpoint: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ npm install @azure/cognitiveservices-customvision-training
##### Sample code
The following sample performs a quick test of the given image based on your custom vision training. To know more, refer to the [Azure Documentation on Custom Vision Services](https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/home).

```typescript
import {
TrainingAPIClient,
TrainingAPIModels
} from "@azure/cognitiveservices-customvision-training";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";

async function main(): Promise<void> {
```javascript
const { TrainingAPIClient } = require("@azure/cognitiveservices-customvision-training");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const customVisionTrainingKey =
process.env["customVisionTrainingKey"] || "<customVisionTrainingKey>";
const customVisionTrainingEndPoint =
Expand All @@ -42,7 +39,7 @@ async function main(): Promise<void> {
const imageURL =
"https://www.atlantatrails.com/wp-content/uploads/2019/02/north-georgia-waterfalls-1024x683.jpg";

const options: TrainingAPIModels.TrainingAPIClientQuickTestImageUrlOptionalParams = {
const options = {
iterationId: iterationId
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-customvision-training",
"author": "Microsoft Corporation",
"description": "TrainingAPIClient Library with typescript type definitions for node.js and browser.",
"version": "5.1.0",
"version": "5.1.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as msRest from "@azure/ms-rest-js";

const packageName = "@azure/cognitiveservices-customvision-training";
const packageVersion = "5.1.0";
const packageVersion = "5.1.1";

export class TrainingAPIClientContext extends msRest.ServiceClient {
endpoint: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample performs a Bing entity search on the query 'Microsoft Azure'. To know more, refer to the [Azure Documentation on Bing Entities Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-entities-search/).

```typescript
import { EntitySearchClient } from "@azure/cognitiveservices-entitysearch";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
```javascript
const { EntitySearchClient } = require("@azure/cognitiveservices-entitysearch");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main(): Promise<void> {
async function main() {
const entitySearchKey = process.env["entitySearchKey"] || "<entitySearchKey>";
const entitySearchEndPoint =
process.env["entitySearchEndPoint"] || "<entitySearchEndPoint>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-entitysearch",
"author": "Microsoft Corporation",
"description": "EntitySearchClient Library with typescript type definitions for node.js and browser.",
"version": "3.0.0",
"version": "3.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as msRest from "@azure/ms-rest-js";
import * as Models from "./models";

const packageName = "@azure/cognitiveservices-entitysearch";
const packageVersion = "3.0.0";
const packageVersion = "3.0.1";

export class EntitySearchClientContext extends msRest.ServiceClient {
endpoint?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample reads the scanned copy of a sample receipt. To know more, refer to the [Azure Documentation on Form Recognizer](https://docs.microsoft.com/en-us/azure/cognitive-services/form-recognizer/overview)

```typescript
import { FormRecognizerClient } from "@azure/cognitiveservices-formrecognizer";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";
```javascript
const { FormRecognizerClient } = require("@azure/cognitiveservices-formrecognizer");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main(): Promise<void> {
async function main() {
const formRecognizerKey = process.env["formRecognizerKey"] || "<formRecognizerKey>";
const endPoint = process.env["endPoint"] || "<endPoint>";
const cognitiveServiceCredentials = new CognitiveServicesCredentials(formRecognizerKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@azure/cognitiveservices-formrecognizer",
"author": "Microsoft Corporation",
"description": "FormRecognizerClient Library with typescript type definitions for node.js and browser.",
"version": "2.0.0",
"version": "2.0.1",
"dependencies": {
"@azure/ms-rest-js": "^2.0.4",
"tslib": "^1.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import * as msRest from "@azure/ms-rest-js";

const packageName = "@azure/cognitiveservices-formrecognizer";
const packageVersion = "2.0.0";
const packageVersion = "2.0.1";

export class FormRecognizerClientContext extends msRest.ServiceClient {
endpoint: string;
Expand Down
15 changes: 6 additions & 9 deletions sdk/cognitiveservices/cognitiveservices-imagesearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ npm install @azure/ms-rest-azure-js
##### Sample code
The following sample performs an image search for 'Microsoft Azure' with conditions such as the color has to be 'Monochrome', etc. To know more, refer to the [Azure Documentation on Bing Image Search](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-image-search/)

```typescript
import {
ImageSearchClient,
ImageSearchModels
} from "@azure/cognitiveservices-imagesearch";
import { CognitiveServicesCredentials } from "@azure/ms-rest-azure-js";

async function main(): Promise<void> {
```javascript
const { ImageSearchClient } = require("@azure/cognitiveservices-imagesearch");
const { CognitiveServicesCredentials } = require("@azure/ms-rest-azure-js");

async function main() {
const imageSearchKey = process.env["imageSearchKey"] || "<imageSearchKey>";
const imageSearchEndPoint =
process.env["imageSearchEndPoint"] || "<imageSearchEndPoint>";
Expand All @@ -45,7 +42,7 @@ async function main(): Promise<void> {
});

const query = "Microsoft Azure";
const options: ImageSearchModels.ImagesSearchOptionalParams = {
const options = {
color: "Monochrome",
count: 10,
imageType: "Photo",
Expand Down
Loading

0 comments on commit 9291f8e

Please sign in to comment.