5. pattern element¶
5.1. bot¶
[1.0]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | String | Yes | Specifies the bot property name. |
- Use Case
The following use case returns the name of the bot. (Assuming properties.txt is set to ‘name: Bot’)
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Are you <bot name="name" />? </pattern>
<template>My name is <bot name="name" />. </template>
</category>
</aiml>
See also: File Management:properties
5.2. iset¶
[1.0]
The iset element is used to describe a small number of target words without using a sets file.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
words | String | Yes | Enter the words to be matched by separating them with commas. |
- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>I live in <iset words="Tokyo, Kanagawa, Chiba, Gunma, Saitama, Tochigi" />. </pattern>
<template>
I live in Kanto, too.
</template>
</category>
</aiml>
See also: set
5.3. nlu¶
[custom]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
intent | String | Yes | Specifies the intent name to match. |
scoreGt | String | No | Specifies the confidence level to match. Matches if the confidence of the target intent is greater than the specified value. |
scoreGe | String | No | Specifies the confidence level to match. Matches if the subject intent’s confidence is greater than or equal to the specified value. |
score | String | No | Specifies the confidence level to match. Matches the confidence of the target intent to the specified value. |
scoreLe | String | No | Specifies the confidence level to match. Matches if the subject intent’s confidence is less than or equal to the specified value. |
scoreLt | String | No | Specifies the confidence level to match. Matches if the confidence of the target intent is less than the specified value. |
maxLikelihood | String | No | Specifies true or false . Specifies whether the confidence of the subject must be the maximum likelihood. If true , the target intent will match only at maximum likelihood. If false , matches even if the subject intent is not one of a maximum likelihood. If not specified, it is true . |
- Use Case
Example of around search intent name set to ‘aroundsearch’ in intent recognition model.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>
<nlu intent="aroundsearch" />
</pattern>
<template>
Around search.
</template>
</category>
</aiml>
See also: NLU
5.4. oneormore¶
[1.0]
This element is a wildcard that matches at least one arbitrary word. If the wildcard is at the end of the description in the pattern element, it matches up to the end of the user’s utterance. Also, if the wildcard is between other AIML pattern matching elements in the pattern element description, match processing continues until the next pattern matching element in the wildcard is matched.
set
, iset
, regex
, and bot
.The following two use cases evaluate the match of 1 word “Hello” with one or more words that follow.
- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Hello _</pattern>
<template>
Hello
</template>
</category>
</aiml>
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Hello *</pattern>
<template>
How are you?
</template>
</category>
</aiml>
See also: zeroormore , Pattern Matching
5.5. priority¶
[1.0]
wildcard
, set
, iset
, regex
, bot
and so on.- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Hello $fantastic day, today. </pattern>
<template>
That's right.
</template>
</category>
<category>
<pattern>Hello * </pattern>
<template>
Hello.
</template>
</category>
<category>
<pattern>Hello * friend.</pattern>
<template>
Hi.
</template>
</category>
</aiml>
See also: word, Pattern Matching
5.6. regex¶
[custom]
The use of regex elements allows pattern matching by regular expressions to user utterances. It supports word-by-word regular expressions and regular expressions for strings.
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
pattern | String | No | Describing Words with Regular Expressions |
template | String | No | Uses word-by-word regular expressions defined in the regex.txt file |
form | String | No | Write regular expressions for strings containing multiple words |
When describing a regex element, one of the following attributes is required: pattern, template, or form.
- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>I did not <regex pattern="reali[z|s]e" />it was that.</pattern>
<template>
Did you realize it was that?
</template>
</category>
</aiml>
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern><regex template="color" /></pattern>
<template>
color
</template>
</category>
</aiml>
Notation | Meaning |
---|---|
‘[…]’ | Matches any character in ‘[…]’. |
‘A|B’ | Matches either of the left or right strings of ‘|’. |
‘(X)’ | A subpattern of the regular expression X. It is OK if it matches X. |
‘()?’ | Matches or does not match the subpattern just before ‘?’. |
The following example matches any of the following statements.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>
<regex form="I like analy[z|s]ing (football|soccer) matches " />
</pattern>
<template>
That's nice.
</template>
</category>
</aiml>
“I like analyzing football matches” “I like analysing football matches” “I like analyzing soccer matches” “I like analysing soccer matches”
See also: File Management:regex_templates
5.7. set¶
[1.0]
- Attribute
Parameter | Type | Required | Description |
---|---|---|---|
name | String | Yes | Character string excluding the extension from the sets file name |
- Use Case
The example below assumes that prefecture.txt contains the names of prefectures in Japan.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>I live in <set name = "preference" />. </pattern>
<template>
I live in Tokyo.
</template>
</category>
</aiml>
See also: iset , File Management:sets
5.8. topic¶
[1.0]
Using the topic element, you can add a condition that the value of the system reserved variable topic matches the value specified for name. “topic” can specify a value using the set of template elements as follows.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern><!-- pattern description goes here --></pattern>
<template>
<think><set name="topic">FISHING</set></think>
<!-- response sentence goes here-->
</template>
</category>
</aiml>
The condition specified in the topic element is evaluated before pattern matching. For example, you can vary the response statement by subdividing the pattern matching process into conditional branches based on the currently set topic value.
In the example below, for the user utterance “Why do you know that?”, the response sentence changes depending on whether the value of topic is set to “FISHING” or “COOKING” in the previous dialog.
- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Why do you know that? </pattern>
<topic>FISHING</topic>
<template>
My father taught me when I was a child.
</template>
</category>
<category>
<pattern>Why do you know that? </pattern>
<topic>COOKING</topic>
<template>
My mother taught me when I was a child.
</template>
</category>
</aiml>
See also: that, set(template element), think
5.9. that¶
[1.0]
By using the that element, you can add to the condition that the response of the system in the previous dialog matches the specified character string. If the pattern element and that element are contained within the category element, the match process of the pattern element is done only if the last response in the previous response of the system matched the specified character string by the that element. This function of the that element makes possible to write dialog rules considering the flow of dialog contents. For example, A system response sentence to a general user utterance sentence such as “Yes” or “No” can be classified according to the content of the previous dialog.
- Use Case
In the example of specification below, depending on whether the system response sentence of the previous conversation was “Would you like sugar and milk in your coffee?” or “Would you like some lemon slices with your tea?”, the dialog rules that match the “Yes” and “No” of user utterances are classified so that system response sentences that match the contents of the previous dialog are returned.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>I like coffee.</pattern>
<template>Would you like sugar and milk in your coffee?</template>
</category>
<category>
<pattern>I like tea.</pattern>
<template>Would you like some lemon slices with your tea?</template>
</category>
<category>
<pattern>Yes.</pattern>
<that>Would you like sugar and milk in your coffee?</that>
<template>Okay.</template>
</category>
<category>
<pattern>No.</pattern>
<that>Would you like sugar and milk in your coffee?</that>
<template>I like black coffee.</template>
</category>
<category>
<pattern>Yes.</pattern>
<that>Would you like some lemon slices with your tea?</that>
<template>Okay. </template>
</category>
<category>
<pattern>No. </pattern>
<that>Would you like some lemon slices with your tea ?</that>
<template>I like black tea.</template>
</category>
</aiml>
関連項目: topic
5.10. word¶
[1.0]
AIML’s the most basic pattern matching element. The word element represents a word and is used inside the dialog engine and cannot be described in a scenario. For English words, match processing is not case-sensitive. For double-byte and single-byte characters, matches are performed in single-byte for alphanumeric characters and in double-byte for kana characters.
In the example below, matches any of HELLO, hello, Hello, or HeLlO.
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>HELLO</pattern>
<template>
Hello
</template>
</category>
</aiml>
See also: priority
5.11. zeroormore¶
[1.0]
This element is a wildcard that matches at least zero arbitrary words. If the wildcard is at the end in the pattern element, it matches up to the end of the user’s utterance. Also, if the wildcard is between other AIML pattern matching elements in the pattern element description, match processing continues until the next pattern matching element.
set
, iset
, regex
and bot
, but the wildcard “#” is matched after these AIML pattern matching elements.In the example below, the grammar will match any sentence that is either ‘HELLO’ or a sentence that starts with ‘HELLO’ and one or more additional words.
For more information, see Pattern Matching.
- Use Case
<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">
<category>
<pattern>Hello ^ </pattern>
<template>
Hello
</template>
</category>
<category>
<pattern>Hello #</pattern>
<template>
How are you?
</template>
</category>
</aiml>
See also: oneormore , Pattern Matching