What’s Hot

How to make a chatbot in Python

How to make a chatbot in Python


First stop for building a real chatbot in Python would be to use PyAIML, which can be downloaded here
AIML (Artificial Intelligence Markup Language) is an XML based format for encoding a chatbots “brain”. It was Developed by Richard Wallace and the resulting bot, ALICE was the best at the time.
you can also download the standard ALICE brain here

download PyAIML, unpack it and run
1
$ sudo python setup.py install
in its folder. then download the Alice brain from thr second link and unpack it. The file std-startup.xml should be on python path and the other files in their folder below.
To make a quick script that will get you chatting use the following
1
2
3
4
5
import aiml
k = aiml.Kernel()
k.learn("std-startup.xml")
k.respond("load aiml b")
while True: print k.respond(raw_input("> "))
this is the ultimate start you off script for starting to chat with PyAIML, but I advise you to dive in and start to write your own AIML fairly soon. It is not a full programming language, but an xml dialect to specify statements and responses.
Each aiml file has a header like this
1
2
3
4
<?xml version="1.0" encoding="ISO-8859-1"?>
<aiml version="1.0">
<meta name="author" content="luke Dunn"/>
<meta name="language" content="en"/>
Then it consists of stuff like
1
2
3
4
<category>
<pattern>hello</pattern>
<template>Hi there</template>
</category>
Each <category> element holds a pattern and a template. the pattern is the input to PyAIML, ie what the user says to the bot and the template holds the output, what the bot will say back.
with that knowledge alone you can start customising, but I’ll add a bit more. Consider ways to shorten the code. There is little difference between statements like “Hello”, “Hi”, “Howdy” in terms of their interactional meaning. So AIML has a way to map multiple inputs to the same output. Its done like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&lt;category&gt;
&lt;pattern&gt;HEY&lt;/pattern&gt;
&lt;template&gt;&lt;srai&gt;hello&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;
&lt;category&gt;
&lt;pattern&gt;HI THERE&lt;/pattern&gt;
&lt;template&gt;&lt;srai&gt;hello&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;
&lt;category&gt;
&lt;pattern&gt;HOWDY&lt;/pattern&gt;
&lt;template&gt;&lt;srai&gt;hello&lt;/srai&gt;&lt;/template&gt;
&lt;/category&gt;
&lt;category&gt;
&lt;pattern&gt;HELLO&lt;/pattern&gt;
&lt;template&gt;hello human&lt;/template&gt;
&lt;/category&gt;
the <srai> tag tells the system that “Hey”, “Hi there”,”howdy” and “hello” all mean the same thing.. simple really.
You can also use wildcards, which are designated by *, and you can group multiple differing inputs all to give the same response using the <srai>. There is also a “random.choice()” type function that can choose from a list of responses and all the above can be composed together allowing lots of different possibilities.
You can also set topics which contain different sets of answers conditional on what the topic is.
A more complete bit of documentation is here
Once you’ve started playing and grokked the concept then next check out
which is an excellent book on aiml written by Wallace himself. There is so much more to learn but you’ll have hours of fun with what I’ve pointed you at here !
One other nice thing is that AIML can perform a system command where it accesses a shell. This is the starting point for crazy dreamers who might want to make a voice controlled OS frontend, perhaps using CMU Sphinx etc see my post: here
also check this:

Source: pythonism.wordpress


3 comments: Leave Your Comments

  1. Your thinking toward the respective issue is awesome also the idea behind the blog is very interesting which would bring a new evolution in respective field. Keep update more information.
    Chatbot Company in India
    Chatbot Company in Chennai
    Chatbot Development Company in Chennai
    Chatbot in Chennai

    ReplyDelete
  2. Really very informative and creative. This sharing concept is a good way to enhance the knowledge. Thank you very much for this post. I like this site very much. I like it and it help me to development very well...
    Chatbot Company in Dubai
    Chatbot Companies in Dubai
    Chatbot Development
    AI Chatbot Development
    Chatbot Companies in UAE
    Chatbot Company in Chennai
    Chatbot Company in Mumbai
    Chatbot Company in Delhi
    Chatbot Development Companies

    ReplyDelete
  3. Selling USA FRESH SSN Leads/Fullz, along with Driving License/ID Number with good connectivity.

    **PRICE FOR ONE LEAD/FULLZ 2$**

    All SSN's are Tested & Verified. Fresh spammed data.

    **DETAILS IN LEADS/FULLZ**

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER
    ->ADDRESS WITH ZIP
    ->PHONE NUMBER, EMAIL
    ->EMPLOYEE DETAILS

    ->Bulk order negotiable
    ->Minimum buy 25 to 30 leads/fullz
    ->Hope for the long term business
    ->You can asked for specific states too

    **Contact 24/7**

    Whatsapp > +923172721122

    Email > leads.sellers1212@gmail.com

    Telegram > @leadsupplier

    ICQ > 752822040

    ReplyDelete