-
Notifications
You must be signed in to change notification settings - Fork 135
Tutorial Sets
Sets are essentially a collection of similar words that you can use within a <pattern>
tag to simplify the pattern matching capabilities. Instead of separate categories to capture every possible grammar allowing the user to state that they like a color, we can have a single grammar that makes use of a set of colours, as follows
<category>
<pattern> I LIKE THE COLOR <set name="colors"></pattern>
<template>
That is great, I like that color too.
</template>
</category>
The set above references a name attribute with a value 'colors'. This references a file stored in the directory that is referenced by the configuration option
brain:
sets:
files: $BOT_ROOT/sets
extension: .txt
directories: false
For more information on the settings, see the section Brain File Configuration
If you were to add this grammar to your bot and execute. You can then ask any question about like a color, as long as that colors name is contained within the set file colors.txt
Loading, please wait...
No bot root argument set, defaulting to [.]
Y-Bot version 0.0.1, initiated March 14, 2017
Hi, how can I help you today?
>>> I like the color red
That is great, I like that color too.
>>> I like the color green
That is great, I like that color too.
Lets create a new set for the types of cars.
-
Create a file and give it the name of the set you want to use. Don't worry about case, set name lookup is case insensitive, so cars.txt, CARS.txt and Cars.txt will all be considered the same set
-
Fill the set with names of all the cars you want in the set. Again don't worry about case, set contents lookup is case insensitive.
Saab
Ford
Vauxhall
Peugeot
Honda
Nissan
BMW
Mercedes
- Next, create a grammar that can make use of the set in the AIML folder of your bot.
<category>
<pattern> I DRIVE A <set name="cars"></pattern>
<template>
Hey, I have always wanted to drive one of them.
</template>
</category>
-
Reload the bot, and check the log file to make sure that the new grammar has been loaded without any issues.
-
You can now interact with your bot using the new grammar and set
Loading, please wait...
No bot root argument set, defaulting to [.]
Y-Bot version 0.0.1, initiated March 14, 2017
Hi, how can I help you today?
>>> I drive a Ford
Hey, I have always wanted to drive one of them.
>>> I drive a Saab
Hey, I have always wanted to drive one of them.
- Numeric
For more information about the template set tag, see the wiki page Sets
Email: [email protected] | Twitter: @keiffster | Facebook: keith.sterling | LinkedIn: keithsterling | My Blog
- Home
- Background
- Guiding Principles
- Reporting an Issue
- Installation
- You And Your Bot
- Bots
- Clients
- Configuration
- AIML
- Sentence Splitting
- Natural Langauge Processing
- Normalization
- Spelling
- Sentiment Analysis
- Translation
- Security
- Hot Reload
- Logging
- Out of Band
- Multi Language
- RDF Support
- Rich Media
- Asynchronous Events
- Triggers
- External Services
- Dynamic Sets, Maps & Vars
- Extensions
- Pre & Post Processors
- Custom Nodes
- The Brain Tree
- Utilities
- Building It Yourself
- Creating Your Own Bot
- Contributing
- Performance Testing
- FAQ
- History
- Website