Skip to content

Commit f3cfa73

Browse files
authored
Merge pull request #115180 from dksimpson/DKS-US1712683-bing-spell-check
Refresh Bing Spell Check REST API quickstarts
2 parents 1d7645d + dfdce04 commit f3cfa73

File tree

7 files changed

+125
-91
lines changed

7 files changed

+125
-91
lines changed

articles/cognitive-services/Bing-Spell-Check/quickstarts/csharp.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,34 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: bing-spell-check
1010
ms.topic: quickstart
11-
ms.date: 12/16/2019
11+
ms.date: 05/21/2020
1212
ms.author: aahi
1313
---
1414

1515
# Quickstart: Check spelling with the Bing Spell Check REST API and C#
1616

17-
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple C# application sends a request to the API and returns a list of suggested corrections. While this application is written in C#, the API is a RESTful Web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingAutosuggestv7.cs).
17+
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple C# application sends a request to the API and returns a list of suggested corrections.
18+
19+
Although this application is written in C#, the API is a RESTful Web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/dotnet/Search/BingAutosuggestv7.cs).
1820

1921
## Prerequisites
2022

2123
* Any edition of [Visual Studio 2017 or later](https://www.visualstudio.com/downloads/).
22-
* To install `Newtonsoft.Json` as a NuGet package in Visual studio:
23-
1. In **Solution Explorer**, right-click the Solution file.
24-
1. Select **Manage NuGet Packages for Solution**.
25-
1. Search for `Newtonsoft.Json` and install the package.
26-
* If you're using Linux/MacOS, this application can be run using [Mono](https://www.mono-project.com/).
24+
* The Newtonsoft.Json NuGet package.
25+
26+
To install this package in Visual studio:
27+
28+
1. In **Solution Explorer**, right-click the Solution file.
29+
1. Select **Manage NuGet Packages for Solution**.
30+
1. Search for *Newtonsoft.Json* and install the package.
31+
32+
* If you're using Linux/MacOS, you can run this application by using [Mono](https://www.mono-project.com/).
2733

2834
[!INCLUDE [cognitive-services-bing-spell-check-signup-requirements](../../../../includes/cognitive-services-bing-spell-check-signup-requirements.md)]
2935

3036
## Create and initialize a project
3137

32-
1. Create a new console solution named `SpellCheckSample` in Visual Studio. Then add the following namespaces into the main code file.
38+
1. Create a new console solution named SpellCheckSample in Visual Studio. Then, add the following namespaces into the main code file:
3339

3440
```csharp
3541
using System;
@@ -41,7 +47,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
4147
using Newtonsoft.Json;
4248
```
4349

44-
2. Create variables for the API endpoint, your subscription key, and the text to be spell checked. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
50+
2. Create variables for the API endpoint, your subscription key, and the text to be spell checked. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4551

4652
```csharp
4753
namespace SpellCheckSample
@@ -57,15 +63,19 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
5763
}
5864
```
5965

60-
3. Create a variable for your search parameters. Append your market code after `mkt=`. The market code is the country/region you make the request from. Also, append your spell-check mode after `&mode=`. Mode is either `proof` (catches most spelling/grammar errors) or `spell` (catches most spelling but not as many grammar errors).
66+
3. Create a string for your search parameters:
67+
68+
a. Assign your market code to the `mkt` parameter with the `=` operator. The market code is the code of the country/region you make the request from.
69+
70+
b. Add the `mode` parameter with the `&` operator, and then assign the spell-check mode. The mode can be either `proof` (catches most spelling/grammar errors) or `spell` (catches most spelling errors, but not as many grammar errors).
6171

6272
```csharp
6373
static string params_ = "mkt=en-US&mode=proof";
6474
```
6575

6676
## Create and send a spell check request
6777

68-
1. Create an asynchronous function called `SpellCheck()` to send a request to the API. Create a `HttpClient`, and add your subscription key to the `Ocp-Apim-Subscription-Key` header. Then perform the following steps within the function.
78+
1. Create an asynchronous function called `SpellCheck()` to send a request to the API. Create a `HttpClient`, and add your subscription key to the `Ocp-Apim-Subscription-Key` header. Within the function, follow the next steps.
6979

7080
```csharp
7181
async static void SpellCheck()
@@ -122,7 +132,7 @@ Console.WriteLine(jsonObj);
122132

123133
## Call the spell check function
124134

125-
In the Main function of your project, call `SpellCheck()`.
135+
In the `Main()` function of your project, call `SpellCheck()`.
126136

127137
```csharp
128138
static void Main(string[] args)
@@ -184,4 +194,4 @@ A successful response is returned in JSON, as shown in the following example:
184194
> [Create a single-page web app](../tutorials/spellcheck.md)
185195
186196
- [What is the Bing Spell Check API?](../overview.md)
187-
- [Bing Spell Check API v7 Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)
197+
- [Bing Spell Check API v7 reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)

articles/cognitive-services/Bing-Spell-Check/quickstarts/java.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-spell-check
1111
ms.topic: quickstart
12-
ms.date: 12/16/2019
12+
ms.date: 05/21/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Check spelling with the Bing Spell Check REST API and Java
1717

18-
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple Java application sends a request to the API and returns a list of suggested corrections. While this application is written in Java, the API is a RESTful web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingSpellCheck.java).
18+
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple Java application sends a request to the API and returns a list of suggested corrections.
19+
20+
Although this application is written in Java, the API is a RESTful web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/java/Search/BingSpellCheck.java).
1921

2022
## Prerequisites
2123

2224
* The Java Development Kit(JDK) 7 or later.
2325

24-
* Import the [gson-2.8.5.jar](https://libraries.io/maven/com.google.code.gson%3Agson) or the most current [Gson](https://github.com/google/gson) version. For command line execution, add the `.jar` to your Java folder with the main class.
26+
* Import the [gson-2.8.5.jar](https://libraries.io/maven/com.google.code.gson%3Agson) or the most current [Gson](https://github.com/google/gson) version. For command-line execution, add the `.jar` to your Java folder with the main class.
2527

2628
[!INCLUDE [cognitive-services-bing-spell-check-signup-requirements](../../../../includes/cognitive-services-bing-spell-check-signup-requirements.md)]
2729

2830
## Create and initialize an application
2931

30-
1. Create a new Java Project in your favorite IDE or editor with a class name of your choosing, and then import the following packages.
32+
1. Create a new Java Project in your favorite IDE or editor with a class name of your choosing, and then import the following packages:
3133

3234
```java
3335
import java.io.*;
@@ -36,7 +38,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
3638
import javax.net.ssl.HttpsURLConnection;
3739
```
3840

39-
2. Create variables for the API endpoint's host, path, and your subscription key. Then create variables for your market, the text you want to spell check, and a string for the spell check mode. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
41+
2. Create variables for the API endpoint's host, path, and your subscription key. Then, create variables for your market, the text you want to spell check, and a string for the spell check mode. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
4042
4143
```java
4244
static String host = "https://api.cognitive.microsoft.com";
@@ -51,7 +53,11 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
5153
5254
## Create and send an API request
5355
54-
1. Create a function called `check()` to create and send the API request. Within it, follow these steps. Create a string for the request parameters. append the `?mkt=` parameter to your market string, and the `&mode=` parameter to your spell check mode.
56+
1. Create a function called `check()` to create and send the API request. Within this function, add the code specified in the next steps. Create a string for the request parameters:
57+
58+
a. Assign your market code to the `mkt` parameter with the `=` operator.
59+
60+
b. Add the `mode` parameter with the `&` operator, and then assign the spell-check mode.
5561
5662
```java
5763
public static void check () throws Exception {
@@ -60,14 +66,14 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
6066
}
6167
```
6268
63-
2. Create a URL by combining the endpoint host, path and parameters string. Create a new `HttpsURLConnection` object.
69+
2. Create a URL by combining the endpoint host, path, and parameters string. Create a new `HttpsURLConnection` object.
6470
6571
```java
6672
URL url = new URL(host + path + params);
6773
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
6874
```
6975
70-
3. Open a connection to the URL. Set the request method to `POST`. Add your request parameters. Make sure to add your subscription key to the `Ocp-Apim-Subscription-Key` header.
76+
3. Open a connection to the URL. Set the request method to `POST` and add your request parameters. Be sure to add your subscription key to the `Ocp-Apim-Subscription-Key` header.
7177
7278
```java
7379
connection.setRequestMethod("POST");
@@ -76,7 +82,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
7682
connection.setDoOutput(true);
7783
```
7884
79-
4. Create a new `DataOutputStream` object and Send the request to the API.
85+
4. Create a new `DataOutputStream` object and send the request to the API.
8086
8187
```java
8288
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
@@ -87,7 +93,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
8793
8894
## Format and read the API response
8995
90-
1. Add this method to your class. It formats the JSON for a more readable output.
96+
1. Add the `prettify()` method to your class, which formats the JSON for a more readable output.
9197
9298
``` java
9399
// This function prettifies the json response.
@@ -113,7 +119,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
113119
114120
## Call the API
115121
116-
In the main function of your application, call your check() method created above.
122+
In the main function of your application, call your `check()` method created previously.
117123
```java
118124
public static void main(String[] args) {
119125
try {
@@ -127,19 +133,19 @@ In the main function of your application, call your check() method created above
127133
128134
## Run the application
129135
130-
Build and run your project.
136+
Build and run your project. If you're using the command line, use the following commands to build and run the application:
131137

132-
If you're using the command line, use the following commands to build and run the application.
138+
1. Build the application:
133139

134-
**Build:**
135-
```bash
136-
javac -classpath .;gson-2.2.2.jar\* <CLASS_NAME>.java
137-
```
140+
```bash
141+
javac -classpath .;gson-2.2.2.jar\* <CLASS_NAME>.java
142+
```
138143

139-
**Run:**
140-
```bash
141-
java -cp .;gson-2.2.2.jar\* <CLASS_NAME>
142-
```
144+
2. Run the application:
145+
146+
```bash
147+
java -cp .;gson-2.2.2.jar\* <CLASS_NAME>
148+
```
143149

144150
## Example JSON response
145151

@@ -189,4 +195,4 @@ A successful response is returned in JSON, as shown in the following example:
189195
> [Create a single-page web app](../tutorials/spellcheck.md)
190196
191197
- [What is the Bing Spell Check API?](../overview.md)
192-
- [Bing Spell Check API v7 Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)
198+
- [Bing Spell Check API v7 reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)

articles/cognitive-services/Bing-Spell-Check/quickstarts/nodejs.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: bing-spell-check
1111
ms.topic: quickstart
12-
ms.date: 12/16/2019
12+
ms.date: 05/21/2020
1313
ms.author: aahi
1414
---
1515

1616
# Quickstart: Check spelling with the Bing Spell Check REST API and Node.js
1717

18-
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple Node application sends a request to the API and returns a list of words it didn't recognize, followed by suggested corrections. While this application is written in Node.js, the API is a RESTful Web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingSpellCheckv7.js).
18+
Use this quickstart to make your first call to the Bing Spell Check REST API. This simple JavaScript application sends a request to the API and returns a list of suggested corrections.
19+
20+
Although this application is written in JavaScript, the API is a RESTful Web service compatible with most programming languages. The source code for this application is available on [GitHub](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingSpellCheckv7.js).
1921

2022
## Prerequisites
2123

@@ -26,7 +28,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
2628

2729
## Create and initialize a project
2830

29-
1. Create a new JavaScript file in your favorite IDE or editor. Set the strictness, and require `https`. Then create variables for your API endpoint's host, path, and your subscription key. You can use the global endpoint below, or the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
31+
1. Create a new JavaScript file in your favorite IDE or editor. Set the strictness, and require `https`. Then, create variables for your API endpoint's host, path, and your subscription key. You can use the global endpoint in the following code, or use the [custom subdomain](../../../cognitive-services/cognitive-services-custom-subdomains.md) endpoint displayed in the Azure portal for your resource.
3032

3133
```javascript
3234
'use strict';
@@ -37,7 +39,11 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
3739
let key = '<ENTER-KEY-HERE>';
3840
```
3941

40-
2. Create variables for your search parameters and the text you want to check. Append your market code after `mkt=`. The market code is the country/region you make the request from. Also, append your spell-check mode after `&mode=`. Mode is either `proof` (catches most spelling/grammar errors) or `spell` (catches most spelling but not as many grammar errors).
42+
2. Create variables for your search parameters and the text you want to check:
43+
44+
a. Assign your market code to the `mkt` parameter with the `=` operator. The market code is the code of the country/region you make the request from.
45+
46+
b. Add the `mode` parameter with the `&` operator, and then assign the spell-check mode. The mode can be either `proof` (catches most spelling/grammar errors) or `spell` (catches most spelling errors, but not as many grammar errors).
4147

4248
```javascript
4349
let mkt = "en-US";
@@ -48,7 +54,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
4854

4955
## Create the request parameters
5056

51-
Create your request parameters by creating a new object with a `POST` method. Add your path by appending your endpoint path, and query string. Add your subscription key to the `Ocp-Apim-Subscription-Key` header.
57+
Create your request parameters by creating a new object with a `POST` method. Add your path by appending your endpoint path, and query string. Then, add your subscription key to the `Ocp-Apim-Subscription-Key` header.
5258

5359
```javascript
5460
let request_params = {
@@ -65,7 +71,7 @@ let request_params = {
6571

6672
## Create a response handler
6773

68-
Create a function called `response_handler` to take the JSON response from the API, and print it. Create a variable for the response body. Append the response when a `data` flag is received, using `response.on()`. When a `end` flag is received, print the JSON body to the console.
74+
Create a function called `response_handler` to take the JSON response from the API, and print it. Create a variable for the response body. Append the response when a `data` flag is received by using `response.on()`. After an `end` flag is received, print the JSON body to the console.
6975

7076
```javascript
7177
let response_handler = function (response) {
@@ -85,7 +91,7 @@ let response_handler = function (response) {
8591

8692
## Send the request
8793

88-
Call the API using `https.request()` with your request parameters, and response handler. Write your text to the API, and end the request afterwards.
94+
Call the API using `https.request()` with your request parameters and response handler. Write your text to the API, and then end the request.
8995

9096
```javascript
9197
let req = https.request (request_params, response_handler);
@@ -96,13 +102,13 @@ req.end ();
96102

97103
## Run the application
98104

99-
Build and run your project.
105+
1. Build and run your project.
100106

101-
If you're using the command line, use the following commands to build and run the application.
107+
1. If you're using the command line, use the following command to build and run the application:
102108

103-
```bash
104-
node <FILE_NAME>.js
105-
```
109+
```bash
110+
node <FILE_NAME>.js
111+
```
106112

107113

108114
## Example JSON response
@@ -150,7 +156,7 @@ A successful response is returned in JSON, as shown in the following example:
150156
## Next steps
151157

152158
> [!div class="nextstepaction"]
153-
> [Create a single page web-app](../tutorials/spellcheck.md)
159+
> [Create a single-page web app](../tutorials/spellcheck.md)
154160
155161
- [What is the Bing Spell Check API?](../overview.md)
156-
- [Bing Spell Check API v7 Reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)
162+
- [Bing Spell Check API v7 reference](https://docs.microsoft.com/rest/api/cognitiveservices-bingsearch/bing-spell-check-api-v7-reference)

0 commit comments

Comments
 (0)