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/LUIS/luis-concept-patterns.md
+5-117Lines changed: 5 additions & 117 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.custom: seodec18
9
9
ms.service: cognitive-services
10
10
ms.subservice: language-understanding
11
11
ms.topic: conceptual
12
-
ms.date: 10/15/2019
12
+
ms.date: 11/11/2019
13
13
ms.author: diberry
14
14
---
15
15
# Patterns improve prediction accuracy
@@ -52,128 +52,16 @@ Given enough example utterances, LUIS would be able to increase prediction confi
52
52
## Pattern matching
53
53
A pattern is matched based on detecting the entities inside the pattern first, then validating the rest of the words and word order of the pattern. Entities are required in the pattern for a pattern to match. The pattern is applied at the token level, not the character level.
54
54
55
-
## Pattern syntax
56
-
Pattern syntax is a template for an utterance. The template should contain words and entities you want to match as well as words and punctuation you want to ignore. It is **not** a regular expression.
57
-
58
-
Entities in patterns are surrounded by curly brackets, `{}`. Patterns can include entities, and entities with roles. [Pattern.any](luis-concept-entity-types.md#patternany-entity) is an entity only used in patterns.
59
-
60
-
Pattern syntax supports the following syntax:
61
-
62
-
|Function|Syntax|Nesting level|Example|
63
-
|--|--|--|--|
64
-
|entity| {} - curly brackets|2|Where is form {entity-name}?|
65
-
|optional|[] - square brackets<BR><BR>There is a limit of 3 on nesting levels of any combination of optional and grouping |2|The question mark is optional [?]|
66
-
|grouping|() - parentheses|2|is (a \| b)|
67
-
|or|\| - vertical bar (pipe)<br><br>There is a limit of 2 on the vertical bars (Or) in one group |-|Where is form ({form-name-short} | {form-name-long} | {form-number})|
68
-
|beginning and/or end of utterance|^ - caret|-|^begin the utterance<br>the utterance is done^<br>^strict literal match of entire utterance with {number} entity^|
69
-
70
-
## Nesting syntax in patterns
71
-
72
-
The **optional** syntax, with square brackets, can be nested two levels. For example: `[[this]is] a new form`. This example allows for the following utterances:
73
-
74
-
|Nested optional utterance example|Explanation|
75
-
|--|--|
76
-
|this is a new form|matches all words in pattern|
77
-
|is a new form|matches outer optional word and non-optional words in pattern|
78
-
|a new form|matches required words only|
79
-
80
-
The **grouping** syntax, with parentheses, can be nested two levels. For example: `(({Entity1.RoleName1} | {Entity1.RoleName2} ) | {Entity2} )`. This feature allows any of the three entities to be matched.
81
-
82
-
If Entity1 is a Location with roles such as origin (Seattle) and destination (Cairo) and Entity 2 is a known building name from a list entity (RedWest-C), the following utterances would map to this pattern:
83
-
84
-
|Nested grouping utterance example|Explanation|
85
-
|--|--|
86
-
|RedWest-C|matches outer grouping entity|
87
-
|Seattle|matches one of the inner grouping entities|
88
-
|Cairo|matches one of the inner grouping entities|
89
-
90
-
## Nesting limits for groups with optional syntax
91
-
92
-
A combination of **grouping** with **optional** syntax has a limit of 3 nesting levels.
To add an entity into the pattern template, surround the entity name with curly braces, such as `Who does {Employee} manage?`.
110
-
111
-
|Pattern with entity|
112
-
|--|
113
-
|`Who does {Employee} manage?`|
114
-
115
-
## Syntax to add an entity and role to a pattern template
116
-
An entity role is denoted as `{entity:role}` with the entity name followed by a colon, then the role name. To add an entity with a role into the pattern template, surround the entity name and role name with curly braces, such as `Book a ticket from {Location:Origin} to {Location:Destination}`.
117
-
118
-
|Pattern with entity roles|
119
-
|--|
120
-
|`Book a ticket from {Location:Origin} to {Location:Destination}`|
121
-
122
-
## Syntax to add a pattern.any to pattern template
123
-
The Pattern.any entity allows you to add an entity of varying length to the pattern. As long as the pattern template is followed, the pattern.any can be any length.
124
-
125
-
To add a **Pattern.any** entity into the pattern template, surround the Pattern.any entity with the curly braces, such as `How much does {Booktitle} cost and what format is it available in?`.
126
-
127
-
|Pattern with Pattern.any entity|
128
-
|--|
129
-
|`How much does {Booktitle} cost and what format is it available in?`|
130
-
131
-
|Book titles in the pattern|
132
-
|--|
133
-
|How much does **steal this book** cost and what format is it available in?|
134
-
|How much does **ask** cost and what format is it available in?|
135
-
|How much does **The Curious Incident of the Dog in the Night-Time** cost and what format is it available in?|
136
-
137
-
The words of the book title are not confusing to LUIS because LUIS knows where the book title ends, based on the Pattern.any entity.
138
-
139
-
## Explicit lists
140
-
141
-
create an [Explicit List](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5ade550bd5b81c209ce2e5a8) through the authoring API to allow the exception when:
142
-
143
-
* Your pattern contains a [Pattern.any](luis-concept-entity-types.md#patternany-entity)
144
-
* And that pattern syntax allows for the possibility of an incorrect entity extraction based on the utterance.
145
-
146
-
For example, suppose you have a pattern containing both optional syntax, `[]`, and entity syntax, `{}`, combined in a way to extract data incorrectly.
147
-
148
-
Consider the pattern `[find] email about {subject} [from {person}]'.
149
-
150
-
In the following utterances, the **subject** and **person** entity are extracted correctly and incorrectly:
151
-
152
-
|Utterance|Entity|Correct extraction|
153
-
|--|--|:--:|
154
-
|email about dogs from Chris|subject=dogs<br>person=Chris|✔|
155
-
|email about the man from La Mancha|subject=the man<br>person=La Mancha|X|
156
-
157
-
In the preceding table, the subject should be `the man from La Mancha` (a book title) but because the subject includes the optional word `from`, the title is incorrectly predicted.
158
-
159
-
To fix this exception to the pattern, add `the man from la mancha` as an explicit list match for the {subject} entity using the [authoring API for explicit list](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5ade550bd5b81c209ce2e5a8).
160
-
161
-
## Syntax to mark optional text in a template utterance
162
-
Mark optional text in the utterance using the regular expression square bracket syntax, `[]`. The optional text can nest square brackets up to two brackets only.
163
-
164
-
|Pattern with optional text|Meaning|
165
-
|--|--|
166
-
|`[find] email about {subject} [from {person}]`|`find` and `from {person}` are optional|
167
-
|`Can you help me[?]|The punctuation mark is optional|
168
-
169
-
Punctuation marks (`?`, `!`, `.`) should be ignored and you need to ignore them using the square bracket syntax in patterns.
170
-
171
55
## Pattern-only apps
172
56
You can build an app with intents that have no example utterances, as long as there's a pattern for each intent. For a pattern-only app, the pattern shouldn't contain machine-learned entities because these do require example utterances.
Copy file name to clipboardExpand all lines: articles/cognitive-services/LUIS/luis-how-to-add-entities.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.custom: seodec18
9
9
ms.service: cognitive-services
10
10
ms.subservice: language-understanding
11
11
ms.topic: conceptual
12
-
ms.date: 10/25/2019
12
+
ms.date: 11/11/2019
13
13
ms.author: diberry
14
14
---
15
15
@@ -103,7 +103,7 @@ In the utterance `Where is Request relocation from employee new to the company o
103
103
104
104
To use the pattern.any entity, add a pattern on the **Patterns** page, in the **Improve app performance** section, with the correct curly brace syntax, such as `Where is **{HumanResourcesFormTitle}** on the server?`.
105
105
106
-
If you find that your pattern, when it includes a Pattern.any, extracts entities incorrectly, use an [explicit list](luis-concept-patterns.md#explicit-lists) to correct this problem.
106
+
If you find that your pattern, when it includes a Pattern.any, extracts entities incorrectly, use an [explicit list](reference-pattern-syntax.md#explicit-lists) to correct this problem.
Copy file name to clipboardExpand all lines: articles/cognitive-services/LUIS/luis-quickstart-intent-and-list-entity.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.custom: seodec18
9
9
ms.service: cognitive-services
10
10
ms.subservice: language-understanding
11
11
ms.topic: tutorial
12
-
ms.date: 10/14/2019
12
+
ms.date: 11/11/2019
13
13
ms.author: diberry
14
14
#Customer intent: As a new user, I want to understand how and why to use the list entity.
15
15
---
@@ -45,7 +45,7 @@ A list entity is a good choice for this type of data when:
45
45
46
46
* The data values are a known set.
47
47
* The set doesn't exceed the maximum LUIS [boundaries](luis-boundaries.md) for this entity type.
48
-
* The text in the utterance is an exact match with a synonym or the canonical name. LUIS doesn't use the list beyond exact text matches. Stemming, plurals, and other variations are not resolved with just a list entity. To manage variations, consider using a [pattern](luis-concept-patterns.md#syntax-to-mark-optional-text-in-a-template-utterance) with the optional text syntax.
48
+
* The text in the utterance is an exact match with a synonym or the canonical name. LUIS doesn't use the list beyond exact text matches. Stemming, plurals, and other variations are not resolved with just a list entity. To manage variations, consider using a [pattern](reference-pattern-syntax.md#syntax-to-mark-optional-text-in-a-template-utterance) with the optional text syntax.
Copy file name to clipboardExpand all lines: articles/cognitive-services/LUIS/luis-tutorial-pattern-any.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ manager: nitinme
9
9
ms.service: cognitive-services
10
10
ms.subservice: language-understanding
11
11
ms.topic: tutorial
12
-
ms.date: 10/14/2019
12
+
ms.date: 11/11/2019
13
13
ms.author: diberry
14
14
#Customer intent: As a new user, I want to understand how and why to use pattern.any entity to improve predictions.
15
15
---
@@ -134,7 +134,7 @@ The Pattern.any entity extracts entities of varying length. It only works in a p
134
134
135
135
## Using an explicit list
136
136
137
-
If you find that your pattern, when it includes a Pattern.any, extracts entities incorrectly, use an [explicit list](luis-concept-patterns.md#explicit-lists) to correct this problem.
137
+
If you find that your pattern, when it includes a Pattern.any, extracts entities incorrectly, use an [explicit list](reference-pattern-syntax.md#explicit-lists) to correct this problem.
Copy file name to clipboardExpand all lines: articles/cognitive-services/LUIS/reference-entity-list.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ manager: nitinme
8
8
ms.service: cognitive-services
9
9
ms.subservice: language-understanding
10
10
ms.topic: reference
11
-
ms.date: 09/29/2019
11
+
ms.date: 11/11/2019
12
12
ms.author: diberry
13
13
---
14
14
# List entity
@@ -22,7 +22,7 @@ A list entity isn't machine-learned. It is an exact text match. LUIS marks any m
22
22
* Are a known set.
23
23
* Doesn't change often. If you need to change the list often or want the list to self-expand, a simple entity boosted with a phrase list is a better choice.
24
24
* The set doesn't exceed the maximum LUIS [boundaries](luis-boundaries.md) for this entity type.
25
-
* The text in the utterance is an exact match with a synonym or the canonical name. LUIS doesn't use the list beyond exact text matches. Fuzzy matching, case-insensitivity, stemming, plurals, and other variations are not resolved with a list entity. To manage variations, consider using a [pattern](luis-concept-patterns.md#syntax-to-mark-optional-text-in-a-template-utterance) with the optional text syntax.
25
+
* The text in the utterance is an exact match with a synonym or the canonical name. LUIS doesn't use the list beyond exact text matches. Fuzzy matching, case-insensitivity, stemming, plurals, and other variations are not resolved with a list entity. To manage variations, consider using a [pattern](reference-pattern-syntax.md#syntax-to-mark-optional-text-in-a-template-utterance) with the optional text syntax.
description: Create entities to extract key data from user utterances in Language Understanding (LUIS) apps. Extracted data is used by the client application.
5
+
services: cognitive-services
6
+
author: diberry
7
+
manager: nitinme
8
+
ms.service: cognitive-services
9
+
ms.subservice: language-understanding
10
+
ms.topic: reference
11
+
ms.date: 11/11/2019
12
+
ms.author: diberry
13
+
---
14
+
15
+
# Pattern syntax
16
+
17
+
Pattern syntax is a template for an utterance. The template should contain words and entities you want to match as well as words and punctuation you want to ignore. It is **not** a regular expression.
18
+
19
+
Entities in patterns are surrounded by curly brackets, `{}`. Patterns can include entities, and entities with roles. [Pattern.any](luis-concept-entity-types.md#patternany-entity) is an entity only used in patterns.
20
+
21
+
Pattern syntax supports the following syntax:
22
+
23
+
|Function|Syntax|Nesting level|Example|
24
+
|--|--|--|--|
25
+
|entity| {} - curly brackets|2|Where is form {entity-name}?|
26
+
|optional|[] - square brackets<BR><BR>There is a limit of 3 on nesting levels of any combination of optional and grouping |2|The question mark is optional [?]|
27
+
|grouping|() - parentheses|2|is (a \| b)|
28
+
|or|\| - vertical bar (pipe)<br><br>There is a limit of 2 on the vertical bars (Or) in one group |-|Where is form ({form-name-short} | {form-name-long} | {form-number})|
29
+
|beginning and/or end of utterance|^ - caret|-|^begin the utterance<br>the utterance is done^<br>^strict literal match of entire utterance with {number} entity^|
30
+
31
+
## Nesting syntax in patterns
32
+
33
+
The **optional** syntax, with square brackets, can be nested two levels. For example: `[[this]is] a new form`. This example allows for the following utterances:
34
+
35
+
|Nested optional utterance example|Explanation|
36
+
|--|--|
37
+
|this is a new form|matches all words in pattern|
38
+
|is a new form|matches outer optional word and non-optional words in pattern|
39
+
|a new form|matches required words only|
40
+
41
+
The **grouping** syntax, with parentheses, can be nested two levels. For example: `(({Entity1.RoleName1} | {Entity1.RoleName2} ) | {Entity2} )`. This feature allows any of the three entities to be matched.
42
+
43
+
If Entity1 is a Location with roles such as origin (Seattle) and destination (Cairo) and Entity 2 is a known building name from a list entity (RedWest-C), the following utterances would map to this pattern:
44
+
45
+
|Nested grouping utterance example|Explanation|
46
+
|--|--|
47
+
|RedWest-C|matches outer grouping entity|
48
+
|Seattle|matches one of the inner grouping entities|
49
+
|Cairo|matches one of the inner grouping entities|
50
+
51
+
## Nesting limits for groups with optional syntax
52
+
53
+
A combination of **grouping** with **optional** syntax has a limit of 3 nesting levels.
To add an entity into the pattern template, surround the entity name with curly braces, such as `Who does {Employee} manage?`.
71
+
72
+
|Pattern with entity|
73
+
|--|
74
+
|`Who does {Employee} manage?`|
75
+
76
+
## Syntax to add an entity and role to a pattern template
77
+
An entity role is denoted as `{entity:role}` with the entity name followed by a colon, then the role name. To add an entity with a role into the pattern template, surround the entity name and role name with curly braces, such as `Book a ticket from {Location:Origin} to {Location:Destination}`.
78
+
79
+
|Pattern with entity roles|
80
+
|--|
81
+
|`Book a ticket from {Location:Origin} to {Location:Destination}`|
82
+
83
+
## Syntax to add a pattern.any to pattern template
84
+
The Pattern.any entity allows you to add an entity of varying length to the pattern. As long as the pattern template is followed, the pattern.any can be any length.
85
+
86
+
To add a **Pattern.any** entity into the pattern template, surround the Pattern.any entity with the curly braces, such as `How much does {Booktitle} cost and what format is it available in?`.
87
+
88
+
|Pattern with Pattern.any entity|
89
+
|--|
90
+
|`How much does {Booktitle} cost and what format is it available in?`|
91
+
92
+
|Book titles in the pattern|
93
+
|--|
94
+
|How much does **steal this book** cost and what format is it available in?|
95
+
|How much does **ask** cost and what format is it available in?|
96
+
|How much does **The Curious Incident of the Dog in the Night-Time** cost and what format is it available in?|
97
+
98
+
The words of the book title are not confusing to LUIS because LUIS knows where the book title ends, based on the Pattern.any entity.
99
+
100
+
## Explicit lists
101
+
102
+
create an [Explicit List](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5ade550bd5b81c209ce2e5a8) through the authoring API to allow the exception when:
103
+
104
+
* Your pattern contains a [Pattern.any](luis-concept-entity-types.md#patternany-entity)
105
+
* And that pattern syntax allows for the possibility of an incorrect entity extraction based on the utterance.
106
+
107
+
For example, suppose you have a pattern containing both optional syntax, `[]`, and entity syntax, `{}`, combined in a way to extract data incorrectly.
108
+
109
+
Consider the pattern `[find] email about {subject} [from {person}]'.
110
+
111
+
In the following utterances, the **subject** and **person** entity are extracted correctly and incorrectly:
112
+
113
+
|Utterance|Entity|Correct extraction|
114
+
|--|--|:--:|
115
+
|email about dogs from Chris|subject=dogs<br>person=Chris|✔|
116
+
|email about the man from La Mancha|subject=the man<br>person=La Mancha|X|
117
+
118
+
In the preceding table, the subject should be `the man from La Mancha` (a book title) but because the subject includes the optional word `from`, the title is incorrectly predicted.
119
+
120
+
To fix this exception to the pattern, add `the man from la mancha` as an explicit list match for the {subject} entity using the [authoring API for explicit list](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5ade550bd5b81c209ce2e5a8).
121
+
122
+
## Syntax to mark optional text in a template utterance
123
+
Mark optional text in the utterance using the regular expression square bracket syntax, `[]`. The optional text can nest square brackets up to two brackets only.
124
+
125
+
|Pattern with optional text|Meaning|
126
+
|--|--|
127
+
|`[find] email about {subject} [from {person}]`|`find` and `from {person}` are optional|
128
+
|`Can you help me[?]|The punctuation mark is optional|
129
+
130
+
Punctuation marks (`?`, `!`, `.`) should be ignored and you need to ignore them using the square bracket syntax in patterns.
131
+
132
+
## Next steps
133
+
134
+
Understand how [sentiment](luis-reference-prebuilt-sentiment.md) is returned in the .json response.
0 commit comments