Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
#Python AI chatbot that solves Medical queries
#import libraries
import urllib
import requests
from nltk.chat.util import Chat, reflections
"""Function to chat with the user"""
def chatter():
x=0
print("Hi, My name is A.P.P.O.L.O and I'm a Medical chatbot.Let's chat ! ")
#List to hold responses
My_responses = [
['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 group(.*)',['A+ , A- , B+ , B- , O+ , O- , AB+ ,AB-']],
['Corona(.*)|corona(.*)', ['Coronaviruses are a group of related viruses that cause diseases in mammals and birds. In humans, coronaviruses cause respiratory tract infections that can be mild, such as some cases of the common cold (among other possible causes, predominantly rhinoviruses), and others that can be lethal, such as SARS, MERS, and COVID-19. Symptoms in other species vary: in chickens, they cause an upper respiratory tract disease, while in cows and pigs they cause diarrhea. There are yet to be vaccines or antiviral drugs to prevent or treat human coronavirus infections.']]
]
print('\nTo start a conversation with me select an option from below list \nOr if you just wanna chat casually press !:')
while(x!='!'):
print("\nplease select any one among the following :")
x=input('1) Overall Covid-19 Report \n2) Country-wise Corvid-19 report \n3) Hospitals registered under Medicare\n')
if x=='1':
r= urllib.request.urlopen('https://coronavirus-19-api.herokuapp.com/all ') #requests the needed api and store it
print('Overall report\n')
print(r.read())
if x=='2':
r= urllib.request.urlopen('https://coronavirus-19-api.herokuapp.com/countries')
print('Country-wise breakdown.Scroll right to see more if not displaying properly\n')
print(r.read())
if x=='3':
r= urllib.request.urlopen('https://data.medicare.gov/api/views/84jm-wiui')
print("List of hospital registered under Medicare.Scroll right if data is unseen\n")
print(r.read())
if x=='exit' or x=='Exit':
return
print("\nOkay then let's chat\n")
chat=Chat(My_responses)
chat.converse() #starts coversation with user
chatter() #calls the chatter function