Skip to content

Tutorial Symbolic Reduction

Keith Sterling edited this page Oct 2, 2017 · 9 revisions

Symbolic Reduction

A symbolic reduction is about reducing multiple different grammars down to a single one. This allows you to capture multiple ways in which to ask a single question, but then to have it all funnelled into a single grammar that does the work. This greatly reduces complexity and duplication of effort when working with large grammars

Imagine all the different ways you can say hello to someone, but the answer is always going to be the same ( Later on we'll see how we can create multiple responses to the same question, but let's keep it simple for now )

<?xml version="1.0" encoding="UTF-8"?>
<aiml version="2.0">

    <category>
        <pattern>HELLO</pattern>
        <template>
            <srai>HELLO_RESPONSE</srai>
       </template>
    <category>

    <category>
        <pattern>HI</pattern>
        <template>
            <srai>HELLO_RESPONSE</srai>
       </template>
    <category>

    <category>
        <pattern>GOOD MORNING</pattern>
        <template>
            <srai>HELLO_RESPONSE</srai>
       </template>
    <category>

    <category>
        <pattern>HELLO_RESPONSE</pattern>
        <template>
            <srai>Hi there!</srai>
       </template>
    <category>

</aiml>

If we now run the bot with this new grammar, we can see we can ask it various versions of hello and get the same response back

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?
>>> Hello
Hi there!
>>> Hi
Hi there!
>>> Good morning
Hi there!
>>> 

For more details about this tag see srai tag

SR Shorthand


Back to Tutorial | Back - Regular Expressions | Next - Random Selection

Clone this wiki locally