You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Spell-Check/quickstarts/csharp.md
+23-13Lines changed: 23 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,28 +8,34 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: bing-spell-check
10
10
ms.topic: quickstart
11
-
ms.date: 12/16/2019
11
+
ms.date: 05/21/2020
12
12
ms.author: aahi
13
13
---
14
14
15
15
# Quickstart: Check spelling with the Bing Spell Check REST API and C#
16
16
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).
18
20
19
21
## Prerequisites
20
22
21
23
* 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/).
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:
33
39
34
40
```csharp
35
41
usingSystem;
@@ -41,7 +47,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
41
47
usingNewtonsoft.Json;
42
48
```
43
49
44
-
2. Createvariablesfor 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) endpointdisplayedintheAzureportalfor your resource.
50
+
2. Createvariablesfor 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) endpointdisplayedintheAzureportalfor your resource.
45
51
46
52
```csharp
47
53
namespace SpellCheckSample
@@ -57,15 +63,19 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
57
63
}
58
64
```
59
65
60
-
3. Createavariablefor 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/grammarerrors) or `spell` (catchesmostspellingbutnotasmanygrammarerrors).
66
+
3. Createastringfor 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/grammarerrors) or `spell` (catchesmostspellingerrors, butnotasmanygrammarerrors).
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Spell-Check/quickstarts/java.md
+28-22Lines changed: 28 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,25 +9,27 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-spell-check
11
11
ms.topic: quickstart
12
-
ms.date: 12/16/2019
12
+
ms.date: 05/21/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Check spelling with the Bing Spell Check REST API and Java
17
17
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).
19
21
20
22
## Prerequisites
21
23
22
24
* The Java Development Kit(JDK) 7 or later.
23
25
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 commandline 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.
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:
31
33
32
34
```java
33
35
importjava.io.*;
@@ -36,7 +38,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
36
38
importjavax.net.ssl.HttpsURLConnection;
37
39
```
38
40
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.
@@ -51,7 +53,11 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
51
53
52
54
## Create and send an API request
53
55
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.
55
61
56
62
```java
57
63
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
60
66
}
61
67
```
62
68
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.
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.
71
77
72
78
```java
73
79
connection.setRequestMethod("POST");
@@ -76,7 +82,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
76
82
connection.setDoOutput(true);
77
83
```
78
84
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.
80
86
81
87
```java
82
88
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
87
93
88
94
## Format and read the API response
89
95
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.
91
97
92
98
``` java
93
99
// 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
113
119
114
120
## Call the API
115
121
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.
117
123
```java
118
124
public static void main(String[] args) {
119
125
try {
@@ -127,19 +133,19 @@ In the main function of your application, call your check() method created above
127
133
128
134
## Run the application
129
135
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:
131
137
132
-
If you're using the command line, use the following commands to build and run the application.
Copy file name to clipboardExpand all lines: articles/cognitive-services/Bing-Spell-Check/quickstarts/nodejs.md
+20-14Lines changed: 20 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,15 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: bing-spell-check
11
11
ms.topic: quickstart
12
-
ms.date: 12/16/2019
12
+
ms.date: 05/21/2020
13
13
ms.author: aahi
14
14
---
15
15
16
16
# Quickstart: Check spelling with the Bing Spell Check REST API and Node.js
17
17
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).
19
21
20
22
## Prerequisites
21
23
@@ -26,7 +28,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
26
28
27
29
## Create and initialize a project
28
30
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.
30
32
31
33
```javascript
32
34
'use strict';
@@ -37,7 +39,11 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
37
39
let key ='<ENTER-KEY-HERE>';
38
40
```
39
41
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).
41
47
42
48
```javascript
43
49
let mkt = "en-US";
@@ -48,7 +54,7 @@ Use this quickstart to make your first call to the Bing Spell Check REST API. Th
48
54
49
55
## Create the request parameters
50
56
51
-
Create your request parameters by creating a newobjectwith 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 newobjectwith 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.
52
58
53
59
```javascript
54
60
let request_params = {
@@ -65,7 +71,7 @@ let request_params = {
65
71
66
72
## Create a response handler
67
73
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.
69
75
70
76
```javascript
71
77
let response_handler = function (response) {
@@ -85,7 +91,7 @@ let response_handler = function (response) {
85
91
86
92
## Send the request
87
93
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.
89
95
90
96
```javascript
91
97
let req =https.request (request_params, response_handler);
@@ -96,13 +102,13 @@ req.end ();
96
102
97
103
## Run the application
98
104
99
-
Build and run your project.
105
+
1.Build and run your project.
100
106
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:
102
108
103
-
```bash
104
-
node <FILE_NAME>.js
105
-
```
109
+
```bash
110
+
node <FILE_NAME>.js
111
+
```
106
112
107
113
108
114
## Example JSON response
@@ -150,7 +156,7 @@ A successful response is returned in JSON, as shown in the following example:
150
156
## Next steps
151
157
152
158
> [!div class="nextstepaction"]
153
-
> [Create a singlepage web-app](../tutorials/spellcheck.md)
159
+
> [Create a single-page webapp](../tutorials/spellcheck.md)
154
160
155
161
-[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