Home  >  Article  >  Backend Development  >  AIML-based PHP chatbot

AIML-based PHP chatbot

小云云
小云云Original
2017-12-05 11:00:033309browse

A chatbot is a program used to simulate human conversation or chat. "Eliza" and "Parry" are very famous early chatbots. It attempts to build programs that, at least temporarily, make a real human think they are chatting with another human being.

AIML-based PHP chatbot

0. Introduction

This chatbot is Written with reference to AIML 2.5 and Program-P, suitable for languages ​​with UTF-8 encoding and word suffixes that change according to different tenses. Interested friends can do their own research and study.

1. Download and install

git clone https://github.com/kompasim/chatbot.git. After downloading, complete the following steps You can upload it directly to your server.

2. Database configuration

The database uses MySQL. You can see the Config.php configuration file in the chatbot file Ai Ni Jia. And fill in the relevant information about the database.

3. Import the database backup file

Import chatbot.sql in the root directory into the database, which stores the configuration information of the chatbot , a table for requesting records and other information.

4. Add personalized corpus

We open aiml/chatbot.aiml for editing or create a new aiml file and add our personalization Corpus, and then include the new aiml file to chatbot.aiml.

5. About AIML files

  • aiml corpus files must be placed under the aiml folder in the root directory . chatbot.aiml value entry file, the aiml root tag inside can contain multiple category tags, a default tag, and multiple include tags.

  • Other aiml files must first contain the topic tag in the aiml root tag, which then contains multiple categories and a default tag. It cannot There is an include tag.

#6. Test the chatbot

After opening imdex.php, you can test the corpus we just added.

7. Call api

#If you want to call the chatbot in the public account or your own APP, we can call its api api like this. php?requestType=talk&input=Hello

8. About the matching rules

The modified matching rules:

<span style="font-size: 16px;">* ---> (\S+)<br># ---> \S+<br>_ ---> .*<br>= ---> \S*<br></span>

9. About AIML tags

  • The aiml tag of this chat robot is different from the standard aiml tag. We You can find more tags supported by this chatbot in the AIML.MD file.

10. Project github address

https://github.com/kompasim/chatbot

AIML-based PHP chatbot

The above content is a PHP chatbot based on AIML. I hope it will be helpful to everyone.

Related recommendations:

PHP WeChat public platform development Chatbot development

How to use AIML to build a chatbot based on Python

Use Turing API to create a WeChat chatbot

The above is the detailed content of AIML-based PHP chatbot. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn