-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatterbot.py
50 lines (35 loc) · 1.03 KB
/
chatterbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import Flask, jsonify, request
import aiml
import requests
import json
kernel = aiml.Kernel()
kernel.learn("chatterbot.xml")
kernel.respond("load aiml b")
app = Flask(__name__)
@app.route("/")
def hello():
fp = open("conversations.txt", "a")
fp.write("user: " + request.args["param"] + "\n")
name = kernel.respond(request.args["param"])
fp.write("chatterbot: " + name + "\n")
fp.close()
return name
@app.route("/home")
def there():
return "Ganupa"
if __name__ == "__main__":
app.run()
# Create the kernel and learn AIML files
# Press CTRL-C to break this loop
# while True:
# print (kernel.respond(input("Enter your message >> ")))
# domain=kernel.getPredicate('domain')
# link="https://jobs.github.com/positions.json?"
# par={'description':domain}
# r = requests.get(url = link, params = par)
# r.text
# data = json.loads(r.text)
# for item in data:
# print ("job Title: %s" % (item['title']))
# print ("****************************************")
#