Search code examples
xmlartificial-intelligenceaiml

How do I get the <topic> tag to work with this question in AIML?


For a project I have the same question asked but requires different answers due to the context. The code below does not work and I am having issues understanding why. I think it is referring to my other question because is has the same pattern, however I thought that the tag would look at the two patterns below first.

<category>
    <pattern>WHAT IS *</pattern>
    <template>
        <think>
            <set name = "topic">
                state<star />
            </set>
        </think>
        <condition name = "topic" value = "beauty">A subjective judgment evoked by an emotional response</condition>
        <condition name = "topic" value = "Bristol">Bristol is a city.</condition>
        <condition name = "topic" value = "London">London is a city.</condition>
        <condition name = "topic" value = "UWE">I do not have an answer for that</condition>
    </template>
</category>
<topic name = "state">
    <category>
        <pattern># WHERE IS IT #</pattern>
        <that>Bristol is a city.</that>
        <template>In the South-West of England</template>
    </category>
    <category>
        <pattern># WHERE IS IT #</pattern>
        <that>London is a city.</that>
        <template>Somewhere east of Bristol</template>
    </category>
</topic>

Solution

  • Remove the full stops. No punctuation should be used in <that> tags. You don't need to use topics for this.

    <that>Bristol is a city</that>
    

    You can actually do this a lot cleaner without using the topic tag like this:

    <category>
        <pattern>WHAT IS *</pattern>
        <template>
            <think><set name="it"><star/></set></think>
            <condition name="it">
                <li value="beauty">A subjective judgment evoked by an emotional response.</li>
                <li value="Bristol">Bristol is a city.</li>
                <li value="London">London is a city.</li>
                <li value="UWE">I do not have an answer for that</li>
                <li>I have no idea.</li>
            </condition>
        </template>
    </category>
    
    <category>
        <pattern># WHERE IS IT #</pattern>
        <template>
            <condition name="it">
                <li value="beauty">In someone attractive.</li>
                <li value="Bristol">In the South-West of England.</li>
                <li value="London">Somewhere east of Bristol.</li>
                <li value="UWE">I do not have an answer for that</li>
                <li>Where is what?</li>
            </condition>
        </template>
    </category>