Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Medical-Smart-Chatbot/Initial_chatbot.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (25 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import the library | |
from nltk.chat.util import Chat, reflections | |
import requests | |
#URL='http://apps.who.int/gho/athena/api/GHO?format=json' | |
def get_latest_blood( ): | |
response = requests.get(URL+'/') | |
return response | |
"""List which hold responses""" | |
name_resp = [ | |
['my name is (.*)',['hi %1']], | |
[('hi|hello') ,['hey there' , 'hello there', 'greetings!']], | |
['why were you made(.*)' , ['I am a chatbot designed for managing operations of a blood bank']], | |
['how many blood groups are there(.*)',['8 blood groups']], | |
['which are the blood groups(.*)',['A+ , A- , B+ , B- , O+ , O- , AB+ ,AB-']] | |
#,['(.*)database(.*)', [''.join( str(get_latest_blood( ))),]] | |
] | |
dummy_myresponse = { | |
'how are you' : 'I am fine,thank you' | |
} | |
"""Function for conversing with user""" | |
def chatter(): | |
print("Hi, I'm a Blood Bank Chatbot and I want to help and chat with you ! \n Type quit to leave ") #default message at the start | |
chat=Chat(name_resp,dummy_myresponse) | |
chat.converse() | |
chatter() |