AIML Parser PHP

557 views Asked by At

I am trying to develop Artificial Bot i found AIML is something that can be used for achieving such goal i found these points regarding AIML parsing which is done by Program-O

1.) All letters in the input are converted to UPPERCASE 2.) All punctuation is stripped out and replaced with spaces 3.) extra whitespace chatacters, including tabs, are removed

From there, Program O performs a search in the database, looking for all potential matches to the input, including wildcards. The returned results are then “scored” for relevancy and the “best match” is selected. Program O then processes the AIML from the selected result, and returns the finished product to the user.

I am just wondering how to define score and find relevant answer closest to user input

Any help or ideas will be appreciated

1

There are 1 answers

0
Dave Morton On BEST ANSWER

@user3589042 (rather cumbersome name, don't you think?)

I'm Dave Morton, lead developer for Program O. I'm sorry I missed this at the time you asked the question. It only came to my attention today.

The way that Program O scores the potential matches pulled from the database is this:

  1. Is the response from the aiml_userdefined table? yes=300/no=0
  2. Is the category for this bot, or it's parent (if it has one)? this=250/parent=0
  3. Does the pattern have one or more underscore (_) wildcards? yes=100/no=0
  4. Does the current category have a <topic> tag? yes(see below)/no=0

    a. Does the <topic> contain one or more underscore (_) wildcards? yes=80/no=0

    b. Does the <topic> directly match the current topic? yes=50/no=0

    c. Does the <topic> contain a star (*) wildcard? yes=10/no=0

  5. Does the current category contain a <that> tag? yes(see below)/no=0

    a. Does the <that> contain one or more underscore (_) wildcards? yes=45/no=0

    b. Does the <that> directly match the current topic? yes=15/no=0

    c. Does the <that> contain a star (*) wildcard? yes=2/no=0

  6. Is the <pattern> a direct match to the user's input? yes=10/no=0

  7. Does the <pattern> contain one or more star (*) wildcards? yes=1/no=0

  8. Does the <pattern> match the default AIML pattern from the config? yes=5/no=0

The script then adds up all passed tests listed above, and also adds a point for each word in the category's <pattern> that also matches a word in the user's input. The AIML category with the highest score is considered to be the "best match". In the event of a tie, the script will then select either the "first" highest scoring category, the "last" one, or one at random, depending on the configuration settings. this selected category is then returned to other functions for parsing of the XML.

I hope this answers your question.