File tree 5 files changed +93
-0
lines changed
5 files changed +93
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Simple Chatbot
2
+
3
+ This script is used to create a simple chatbot for basic conversations.
4
+
5
+ ## Requirement for this script:
6
+
7
+ 1 . aiml
8
+
9
+ install it by running the following command in the command prompt:
10
+
11
+ pip install aiml
12
+
13
+ ## How to use this script?
14
+
15
+ Just type the following in your command prompt:
16
+
17
+ python script.py
18
+
19
+ ## Sample of the script in action:
20
+
21
+ ![ demo] ( https://user-images.githubusercontent.com/56690856/98097850-930cc900-1eb3-11eb-8fa4-c6118a802531.png )
Original file line number Diff line number Diff line change
1
+ <aiml version="1.0.1" encoding="UTF-8">
2
+ <!-- basic_chat.aiml -->
3
+
4
+ <category>
5
+ <pattern>HELLO</pattern>
6
+ <template>
7
+ Well, hello!!!
8
+ </template>
9
+ </category>
10
+
11
+ <category>
12
+ <pattern>I am *</pattern>
13
+ <template>
14
+ Hello <set name = "username"> <star/>! </set>
15
+ </template>
16
+ </category>
17
+
18
+ <category>
19
+ <pattern>WHO ARE YOU</pattern>
20
+ <template>
21
+ I'm a bot, silly!
22
+ </template>
23
+ </category>
24
+
25
+ <category>
26
+ <pattern>Bye</pattern>
27
+ <template>
28
+ Bye <get name = "username"/> Thanks for the conversation!
29
+ </template>
30
+ </category>
31
+
32
+ <category>
33
+ <pattern>WHAT IS YOUR NAME</pattern>
34
+ <template>My name is Botty</template>
35
+ </category>
36
+
37
+ </aiml>
Original file line number Diff line number Diff line change
1
+ aiml
Original file line number Diff line number Diff line change
1
+ import aiml
2
+
3
+ # Create the kernel and learn AIML files
4
+ kernel = aiml .Kernel ()
5
+ kernel .learn ("std-startup.xml" )
6
+ kernel .respond ("load aiml b" )
7
+
8
+ print ("This is a simple chatbot" )
9
+ print ("Press CTRL-C to exit" )
10
+
11
+ # Press CTRL-C to break this loop
12
+ while True :
13
+ print (kernel .respond (input ("Enter you message >>" )))
Original file line number Diff line number Diff line change
1
+ <aiml version =" 1.0.1" encoding =" UTF-8" >
2
+ <!-- std-startup.xml -->
3
+
4
+ <!-- Category is an atomic AIML unit -->
5
+ <category >
6
+
7
+ <!-- Pattern to match in user input -->
8
+ <!-- If user enters "LOAD AIML B" -->
9
+ <pattern >LOAD AIML B</pattern >
10
+
11
+ <!-- Template is the response to the pattern -->
12
+ <!-- This learn an aiml file -->
13
+ <template >
14
+ <learn >basic_chat.aiml</learn >
15
+ <!-- You can add more aiml files here -->
16
+ <!-- <learn>more_aiml.aiml</learn>-->
17
+ </template >
18
+
19
+ </category >
20
+
21
+ </aiml >
You can’t perform that action at this time.
0 commit comments