Skip to content

Commit 94784de

Browse files
authored
Merge pull request #96657 from erhopf/luis-hackadoc-rest-py
[CogSvcs - LUIS Hackadoc] Review of Python REST Quickstart
2 parents 3a8cb66 + 733d587 commit 94784de

6 files changed

+50
-47
lines changed

articles/cognitive-services/LUIS/includes/get-key-quickstart.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/17/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212

13-
Access to the keys and endpoints is provided in the LUIS portal in the Manage Section on the Azure Resources page.
13+
Keys and endpoints are provided in the LUIS portal in the **Manage Section** on the **Azure Resources** page.
1414

15-
1. Sign in to the LUIS portal.
16-
1. Select your app from the apps list.
15+
1. Sign in to the [LUIS portal](https://preview.luis.ai/).
16+
1. Create a new app, or select an existing app from the apps list.
1717
1. Select **Manage** then select **Azure Resources**.
18-
1. Copy the values for the key and endpoint for the Starter resource.
19-
20-
The **Starter** key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.
18+
1. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.
19+
> [!NOTE]
20+
> The **Starter** key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-csharp.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,38 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/17/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212

1313
## Prerequisites
1414

1515
* [.NET Core V2.2+](https://dotnet.microsoft.com/download)
1616
* [Visual Studio Code](https://code.visualstudio.com/)
17-
* Public app ID: df67dcdb-c37d-46af-88e1-8b97951ca1c2
17+
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1818

1919
## Get LUIS key
2020

2121
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
2222

2323
## Get intent programmatically
2424

25-
Use C# to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-prediction) to get the prediction result.
25+
Use C# (.NET Core) to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2626

2727
1. Create a new console application targeting the C# language, with a project and folder name of `predict-with-rest`.
2828

2929
```console
3030
dotnet new console -lang C# -n predict-with-rest
3131
```
3232

33-
1. Install required dependencies with the following dotnet CLI commands.
33+
1. Change to the `predict-with-rest` directory you just created, and install required dependencies with these commands:
3434

3535
```console
36+
cd predict-with-rest
3637
dotnet add package System.Net.Http
3738
```
38-
1. Overwrite Program.cs with the following code:
39+
40+
1. Open `Program.cs` in your favorite IDE or editor. Then overwrite `Program.cs` with the following code:
3941
4042
```csharp
4143
using System;
@@ -97,10 +99,10 @@ Use C# to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-pr
9799

98100
1. Replace the following values:
99101

100-
* `YOUR-KEY` with your starter key
101-
* `YOUR-ENDPOINT` with your endpoint, for example, `westus2.api.cognitive.microsoft.com`
102+
* `YOUR-KEY` with your starter key.
103+
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
102104

103-
1. Build the console application.
105+
1. Build the console application with this command:
104106

105107
```console
106108
dotnet build
@@ -112,7 +114,7 @@ Use C# to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-pr
112114
dotnet run
113115
```
114116

115-
1. Review prediction response in JSON format:
117+
1. Review the prediction response, which is returned as JSON:
116118

117119
```console
118120
Hit ENTER to exit...

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-go.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/17/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
12+
1213
## Prerequisites
1314

1415
* [Go](https://golang.org/) programming language
1516
* [Visual Studio Code](https://code.visualstudio.com/)
16-
* Public app ID: df67dcdb-c37d-46af-88e1-8b97951ca1c2
17+
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1718

1819
## Get LUIS key
1920

2021
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
2122

2223
## Get intent programmatically
2324

24-
Use Go to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-prediction) to get the prediction result.
25+
Use Go to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2526

2627
1. Create a new file named `predict.go`. Add the following code:
2728

@@ -79,8 +80,8 @@ Use Go to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-pr
7980

8081
1. Replace the following values:
8182

82-
* `YOUR-KEY` with your starter key
83-
* `YOUR-ENDPOINT` with your endpoint, for example, `westus2.api.cognitive.microsoft.com`
83+
* `YOUR-KEY` with your starter key.
84+
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
8485

8586
1. With a command prompt in the same directory as where you created the file, enter the following command to compile the Go file:
8687

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-java.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/17/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212
## Prerequisites
1313

1414
* [JDK SE](https://aka.ms/azure-jdks) (Java Development Kit, Standard Edition)
1515
* [Visual Studio Code](https://code.visualstudio.com/) or your favorite IDE
16-
* Public app ID: df67dcdb-c37d-46af-88e1-8b97951ca1c2
16+
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1717

1818
## Get LUIS key
1919

2020
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
2121

2222
## Get intent programmatically
2323

24-
Use Java to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-prediction) to get the prediction result.
24+
Use Java to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2525

2626
1. Make a subdirectory named `lib` and copy in the following java libs:
2727

@@ -31,7 +31,6 @@ Use Java to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-
3131

3232
1. Copy the following code to create a class in a file named `Predict.java`:
3333

34-
3534
```java
3635
import java.io.*;
3736
import java.net.URI;
@@ -102,10 +101,10 @@ Use Java to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-
102101
1. Replace the following values:
103102

104103
* `YOUR-KEY` with your starter key
105-
* `YOUR-ENDPOINT` with your endpoint, for example, `westus2.api.cognitive.microsoft.com`
104+
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
106105

107106

108-
1. Compile the java program from a command line:
107+
1. Compile the java program from the command line:
109108

110109
```console
111110
javac -cp ":lib/*" Predict.java
@@ -117,7 +116,7 @@ Use Java to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-
117116
java -cp ":lib/*" Predict
118117
```
119118

120-
1. Review prediction response in JSON format:
119+
1. Review the prediction response, which is returned as JSON:
121120

122121
```console
123122
{'query': 'turn on all lights', 'prediction': {'topIntent': 'HomeAutomation.TurnOn', 'intents': {'HomeAutomation.TurnOn': {'score': 0.5375382}, 'None': {'score': 0.08687421}, 'HomeAutomation.TurnOff': {'score': 0.0207554}}, 'entities': {'HomeAutomation.Operation': ['on'], '$instance': {'HomeAutomation.Operation': [{'type': 'HomeAutomation.Operation', 'text': 'on', 'startIndex': 5, 'length': 2, 'score': 0.724984169, 'modelTypeId': -1, 'modelType': 'Unknown', 'recognitionSources': ['model']}]}}}}

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-nodejs.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/18/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212

1313
## Prerequisites
1414

1515
* [Node.js](https://nodejs.org/) programming language
1616
* [Visual Studio Code](https://code.visualstudio.com/)
17-
* Public app ID: df67dcdb-c37d-46af-88e1-8b97951ca1c2
17+
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1818

1919
## Get LUIS key
2020

2121
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
2222

2323
## Get intent programmatically
2424

25-
Use Node.js to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-prediction) to get the prediction result.
25+
Use Node.js to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2626

2727
1. Copy the following code snippet to a file named `predict.js`:
2828

@@ -71,24 +71,24 @@ Use Node.js to query the prediction endpoint GET [API](https://aka.ms/luis-apim-
7171
getPrediction().then(()=>console.log("done")).catch((err)=>console.log(err));
7272
```
7373

74-
1. Set the following values:
74+
1. Replace the following values:
7575

76-
* `YOUR-KEY` to your starter key
77-
* `YOUR-ENDPOINT` to your endpoint URL
76+
* `YOUR-KEY` to your starter key.
77+
* `YOUR-ENDPOINT` to your endpoint URL. For example, `westus2.api.cognitive.microsoft.com`.
7878

79-
1. Install dependencies by running the following command at the command-line:
79+
1. Install the `request`, `request-promise`, and `querystring` dependencies with this command:
8080

8181
```console
8282
npm install request request-promise querystring
8383
```
8484

85-
1. Run the code with the following command:
85+
1. Run your app with this command:
8686

8787
```console
8888
node predict.js
8989
```
9090

91-
1. Review prediction response in JSON format:
91+
1. Review the prediction response, which is returned as JSON:
9292

9393
```console
9494
{"query":"turn on all lights","prediction":{"topIntent":"HomeAutomation.TurnOn","intents":{"HomeAutomation.TurnOn":{"score":0.5375382},"None":{"score":0.08687421},"HomeAutomation.TurnOff":{"score":0.0207554}},"entities":{"HomeAutomation.Operation":["on"],"$instance":{"HomeAutomation.Operation":[{"type":"HomeAutomation.Operation","text":"on","startIndex":5,"length":2,"score":0.724984169,"modelTypeId":-1,"modelType":"Unknown","recognitionSources":["model"]}]}}}}

articles/cognitive-services/LUIS/includes/get-started-get-intent-rest-python.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@ author: diberry
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 10/18/2019
9+
ms.date: 11/20/2019
1010
ms.author: diberry
1111
---
1212

1313
## Prerequisites
1414

1515
* [Python 3.6](https://www.python.org/downloads/) or later.
1616
* [Visual Studio Code](https://code.visualstudio.com/)
17+
* Public app ID: `df67dcdb-c37d-46af-88e1-8b97951ca1c2`
1718

1819
## Get LUIS key
1920

2021
[!INCLUDE [Use authoring key for endpoint](../includes/get-key-quickstart.md)]
2122

22-
## Get intent programmatically
23+
## Get intent from the prediction endpoint
2324

24-
Use Python to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v3-prediction) to get the prediction result.
25+
Use Python to query the [prediction endpoint](https://aka.ms/luis-apim-v3-prediction) and get a prediction result.
2526

26-
1. Copy one of the following code snippets to a file called `predict.py`:
27+
1. Copy this code snippet into a file called `predict.py`:
2728

2829
```python
2930
########### Python 3.6 #############
@@ -58,28 +59,28 @@ Use Python to query the prediction endpoint GET [API](https://aka.ms/luis-apim-v
5859

5960
1. Replace the following values:
6061

61-
* `YOUR-KEY` with your starter key
62-
* `YOUR-ENDPOINT` with your endpoint, for example, `westus2.api.cognitive.microsoft.com`
62+
* `YOUR-KEY` with your starter key.
63+
* `YOUR-ENDPOINT` with your endpoint. For example, `westus2.api.cognitive.microsoft.com`.
6364

64-
1. Install dependencies with the following console command:
65+
1. Install the `requests` dependency. This is used to make HTTP requests:
6566

6667
```console
6768
pip install requests
6869
```
6970

70-
1. Run the script with the following console command:
71+
1. Run your script with this console command:
7172

7273
```console
7374
python predict.py
7475
```
7576

76-
1. Review prediction response in JSON format:
77+
1. Review the prediction response, which is returned as JSON:
7778

7879
```console
7980
{'query': 'turn on all lights', 'prediction': {'topIntent': 'HomeAutomation.TurnOn', 'intents': {'HomeAutomation.TurnOn': {'score': 0.5375382}, 'None': {'score': 0.08687421}, 'HomeAutomation.TurnOff': {'score': 0.0207554}}, 'entities': {'HomeAutomation.Operation': ['on'], '$instance': {'HomeAutomation.Operation': [{'type': 'HomeAutomation.Operation', 'text': 'on', 'startIndex': 5, 'length': 2, 'score': 0.724984169, 'modelTypeId': -1, 'modelType': 'Unknown', 'recognitionSources': ['model']}]}}}}
8081
```
8182

82-
The JSON response formatted for readability:
83+
Here's the JSON response formatted for readability:
8384

8485
```JSON
8586
{

0 commit comments

Comments
 (0)