2

The following AIML code is used for keyword detection but it can only detect one key word as it is here the FAMILY keyword How can I use such pattern for detecting two keywords in a sentence for example a sentence with FAMILY and FATHER keyword both included?

<category>
  <pattern> FAMILY </pattern>
  <template>
  Family is an important institution.
  </template>
 </category>

<category>
  <pattern> _ FAMILY </pattern>
  <template>
  <srai> FAMILY </srai>
  </template>
 </category>

 <category>
  <pattern> FAMILY * </pattern>
  <template>
  <srai> FAMILY </srai>
  </template>
 </category>

 <category>
  <pattern> _ FAMILY * </pattern>
  <template>
  <srai> FAMILY </srai>
  </template>
 </category>
Freelancer
  • 836
  • 1
  • 14
  • 47

3 Answers3

2

You may simply use multiple keywords and their order like this:

    <category>
      <pattern>* FATHER * FAMILY *</pattern>
      <template>
      Family is an important institution.
      </template>
     </category>

   <category>
      <pattern>* FAMILY * FATHER *</pattern>
      <template><srai>* FATHER * FAMILY *</srai> 
      </template>
     </category>

This will match all patterns e.g.

  1. Father Family

  2. SomeText Father SomeText Family

  3. Father sometext Family someText

  4. etc
1

Why not simply :

  <pattern> FAMILY * FATHER <pattern>
AlexisBRENON
  • 2,921
  • 2
  • 18
  • 30
  • This will not match a sentence like `I like the father of this family.` – Freelancer Jan 06 '15 at 05:23
  • 1
    @AliNfr As I know, you cannot define only one pattern to match 2 words in any position. For two words, you have to define two patterns FAMILY * FATHER ... FATHER * FAMILY ... – AlexisBRENON Jan 06 '15 at 09:30
0

You may simply use:

<category>
  <pattern>* FAMILY *</pattern>
  <template>
  Family is an important institution.
  </template>
 </category>

It would work in following cases:

  1. FAMILY
  2. some text and FAMILY
  3. FAMILY and some text
  4. some text FAMILY some text