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
title: Quickstart learning how to add utterances to a LUIS app using Go | Microsoft Docs
3
-
description: In this quickstart, you learn to call a LUIS app using Go.
4
-
services: cognitive-services
2
+
title: Quickstart change model and train LUIS app using Go - Azure Cognitive Services | Microsoft Docs
3
+
description: In this Go quickstart, add example utterances to a Home Automation app and train the app. Example utterances are conversational user text mapped to an intent. By providing example utterances for intents, you teach LUIS what kinds of user-supplied text belongs to which intent.
5
4
titleSuffix: Microsoft Cognitive Services
6
5
author: diberry
7
6
manager: cjgronlund
8
7
ms.service: cognitive-services
9
8
ms.component: language-understanding
10
9
ms.topic: quickstart
11
-
ms.date: 07/17/2018
10
+
ms.date: 08/24/2018
12
11
ms.author: diberry
13
-
#Customer intent: As a developer new to LUIS, I want to add an utterance to the LUIS app model using Go.
12
+
#Customer intent: As an API or REST developer new to the LUIS service, I want to programmatically add an example utterance to an intent and train the model using Go.
14
13
---
15
14
16
-
# Quickstart: Add utterances to a LUIS app using Go
17
-
In this quickstart, write a program to add an utterance to an intent in an app, train the app, and get training status using the Authoring APIs with Go.
15
+
# Quickstart: Change model using Go
18
16
19
-
<!-- green checkmark -->
20
-
<!--
21
-
> [!div class="checklist"]
22
-
> * Create Visual Studio console project
23
-
> * Add method to call LUIS API to add utterance and train app
24
-
> * Add JSON file with example utterances for BookFlight intent
25
-
> * Run console and see training status for utterances
26
-
-->
17
+
[!include[Quickstart introduction for endpoint](../../../includes/cognitive-services-luis-qs-endpoint-intro-para.md)]
27
18
28
-
For more information, see the technical documentation for the [add example utterance to intent](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c08), [train](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c45), and [training status](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c46) APIs.
19
+
## Prerequisites
29
20
30
-
For this article, you need a free [LUIS](luis-reference-regions.md#luis-website) account in order to author your LUIS application.
21
+
[!include[Quickstart introduction for endpoint](../../../includes/cognitive-services-luis-qs-change-model-prereq.md)]
22
+
*[Go](https://golang.org/) programming language installed.
23
+
*[VSCode](https://code.visualstudio.com)
31
24
32
-
## Prerequisites
25
+
[!include[Quickstart introduction for endpoint](../../../includes/cognitive-services-luis-qs-change-model-luis-repo-note.md)]
26
+
27
+
## Example utterances JSON file
28
+
29
+
[!include[Quickstart introduction for endpoint](../../../includes/cognitive-services-luis-qs-change-model-json-ex-utt.md)]
30
+
31
+
## Create quickstart code
32
+
33
+
1. Create `add-utterances.go` with VSCode.
34
+
35
+
2. Add dependencies.
33
36
34
-
*[Go](https://golang.org/) installed.
35
-
* Your LUIS **[authoring key](luis-concept-keys.md#authoring-key)**. You can find this key under Account Settings in the [LUIS](luis-reference-regions.md) website.
36
-
* Import [TravelAgent - Sample 1
37
-
](https://github.com/Microsoft/LUIS-Samples/blob/master/documentation-samples/Examples-BookFlight/travel-agent-sample-01.json) app from Github repository. Get the new app ID from **Settings** page in LUIS website.
38
-
* The **version ID** within the application that receives the utterances. The default ID is `0.1`.
39
-
* Create a new file named `add-utterances.go` project in VSCode.
> The complete Go solution including an example `utterances.json` file are available from the [**LUIS-Samples** Github repository](https://github.com/Microsoft/LUIS-Samples/blob/master/documentation-samples/authoring-api-samples/go).
39
+
3. Add generic HTTP request function, which includes passing authoring key in header.
43
40
44
-
## Add utterances and train using the Authoring API with Go
45
-
You can add example utterances to an existing intent and train the app with Go. Create a new file named `add-utterances.go`. Add the following code:
41
+
[!code-go[Add HTTP request function which includes passing authoring key in header. ](~/samples-luis/documentation-samples/quickstarts/change-model/go/add-utterances.go?range=12-36"Add HTTP request function, which includes passing authoring key in header. ")]
46
42
47
-
[!code-go[Go code that adds utterance and trains app](~/samples-luis/documentation-samples/authoring-api-samples/go/add-utterances.go?range=35-136)]
43
+
4. Add example utterances from JSON file.
48
44
49
-
## Specify utterances to add
50
-
Create and edit the file `utterances.json` to specify the **array of utterances** you want to add to the LUIS app. The intent and entities **must** already be in the LUIS app.
45
+
[!code-go[Add example utterances from JSON file.](~/samples-luis/documentation-samples/quickstarts/change-model/go/add-utterances.go?range=62-76"Add example utterances from JSON file.")]
51
46
52
-
> [!NOTE]
53
-
> The LUIS `TravelAgent - Sample 1` application with the intents and entities used in the `utterances.json` file must exist prior to running the code in `add-utterances.go`. The code in this article does not create the intents and entities. It only adds the utterances for existing intents and entities.
47
+
5. Request training. Uses a helper function to set the VERB for the same route as training status.
54
48
55
-
The `text` field contains the text of the utterance. The `intentName` field must correspond to the name of an intent in the LUIS app. The `entityLabels` field is required. If you don't want to label any entities, provide an empty list as shown in the following example:
If the entityLabels list is not empty, the `startCharIndex` and `endCharIndex` need to mark the entity referred to in the `entityName` field. Both indexes are zero-based counts meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S.
51
+
6. Request training status. Uses a helper function to set the VERB for the same route as request training.
58
52
59
-
```JSON
60
-
[
61
-
{
62
-
"text": "go lang 1",
63
-
"intentName": "None",
64
-
"entityLabels": []
65
-
}
66
-
,
67
-
{
68
-
"text": "go lang 2",
69
-
"intentName": "None",
70
-
"entityLabels": []
71
-
}
72
-
]
73
-
```
53
+
[!code-go[Request training status. ](~/samples-luis/documentation-samples/quickstarts/change-model/go/add-utterances.go?range=87-90"Request training status. ")]
54
+
55
+
7. Add main function to handle command-line parsing.
56
+
57
+
[!code-go[Add main function to handle command line parsing. ](~/samples-luis/documentation-samples/quickstarts/change-model/go/add-utterances.go?range=38-60"Add main function to handle command-line parsing.")]
74
58
75
59
## Add an utterance from the command line, train, and get status
76
-
Run the Go code from a command prompt to add an utterance, train the app, and get the training status.
77
60
78
61
1. From a command prompt in the directory where you created the Go file, enter `go build add-utterances.go` to compile the Go file. The command prompt does not return any information for a successful build.
79
62
80
-
3. Run the Go application from the command line by entering the following in the command prompt:
63
+
2. Run the Go application from the command line by entering the following text in the command prompt:
@@ -103,22 +86,100 @@ Run the Go code from a command prompt to add an utterance, train the app, and ge
103
86
"entityLabels": []
104
87
}
105
88
]
106
-
201
107
-
[{"value":{"ExampleId":77783998,"UtteranceText":"go lang 1"},"hasError":false},{"value":{"ExampleId":77783999,"UtteranceText":"go lang 2"},"hasError":false}]
0 commit comments