├── README.md └── Healthcare-chatbot-using-NLP-master ├── static ├── ba.jpg ├── bg.jpg ├── robo.png ├── robo1.jpg ├── style.css └── sound.js ├── templates ├── bg.jpg └── index2.html ├── __pycache__ └── bot2.cpython-37.pyc ├── pincodes.txt ├── serve.py ├── bot2.py └── symptom.txt /README.md: -------------------------------------------------------------------------------- 1 | # -Healthcare-chatbot-using-NLP -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/ba.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/static/ba.jpg -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/static/bg.jpg -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/robo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/static/robo.png -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/robo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/static/robo1.jpg -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/templates/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/templates/bg.jpg -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/__pycache__/bot2.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mahalakshmee/-Healthcare-chatbot-using-NLP/HEAD/Healthcare-chatbot-using-NLP-master/__pycache__/bot2.cpython-37.pyc -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/pincodes.txt: -------------------------------------------------------------------------------- 1 | 2 | 530011--> 3 | Name:DR. B.Lakshmee, 4 | contactnumber:0891-2709239, 5 | location:"tharamani,chennai", 6 | timings: 6:30pm-9:30pm, 7 | Specialist : ENT. 8 | 9 | 10 | -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/serve.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, jsonify, make_response 2 | from bot2 import chat 3 | app = Flask(__name__) 4 | 5 | @app.route('/', methods = ['GET', 'POST']) 6 | def indexpage(): 7 | if request.method == "POST": 8 | 9 | print(request.form.get('name')) 10 | return render_template("index2.html") 11 | return render_template("index2.html") 12 | 13 | @app.route("/entry", methods=['POST']) 14 | def entry(): 15 | req = request.get_json() 16 | print(req) 17 | res = make_response(jsonify({"name":"{}.".format(chat(req)),"message":"OK"}), 200) 18 | return res 19 | 20 | 21 | if __name__ == "__main__": 22 | app.run(debug=True) 23 | -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/templates/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 14 |

MAKING HEALTHCARE CHATBOT USING NATURAL LANGUAGE PROCESSING

15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |

CHATBOT

29 |

HEALTHCARE CHATBOT

30 |
31 |
32 | 33 |
34 |
    35 |
  • X
  • 36 | 37 |
  • 38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 |
46 |
47 |
48 |
49 |
50 | 51 | 52 |
53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/bot2.py: -------------------------------------------------------------------------------- 1 | # Meet Pybot: your friend 2 | import nltk 3 | import warnings 4 | warnings.filterwarnings("ignore") 5 | # nltk.download() # for downloading packages 6 | #import tensorflow as tf 7 | import numpy as np 8 | import random 9 | import string # to process standard python strings 10 | 11 | f=open('symptom.txt','r',errors = 'ignore') 12 | m=open('pincodes.txt','r',errors = 'ignore') 13 | checkpoint = "./chatbot_weights.ckpt" 14 | #session = tf.InteractiveSession() 15 | #session.run(tf.global_variables_initializer()) 16 | #saver = tf.train.Saver() 17 | #saver.restore(session, checkpoint) 18 | 19 | raw=f.read() 20 | rawone=m.read() 21 | raw=raw.lower()# converts to lowercase 22 | rawone=rawone.lower()# converts to lowercase 23 | nltk.download('punkt') # first-time use only 24 | nltk.download('wordnet') # first-time use only 25 | sent_tokens = nltk.sent_tokenize(raw)# converts to list of sentences 26 | word_tokens = nltk.word_tokenize(raw)# converts to list of words 27 | sent_tokensone = nltk.sent_tokenize(rawone)# converts to list of sentences 28 | word_tokensone = nltk.word_tokenize(rawone)# converts to list of words 29 | 30 | 31 | sent_tokens[:2] 32 | sent_tokensone[:2] 33 | 34 | word_tokens[:5] 35 | word_tokensone[:5] 36 | 37 | lemmer = nltk.stem.WordNetLemmatizer() 38 | def LemTokens(tokens): 39 | return [lemmer.lemmatize(token) for token in tokens] 40 | remove_punct_dict = dict((ord(punct), None) for punct in string.punctuation) 41 | def LemNormalize(text): 42 | return LemTokens(nltk.word_tokenize(text.lower().translate(remove_punct_dict))) 43 | 44 | Introduce_Ans = [" "] 45 | GREETING_INPUTS = ("hello", "hi","hiii","hii","hiiii","hiiii", "greetings", "sup", "what's up","hey",) 46 | GREETING_RESPONSES = ["hi,are you suffering from any health issues?(Y/N)", "hey,are you having any health issues?(Y/N)", "hii there,are you having any health issues?(Y/N)", "hi there,are you having any health issues?(Y/N)", "hello,are you having any health issues?(Y/N)", "I am glad! You are talking to me,are you having any health issues?(Y/N)"] 47 | Basic_Q = ("yes","y") 48 | Basic_Ans = "okay,tell me about your symptoms" 49 | Basic_Om = ("no","n") 50 | Basic_AnsM = "thank you visit again" 51 | fev=("iam suffering from fever", "i affected with fever","i have fever","fever") 52 | feve_r=("which type of fever you have? and please mention your symptoms then we try to calculate your disease.") 53 | 54 | 55 | # Checking for greetings 56 | def greeting(sentence): 57 | """If user's input is a greeting, return a greeting response""" 58 | for word in sentence.split(): 59 | if word.lower() in GREETING_INPUTS: 60 | return random.choice(GREETING_RESPONSES) 61 | 62 | # Checking for Basic_Q 63 | def basic(sentence): 64 | for word in Basic_Q: 65 | if sentence.lower() == word: 66 | return Basic_Ans 67 | def fever(sentence): 68 | for word in fev: 69 | if sentence.lower() == word: 70 | return feve_r 71 | 72 | # Checking for Basic_QM 73 | def basicM(sentence): 74 | """If user's input is a greeting, return a greeting response""" 75 | for word in Basic_Om: 76 | if sentence.lower() == word: 77 | 78 | 79 | return Basic_AnsM 80 | # Checking for Introduce 81 | def IntroduceMe(sentence): 82 | return random.choice(Introduce_Ans) 83 | 84 | 85 | from sklearn.feature_extraction.text import TfidfVectorizer 86 | from sklearn.metrics.pairwise import cosine_similarity 87 | 88 | 89 | # Generating response 90 | def response(user_response): 91 | robo_response='' 92 | sent_tokens.append(user_response) 93 | TfidfVec = TfidfVectorizer(tokenizer=LemNormalize, stop_words='english') 94 | tfidf = TfidfVec.fit_transform(sent_tokens) 95 | 96 | vals = cosine_similarity(tfidf[-1], tfidf) 97 | 98 | idx=vals.argsort()[0][-2] 99 | flat = vals.flatten() 100 | flat.sort() 101 | req_tfidf = flat[-2] 102 | if(req_tfidf==0): 103 | robo_response=robo_response+"I am sorry! I don't understand you" 104 | return robo_response 105 | else: 106 | robo_response = robo_response+sent_tokens[idx] 107 | return robo_response 108 | 109 | # Generating response 110 | 111 | # Generating response 112 | def responseone(user_response): 113 | robo_response='' 114 | sent_tokensone.append(user_response) 115 | TfidfVec = TfidfVectorizer(tokenizer=LemNormalize, stop_words='english') 116 | tfidf = TfidfVec.fit_transform(sent_tokensone) 117 | vals = cosine_similarity(tfidf[-1], tfidf) 118 | idx=vals.argsort()[0][-2] 119 | flat = vals.flatten() 120 | flat.sort() 121 | req_tfidf = flat[-2] 122 | if(req_tfidf==0): 123 | robo_response=robo_response+"I am sorry! I don't understand you" 124 | return robo_response 125 | else: 126 | robo_response = robo_response+sent_tokensone[idx] 127 | return robo_response 128 | 129 | def chat(user_response): 130 | user_response=user_response.lower() 131 | keyword = " module " 132 | keywordone = " module" 133 | keywordsecond = "module " 134 | 135 | if(user_response!='bye'): 136 | 137 | if(user_response=='thanks' or user_response=='thank you' ): 138 | flag=False 139 | #print("ROBO: You are welcome..") 140 | return "You are welcome.." 141 | elif(basicM(user_response)!=None): 142 | return basicM(user_response) 143 | else: 144 | if(user_response.find(keyword) != -1 or user_response.find(keywordone) != -1 or user_response.find(keywordsecond) != -1): 145 | #print("ROBO: ",end="") 146 | #print(responseone(user_response)) 147 | return responseone(user_response) 148 | sent_tokensone.remove(user_response) 149 | elif(greeting(user_response)!=None): 150 | #print("ROBO: "+greeting(user_response)) 151 | return greeting(user_response) 152 | elif(user_response.find("your name") != -1 or user_response.find(" your name") != -1 or user_response.find("your name ") != -1 or user_response.find(" your name ") != -1): 153 | return IntroduceMe(user_response) 154 | elif(basic(user_response)!=None): 155 | return basic(user_response) 156 | elif(fever(user_response)!=None): 157 | return fever(user_response) 158 | else: 159 | #print("ROBO: ",end="") 160 | #print(response(user_response)) 161 | return response(user_response) 162 | sent_tokens.remove(user_response) 163 | 164 | else: 165 | flag=False 166 | #print("ROBO: Bye! take care..") 167 | return "Bye! take care.." 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/symptom.txt: -------------------------------------------------------------------------------- 1 | 2 | Stopped Growth :--> 3 | pred_diseases:'Growth Disorder, Turner Syndrome', 4 | analgesics: 'Thyroid hormone pills, growth hormone injections', 5 | treatment scans:'Bone Age Xray, MRI scan', 6 | 'Meat, Seafood,Leafygreens,Diary,Spinach, Beef' 7 | -------> Enter your pincode to see available doctors near by you . 8 | 9 | Wheezing, Coughing and troubled breathing,chest pain -->pred_diseases: Asthma; 10 | analgesics: Metered dose inhalers, nebulizers; 11 | treatment scans:Asthma therapy; 12 | diet:Fruits and vegetables 13 | -------> Enter your pincode to see available doctors near by you . 14 | 15 | baby too small, weight<5.5 pounds-->pred_diseases: 'Learning disabilities', 16 | analgesics: 'iron supplements', 17 | treatment scans:'Temperature Control Incubator', 18 | diet:'iron supplements' 19 | -------> Enter your pincode to see available doctors near by you. 20 | 21 | Repetetive behaviour,prefers to be alone-->pred_diseases: 'Autism\r\n', 22 | analgesics: 'Ketamine, Midazolem', 23 | treatment scans:'Teach social skills and cognitive behaviour', 24 | diet: 'Only yelow or white foods such as rice, potatoes or pasta and strictly avoid diary' 25 | -------> Enter your pincode to see available doctors near by you. 26 | 27 | Self-destructiveness,sadness and being upset--> 28 | pred_diseases: 'Depression', 29 | analgesics: 'Prozac, Zoloft or Celexa', 30 | treatment scans:'Constantly praise him, teach skills, and give self-development talks', 31 | diet: 'Fish and whole grains'. 32 | 33 | Paleness, loss of energy, weightloss and easy bruising--pred_diseases: 'Cancer or Brain Tumor', 34 | analgesics: 'Morphine or Ibuprofen', 35 | treatment scans:'Chemotherapy or Stem cell transplant', 36 | diet: 'Cheese, Meat, Seafood, Diary and Eggs'. 37 | 38 | Fever,fever up to 102f, Tiredness or Loss of Appetitse--> 39 | pred_diseases:'Chickenpox', 40 | analgesics: 'Acetaminophen', 41 | treatment scans:'lukewarm bath and apply calamine lotion to itchy areas', 42 | diet: 'Raw fruits, Vegetables, Meat, Pastured eggs and avoid salty foods'. 43 | 44 | easy tiredness and overweight--> 45 | pred_diseases:'Obesity', 46 | analgesics: 'Not suggested to take analgesics for obesity', 47 | treatment scans:'building heathy eating ang drinking habits and physical activities like exercise', 48 | diet: 'Fruits and vegetables, and avoid skipping breakfast' 49 | -------> Enter your pincode to see available doctors near by you. 50 | 51 | Severe tooth ache--> 52 | pred_diseases:'Cavities\r\n', 53 | analgesics: 'Ibuprofen or Aspirin', 54 | treatment scans: 'Fluoride toothpaste', 55 | diet: 'juices and avoid sweets, chocolates and unhealthy snacks'. 56 | 57 | Often urinating, slow healing of bruises, weightloss--> 58 | pred_diseases: 'Diabetes', 59 | analgesics: 'Tylenol or Aspirin', 60 | treatment scans:'Insulin Treatment', 61 | diet: 'brown rice or cereals with two eggs daily' 62 | -------> Enter your pincode to see available doctors near by you. 63 | 64 | High body temperature, severe headache and tiredness--> 65 | pred_diseases: 'Fever', 66 | analgesics: 'Paracetemol or Aspirin', 67 | treatment scans:'Tylenol, Ibuprofen to treat stomach irritation', 68 | diet: 'fluid intake like gatorage, fruitjuices or milk' 69 | -------> Enter your pincode to see available doctors near by you. 70 | 71 | Depression, Eating Disorders--> 72 | pred_diseases: 'Drug or Smoke or Alcohol Addiction', 73 | analgesics: 'Baclofen, Gebapentin', 74 | treatment scans:'Visiting Rehabilitation Centers, Help teens choose good friends and learn to say NO', 75 | diet: 'Green leafy vegetables'. 76 | 77 | Swelling, irritation, breast or nipple pain--> 78 | pred_diseases: 'Breast Cancer', 79 | analgesics: 'Tamoxifen', 80 | treatment scans: 'heart-smart diet and indulge in physical activity and avoid smoking', 81 | diet: 'whole grains, beans, legumes'. 82 | 83 | Sudden Confusion, Dizziness, Loss of Banlance--> 84 | pred_diseases: 'Stroke', 85 | analgesics: 'Anti-platelet drugs like Plavix', 86 | treatment scans:'Clot-bursting therapy', 87 | diet: 'Fruits and Vegetables, and avoid salt'. 88 | 89 | Shortness of breath, or being inactive--> 90 | pred_diseases: 'COPD', 91 | analgesics: 'Tudorza or Brovana', 92 | treatment scans:'Inhalers and oral steroids', 93 | diet: 'Eggs, Cheese, Meat, fish, and Poultry' 94 | -------> Enter your pincode to see available doctors near by you. 95 | 96 | Forgetfulness or Confusion--> 97 | pred_diseases: 'Alzheimer\'s disease', 98 | analgesics: 'Aricept or Exelon', 99 | treatment scans:'MRI and CT scans', 100 | diet: 'berries, beans and whole grains'. 101 | 102 | Chest pain, confusion, cough or fatigue--> 103 | pred_diseases: 'Pneumonia or Influenza', 104 | analgesics: 'Levofloxacin', 105 | treatment scans:'Plenty of fluids and get lot of rest', 106 | diet:'Citrus fruits, Oily fish and Leafy greens' 107 | -------> Enter your pincode to see available doctors near by you. 108 | 109 | Often urinating, slow healing of bruises, weightloss--> 110 | pred_diseases: 'Diabetes', 111 | analgesics: 'Tylenol or Aspirin', 112 | treatment scans:'Insulin Treatment', 113 | diet:'Brown rice or cereals with two eggs daily'. 114 | 115 | reduced urine, swelling of legs or fatigue--> 116 | pred_diseases: 'Kidney Disease', 117 | analgesics: 'Naproxen or Ibuprofen', 118 | treatment scans:'Dialysis', 119 | diet:'Berries, bell peppers, onions and apples'. 120 | 121 | Fever, chills, rapid breathing and heart rate--> 122 | pred_diseases: 'Blood poisoning', 123 | analgesics: 'Ceftriaxone or Azithromycin', 124 | treatment scans:'Vasoconstriction to narrow blood vessels', 125 | diet:'Leafy greens like spinach'. 126 | 127 | Fragile bones--> 128 | pred_diseases: 'Brittle bone disease', 129 | analgesics: 'Biphosphonates, calcium and vitamin D supplements', 130 | treatment scans: 'VitaminD supplements and avoid smoking and alcohol', 131 | diet:'fruits and foods high on calcium'. 132 | 133 | Skin wrinkles and aging--> 134 | pred_diseases: 'No disease', 135 | analgesics: 'Anti-aging creams', 136 | treatment scans: 'Blepharoplasty surgery to get rid of aging', 137 | diet: 'Berries, Broccoli, Papaya, Spinach, Nuts and Avocado'. 138 | 139 | Blurry and loss of vision--> 140 | pred_diseases: 'Mascular Degeneration', 141 | analgesics: 'Lucentis or Macugen', 142 | treatment scans: 'Regular exercise and avoid smoking', 143 | diet:'Fish and vegetables'. 144 | 145 | Blood pressure reading 140 or higher--> 146 | pred_diseases: 'High blood pressure', 147 | analgesics: 'Thiazide diuretics', 148 | treatment scans:'Physical activity like exercise and avoid smoking and srinking', 149 | diet:'low-fat diary, whole grains and Fruits'. 150 | 151 | Trouble sleeping or sleep, mood swings, vaginal dryness--> 152 | pred_diseases: 'Menopause', 153 | analgesics: 'Isoflav capsules', 154 | treatment scans: 'Estrogen levels test', 155 | diet:'Fish, Fruits, Vegetables and Diary'. 156 | 157 | Cold, Allergies, Nasal problems--> 158 | pred_diseases: 'Sinusitis', 159 | analgesics: 'Acetaminophen or Nasal spray', 160 | treatment scans: 'Antibiotics like Aspirin and Nasal sprays', 161 | diet:'Salmon, Avocados, Cherries and Beans' 162 | -------> Enter your pincode to see available doctors near by you. 163 | 164 | Pain while urine and ejaculation--> 165 | pred_diseases: 'Prostate Cancer', 166 | analgesics: 'Bicalutamide or Casodex', 167 | treatment scans:'Radiation therapy or prostatectomy', 168 | diet: 'Veggies and fruits and low in meat'. 169 | 170 | Trembling body parts and loss of balance--> 171 | pred_diseases: 'Parkinson\'s disease', 172 | analgesics: 'Vesoret capsules', 173 | treatment scans: 'Cardibopa-levodopa', 174 | diet:'Fruits and vegetables'. 175 | 176 | Buildup of fluids in legs, ankles and legs, tiredness--> 177 | pred_diseases: 'Heart failure', 178 | analgesics: 'Carvedilol or Metoprolol', 179 | treatment scans: 'ACE inhibitors', 180 | diet: 'Plain rice, fish, egg, milk and yoghurt'. 181 | 182 | 530011--> 183 | Name:DR. B.Lakshmee, 184 | contactnumber:0891-2709239, 185 | location:"tharamani,chennai", 186 | timings: 6:30pm-9:30pm, 187 | Specialist:ENT. -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/style.css: -------------------------------------------------------------------------------- 1 | /*-------------------- 2 | Mixins 3 | --------------------*/ 4 | /*-------------------- 5 | Body 6 | --------------------*/ 7 | *, 8 | *::before, 9 | *::after { 10 | box-sizing: border-box; 11 | } 12 | 13 | html, 14 | body { 15 | 16 | height: 100%; 17 | 18 | } 19 | 20 | body { 21 | background: -webkit-linear-gradient(315deg, #044f48, #2a7561); 22 | background: linear-gradient(135deg, #044f48, #2a7561); 23 | background-size: cover; 24 | font-family: 'Open Sans', sans-serif; 25 | font-size: 12px; 26 | line-height: 1.3; 27 | overflow: hidden; 28 | } 29 | 30 | 31 | .r-nav{ position: absolute; 32 | right: 9px; 33 | width: 100px; 34 | top: 0px; 35 | height: 45px; 36 | } 37 | 38 | .r-nav li { 39 | list-style: none; 40 | float: right; 41 | display: inline-block; 42 | width: 30px; 43 | 44 | text-align: center; 45 | } 46 | .r-nav li a { 47 | margin: 0; 48 | padding: 0; 49 | line-height: 18px; 50 | font-size: 16px; 51 | color: #979797; 52 | 53 | } 54 | 55 | .bg { 56 | width: 100%; 57 | height: 100%; 58 | top: 0; 59 | left: 0; 60 | z-index: 1; 61 | background: url(ba.jpg); 62 | 63 | -webkit-filter: blur(30px); 64 | filter: blur(30px); 65 | 66 | } 67 | 68 | 69 | .loading-img{ 70 | width: 100px; 71 | display: inline; 72 | margin: 10px 80px; 73 | height: 100px;} 74 | 75 | 76 | .buttonx { 77 | background: #0070ff;; 78 | padding: 5px 30px; 79 | margin: 5px 5px 5px 0px; 80 | border: 1px solid #0070ff; 81 | color: #fff; 82 | border-radius: 10px; 83 | } 84 | 85 | .buttony { background: transparent; 86 | padding: 5px 30px; 87 | margin: 5px 5px 5px 0px; 88 | border: 1px solid #0070ff; 89 | color: #0070ff;; 90 | border-radius: 10px; 91 | } 92 | 93 | 94 | .oracle-search{width: 100%; 95 | margin: 7px auto; 96 | height: 29px; 97 | padding: 5px; 98 | font-size: 12px; 99 | border-radius: 15px; 100 | border: 1px solid rgba(255, 255, 255, 0.6); 101 | color: #fff; 102 | background: rgba(68, 68, 68, 0.47);} 103 | 104 | /*-------------------- 105 | Chat 106 | --------------------*/ 107 | 108 | 109 | input[type="range"] { 110 | -webkit-appearance: none; 111 | width: 340px; 112 | height: 2px; 113 | background: #0070ff; 114 | background-position: center; 115 | background-repeat: no-repeat; 116 | position: absolute; 117 | top: 0px; 118 | bottoM: 0px; 119 | left: 0px; 120 | right: 0px; 121 | margin: auto; 122 | display: block; 123 | margin-top: 60px; 124 | } 125 | 126 | input[type="range"]::-webkit-slider-thumb { 127 | -webkit-appearance: none; 128 | width: 20px; 129 | height: 20px; 130 | border-radius: 100%; 131 | background: #434343; 132 | position: relative; 133 | border: 3px solid #0070ff; 134 | z-index: 3; 135 | cursor: pointer; 136 | content: counter(3) 137 | } 138 | 139 | 140 | 141 | 142 | .chat { 143 | position: absolute; 144 | top: 53%; 145 | left: 50%; 146 | -webkit-transform: translate(-50%, -50%); 147 | transform: translate(-50%, -50%); 148 | width: 1300px; 149 | height: 90vh; 150 | max-height: 640px; 151 | z-index: 2; 152 | overflow: hidden; 153 | box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2); 154 | background: rgba(0, 0, 0, 0.5); 155 | border-radius: 20px; 156 | display: -webkit-box; 157 | display: -ms-flexbox; 158 | display: flex; 159 | -webkit-box-pack: justify; 160 | -ms-flex-pack: justify; 161 | justify-content: space-between; 162 | -webkit-box-orient: vertical; 163 | -webkit-box-direction: normal; 164 | -ms-flex-direction: column; 165 | flex-direction: column; 166 | } 167 | 168 | /*-------------------- 169 | Chat Title 170 | --------------------*/ 171 | .chat-title { 172 | -webkit-box-flex: 0; 173 | -ms-flex: 0 1 45px; 174 | flex: 0 1 45px; 175 | position: relative; 176 | z-index: 2; 177 | background: rgba(0, 0, 0, 0.2); 178 | color: #fff; 179 | text-transform: uppercase; 180 | text-align: left; 181 | padding: 10px 10px 10px 50px; 182 | } 183 | .chat-title h1, .chat-title h2 { 184 | font-weight: normal; 185 | font-size: 10px; 186 | margin: 0; 187 | padding: 0; 188 | } 189 | .chat-title h2 { 190 | color: rgba(255, 255, 255, 0.5); 191 | font-size: 8px; 192 | letter-spacing: 1px; 193 | } 194 | .chat-title .avatar { 195 | position: absolute; 196 | z-index: 1; 197 | top: 8px; 198 | left: 9px; 199 | border-radius: 30px; 200 | width: 30px; 201 | height: 30px; 202 | overflow: hidden; 203 | margin: 0; 204 | padding: 0; 205 | border: 2px solid rgba(255, 255, 255, 0.24); 206 | } 207 | .chat-title .avatar img { 208 | width: 100%; 209 | height: auto; 210 | } 211 | 212 | /*-------------------- 213 | Messages 214 | --------------------*/ 215 | .messages { 216 | -webkit-box-flex: 1; 217 | -ms-flex: 1 1 auto; 218 | flex: 1 1 auto; 219 | color: rgb(239, 245, 243); 220 | overflow: hidden; 221 | position: relative; 222 | width: 100%; 223 | } 224 | .messages .messages-content { 225 | position: absolute; 226 | top: 0; 227 | left: 0; 228 | height: 101%; 229 | width: 100%; 230 | } 231 | .messages .message { 232 | clear: both; 233 | float: left; 234 | padding: 6px 10px 7px; 235 | border-radius: 10px 10px 10px 0; 236 | background: rgba(0, 0, 0, 0.3); 237 | margin: 8px 0; 238 | font-size: 14px; 239 | line-height: 1.4; 240 | margin-left: 35px; 241 | position: relative; 242 | text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); 243 | } 244 | .messages .message .timestamp { 245 | position: absolute; 246 | bottom: -19px; 247 | font-size: 9px; 248 | color: rgba(255, 255, 255, 0.3); 249 | } 250 | .messages .message::before { 251 | content: ''; 252 | position: absolute; 253 | bottom: -6px; 254 | border-top: 6px solid rgba(0, 0, 0, 0.3); 255 | left: 0; 256 | border-right: 7px solid transparent; 257 | } 258 | .messages .message .avatar { 259 | position: absolute; 260 | z-index: 1; 261 | bottom: -15px; 262 | left: -35px; 263 | border-radius: 30px; 264 | width: 30px; 265 | height: 30px; 266 | overflow: hidden; 267 | margin: 0; 268 | padding: 0; 269 | border: 2px solid rgba(255, 255, 255, 0.24); 270 | } 271 | .messages .message .avatar img { 272 | width: 100%; 273 | height: auto; 274 | } 275 | .messages .message.message-personal { 276 | float: right; 277 | color: #fff; 278 | text-align: right; 279 | background: -webkit-linear-gradient(330deg, #248A52, #257287); 280 | background: linear-gradient(120deg, #248A52, #257287); 281 | border-radius: 10px 10px 0 10px; 282 | } 283 | .messages .message.message-personal::before { 284 | left: auto; 285 | right: 0; 286 | border-right: none; 287 | border-left: 5px solid transparent; 288 | border-top: 4px solid #257287; 289 | bottom: -4px; 290 | } 291 | .messages .message:last-child { 292 | margin-bottom: 30px; 293 | } 294 | .messages .message.new { 295 | -webkit-transform: scale(0); 296 | transform: scale(0); 297 | -webkit-transform-origin: 0 0; 298 | transform-origin: 0 0; 299 | -webkit-animation: bounce 500ms linear both; 300 | animation: bounce 500ms linear both; 301 | } 302 | .messages .message.loading::before { 303 | position: absolute; 304 | top: 50%; 305 | left: 50%; 306 | -webkit-transform: translate(-50%, -50%); 307 | transform: translate(-50%, -50%); 308 | content: ''; 309 | display: block; 310 | width: 3px; 311 | height: 3px; 312 | border-radius: 50%; 313 | background: rgba(255, 255, 255, 0.5); 314 | z-index: 2; 315 | margin-top: 4px; 316 | -webkit-animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 317 | animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 318 | border: none; 319 | -webkit-animation-delay: .15s; 320 | animation-delay: .15s; 321 | } 322 | .messages .message.loading span { 323 | display: block; 324 | font-size: 0; 325 | width: 20px; 326 | height: 10px; 327 | position: relative; 328 | } 329 | .messages .message.loading span::before { 330 | position: absolute; 331 | top: 50%; 332 | left: 50%; 333 | -webkit-transform: translate(-50%, -50%); 334 | transform: translate(-50%, -50%); 335 | content: ''; 336 | display: block; 337 | width: 3px; 338 | height: 3px; 339 | border-radius: 50%; 340 | background: rgba(255, 255, 255, 0.5); 341 | z-index: 2; 342 | margin-top: 4px; 343 | -webkit-animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 344 | animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 345 | margin-left: -7px; 346 | } 347 | .messages .message.loading span::after { 348 | position: absolute; 349 | top: 50%; 350 | left: 50%; 351 | -webkit-transform: translate(-50%, -50%); 352 | transform: translate(-50%, -50%); 353 | content: ''; 354 | display: block; 355 | width: 3px; 356 | height: 3px; 357 | border-radius: 50%; 358 | background: rgba(255, 255, 255, 0.5); 359 | z-index: 2; 360 | margin-top: 4px; 361 | -webkit-animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 362 | animation: ball 0.45s cubic-bezier(0, 0, 0.15, 1) alternate infinite; 363 | margin-left: 7px; 364 | -webkit-animation-delay: .3s; 365 | animation-delay: .3s; 366 | } 367 | 368 | /*-------------------- 369 | Message Box 370 | --------------------*/ 371 | .message-box { 372 | -webkit-box-flex: 0; 373 | -ms-flex: 0 1 40px; 374 | flex: 0 1 40px; 375 | width: 100%; 376 | background: rgba(0, 0, 0, 0.3); 377 | padding: 10px; 378 | position: relative; 379 | } 380 | .message-box .message-input { 381 | background: none; 382 | border: none; 383 | outline: none !important; 384 | resize: none; 385 | color: rgba(255, 255, 255, 0.7); 386 | font-size: 11px; 387 | height: 40px; 388 | margin: 0; 389 | padding-right: 20px; 390 | width: 1200px; 391 | } 392 | textarea { 393 | font-family: sans-serif; /* 1 */ 394 | font-size: 100%; /* 1 */ 395 | line-height: 2; /* 1 */ 396 | margin: 0; /* 2 */ 397 | } 398 | .message-box textarea:focus:-webkit-placeholder { 399 | color: transparent; 400 | } 401 | .message-box .message-submit { 402 | position: absolute; 403 | z-index: 1; 404 | top: 9px; 405 | right: 10px; 406 | color: #fff; 407 | border: none; 408 | background: #248A52; 409 | font-size: 10px; 410 | text-transform: uppercase; 411 | line-height: 1.5; 412 | padding: 6px 10px; 413 | border-radius: 10px; 414 | outline: none !important; 415 | -webkit-transition: background .2s ease; 416 | transition: background .2s ease; 417 | } 418 | .message-box .message-submit:hover { 419 | background: #1D7745; 420 | } 421 | 422 | /*-------------------- 423 | Custom Srollbar 424 | --------------------*/ 425 | .mCSB_scrollTools { 426 | margin: 1px -3px 1px 0; 427 | opacity: 0; 428 | } 429 | 430 | .mCSB_inside > .mCSB_container { 431 | margin-right: 0px; 432 | padding: 0 10px; 433 | } 434 | 435 | .mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar { 436 | background-color: rgba(0, 0, 0, 0.5) !important; 437 | } 438 | 439 | /*-------------------- 440 | Bounce 441 | --------------------*/ 442 | @-webkit-keyframes bounce { 443 | 0% { 444 | -webkit-transform: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 445 | transform: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 446 | } 447 | 4.7% { 448 | -webkit-transform: matrix3d(0.45, 0, 0, 0, 0, 0.45, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 449 | transform: matrix3d(0.45, 0, 0, 0, 0, 0.45, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 450 | } 451 | 9.41% { 452 | -webkit-transform: matrix3d(0.883, 0, 0, 0, 0, 0.883, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 453 | transform: matrix3d(0.883, 0, 0, 0, 0, 0.883, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 454 | } 455 | 14.11% { 456 | -webkit-transform: matrix3d(1.141, 0, 0, 0, 0, 1.141, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 457 | transform: matrix3d(1.141, 0, 0, 0, 0, 1.141, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 458 | } 459 | 18.72% { 460 | -webkit-transform: matrix3d(1.212, 0, 0, 0, 0, 1.212, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 461 | transform: matrix3d(1.212, 0, 0, 0, 0, 1.212, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 462 | } 463 | 24.32% { 464 | -webkit-transform: matrix3d(1.151, 0, 0, 0, 0, 1.151, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 465 | transform: matrix3d(1.151, 0, 0, 0, 0, 1.151, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 466 | } 467 | 29.93% { 468 | -webkit-transform: matrix3d(1.048, 0, 0, 0, 0, 1.048, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 469 | transform: matrix3d(1.048, 0, 0, 0, 0, 1.048, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 470 | } 471 | 35.54% { 472 | -webkit-transform: matrix3d(0.979, 0, 0, 0, 0, 0.979, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 473 | transform: matrix3d(0.979, 0, 0, 0, 0, 0.979, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 474 | } 475 | 41.04% { 476 | -webkit-transform: matrix3d(0.961, 0, 0, 0, 0, 0.961, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 477 | transform: matrix3d(0.961, 0, 0, 0, 0, 0.961, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 478 | } 479 | 52.15% { 480 | -webkit-transform: matrix3d(0.991, 0, 0, 0, 0, 0.991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 481 | transform: matrix3d(0.991, 0, 0, 0, 0, 0.991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 482 | } 483 | 63.26% { 484 | -webkit-transform: matrix3d(1.007, 0, 0, 0, 0, 1.007, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 485 | transform: matrix3d(1.007, 0, 0, 0, 0, 1.007, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 486 | } 487 | 85.49% { 488 | -webkit-transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 489 | transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 490 | } 491 | 100% { 492 | -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 493 | transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 494 | } 495 | } 496 | @keyframes bounce { 497 | 0% { 498 | -webkit-transform: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 499 | transform: matrix3d(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 500 | } 501 | 4.7% { 502 | -webkit-transform: matrix3d(0.45, 0, 0, 0, 0, 0.45, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 503 | transform: matrix3d(0.45, 0, 0, 0, 0, 0.45, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 504 | } 505 | 9.41% { 506 | -webkit-transform: matrix3d(0.883, 0, 0, 0, 0, 0.883, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 507 | transform: matrix3d(0.883, 0, 0, 0, 0, 0.883, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 508 | } 509 | 14.11% { 510 | -webkit-transform: matrix3d(1.141, 0, 0, 0, 0, 1.141, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 511 | transform: matrix3d(1.141, 0, 0, 0, 0, 1.141, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 512 | } 513 | 18.72% { 514 | -webkit-transform: matrix3d(1.212, 0, 0, 0, 0, 1.212, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 515 | transform: matrix3d(1.212, 0, 0, 0, 0, 1.212, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 516 | } 517 | 24.32% { 518 | -webkit-transform: matrix3d(1.151, 0, 0, 0, 0, 1.151, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 519 | transform: matrix3d(1.151, 0, 0, 0, 0, 1.151, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 520 | } 521 | 29.93% { 522 | -webkit-transform: matrix3d(1.048, 0, 0, 0, 0, 1.048, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 523 | transform: matrix3d(1.048, 0, 0, 0, 0, 1.048, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 524 | } 525 | 35.54% { 526 | -webkit-transform: matrix3d(0.979, 0, 0, 0, 0, 0.979, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 527 | transform: matrix3d(0.979, 0, 0, 0, 0, 0.979, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 528 | } 529 | 41.04% { 530 | -webkit-transform: matrix3d(0.961, 0, 0, 0, 0, 0.961, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 531 | transform: matrix3d(0.961, 0, 0, 0, 0, 0.961, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 532 | } 533 | 52.15% { 534 | -webkit-transform: matrix3d(0.991, 0, 0, 0, 0, 0.991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 535 | transform: matrix3d(0.991, 0, 0, 0, 0, 0.991, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 536 | } 537 | 63.26% { 538 | -webkit-transform: matrix3d(1.007, 0, 0, 0, 0, 1.007, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 539 | transform: matrix3d(1.007, 0, 0, 0, 0, 1.007, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 540 | } 541 | 85.49% { 542 | -webkit-transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 543 | transform: matrix3d(0.999, 0, 0, 0, 0, 0.999, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 544 | } 545 | 100% { 546 | -webkit-transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 547 | transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); 548 | } 549 | } 550 | @-webkit-keyframes ball { 551 | from { 552 | -webkit-transform: translateY(0) scaleY(0.8); 553 | transform: translateY(0) scaleY(0.8); 554 | } 555 | to { 556 | -webkit-transform: translateY(-10px); 557 | transform: translateY(-10px); 558 | } 559 | } 560 | @keyframes ball { 561 | from { 562 | -webkit-transform: translateY(0) scaleY(0.8); 563 | transform: translateY(0) scaleY(0.8); 564 | } 565 | to { 566 | -webkit-transform: translateY(-10px); 567 | transform: translateY(-10px); 568 | } 569 | } 570 | 571 | 572 | 573 | 574 | 575 | 576 | -------------------------------------------------------------------------------- /Healthcare-chatbot-using-NLP-master/static/sound.js: -------------------------------------------------------------------------------- 1 | var synth = window.speechSynthesis; 2 | // get all voices that browser offers 3 | var available_voices = window.speechSynthesis.getVoices(); 4 | 5 | // this will hold an english voice 6 | var english_voice = ''; 7 | 8 | // find voice by language locale "en-US" 9 | // if not then select the first voice 10 | for(var i=0; i
' + 'I am your chatbot. Based on your symptoms here i predict your disease. And i also suggest analgesics,treatment scans,diet for that prediction disease.' + '').appendTo($('.mCSB_container')).addClass('new'); 52 | setDate(); 53 | updateScrollbar(); 54 | textToSpeech('I am your chatbot. Based on your symptoms here i predict your disease. And i also suggest analgesics,treatment scans,diet for that prediction disease.' ); 55 | }, 100); 56 | }); 57 | 58 | function updateScrollbar() { 59 | $messages.mCustomScrollbar("update").mCustomScrollbar('scrollTo', 'bottom', { 60 | scrollInertia: 10, 61 | timeout: 0 62 | }); 63 | } 64 | 65 | function setDate(){ 66 | d = new Date() 67 | if (m != d.getMinutes()) { 68 | m = d.getMinutes(); 69 | $('
' + d.getHours() + ':' + m + '
').appendTo($('.message:last')); 70 | } 71 | } 72 | 73 | function insertMessage() { 74 | msg = $('.message-input').val(); 75 | if ($.trim(msg) == '') { 76 | return false; 77 | } 78 | $('
' + msg + '
').appendTo($('.mCSB_container')).addClass('new'); 79 | setDate(); 80 | $('.message-input').val(null); 81 | updateScrollbar(); 82 | setTimeout(function() { 83 | $('
').appendTo($('.mCSB_container')); 84 | updateScrollbar(); 85 | 86 | 87 | fetch(`${window.origin}/entry`, { 88 | method: "POST", 89 | credentials: "include", 90 | body: JSON.stringify(msg), 91 | cache: "no-cache", 92 | headers: new Headers({ 93 | "content-type": "application/json" 94 | }) 95 | }) 96 | .then(function(response) { 97 | if (response.status !== 200) { 98 | console.log(`Looks like there was a problem. Status code: ${response.status}`); 99 | return; 100 | } 101 | response.json().then(function(data) { 102 | console.log(data); 103 | 104 | $('.message.loading').remove(); 105 | $('
' + data.name + '
').appendTo($('.mCSB_container')).addClass('new'); 106 | setDate(); 107 | updateScrollbar(); 108 | textToSpeech(data.name); 109 | 110 | 111 | }); 112 | }) 113 | .catch(function(error) { 114 | console.log("Fetch error: " + error); 115 | }); 116 | 117 | }, 1000 + (Math.random() * 20) * 100); 118 | } 119 | 120 | $('.message-submit').click(function() { 121 | insertMessage(); 122 | }); 123 | 124 | $(window).on('keydown', function(e) { 125 | if (e.which == 13) { 126 | insertMessage(); 127 | return false; 128 | } 129 | }) 130 | 131 | var Fake = [ 132 | 'Hi im your chatbot ', 133 | 'please enter your name ', 134 | 'Please Enter Your age', 135 | 'good.....What is your comfortable level for investment loss (in %) ', 136 | 'we are Predicting...
', 137 | 'great.. do you want to predict another? ', 138 | 'Bye', 139 | ':)' 140 | ] 141 | 142 | function fakeMessage() { 143 | msg = $('.message-input').val() 144 | if (msg != '') { 145 | return false; 146 | } 147 | $('
').appendTo($('.mCSB_container')); 148 | updateScrollbar(); 149 | 150 | setTimeout(function() { 151 | $('.message.loading').remove(); 152 | fetch(`${window.origin}/entry`, { 153 | method: "POST", 154 | credentials: "include", 155 | body: JSON.stringify(msg), 156 | cache: "no-cache", 157 | headers: new Headers({ 158 | "content-type": "application/json" 159 | }) 160 | }) 161 | .then(function(response) { 162 | if (response.status !== 200) { 163 | console.log(`Looks like there was a problem. Status code: ${response.status}`); 164 | return; 165 | } 166 | response.json().then(function(data) { 167 | console.log(data); 168 | $('
' + data.name + '
').appendTo($('.mCSB_container')).addClass('new'); 169 | setDate(); 170 | updateScrollbar(); 171 | 172 | 173 | }); 174 | }) 175 | .catch(function(error) { 176 | console.log("Fetch error: " + error); 177 | }); 178 | 179 | i++; 180 | }, 1000 + (Math.random() * 20) * 100); 181 | 182 | } 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | --------------------------------------------------------------------------------