Chatbotdoc
Chatbotdoc
on
Of
            BACHELOR OF TECHNOLOGY
                       IN
        COMPUTER SCIENCE AND ENGINEERING
                               Submitted by
   M.BHAVANI                                                       316129510061
   P.GAYATHRI                                                      316129510034
   G.NAVEEN KUMAR                                                  316129510016
   M.MOHANAPRIYA                                                   316129510032
                         Mrs. P.JYOTHI,M.tech
                            Assistant professor
 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
                               CERTIFICATE
    This is to certify that the project report entitled ―MAKING HEALTHCARE
                         CHATBOT USING NLP” Being
                                  submitted by
          M.BHAVANI                                               316129510061
          P.GAYATHRI                                              314129510034
          G.NAVEEN KUMAR                                          316129510016
          M.MOHANAPRIYA                                           316129510032
For partial fulfillment for the award of the degree Bachelor of Technology in
computer science and Engineering is a bonafide project work carried out by
her. This work is not submitted to any university for the award of B.Tech
degree.
                                                          M.BHAVANI (316129510061)
                                                         P.GAYATHRI (316129510034)
                                                    G.NAVEENKUMAR (316129510016)
                                                    M.MOHANAPRIYA (316129510032)
                                DECLARATION
                                                        M.BHAVANI (316129510061)
                                                       P.GAYATHRI (316129510034)
                                                 G.NAVEENKUMAR (316129510016)
                                                 M.MOHANAPRIYA (316129510032)
                                 ABSTRACT
                                                   Page No
1. INTRODUCTION                                          1
2. LITERATURE SURVEY 4
3. SYSTEM ANALYSIS 7
4. SYSTEM REQUIREMENTS 12
5. MODULE DESCRIPTION 57
6. SYSTEM DESIGN 58
6.3 Methodology 62
7. CODING 72
8. SYSTEM TESTING 75
8.1 Testing
9. SCREENSHOTS 78
10. CONCLUSION 87
12. REFERENCES                       89
                                     1. INTRODUCTION
           Now a days , health care is very important in our life. Today‘s people are busy with
their works at home, office works and more addicted to Internet. They are not concerned
about their health .So they avoid to go in hospitals for small problems. it may become a major
problem. So we can provide an idea is to create a health care Chabot system using AI that can
diagnosis the disease and provide basic information about the disease before consulting a
doctor. Which helps the patients know more about their disease and improves their health
User can achieve the all kind of disease information. The system application uses question and
answer protocol in the form of chatbot to answer user queries. The response to the question
will be replied based on the user query. The significant keywords are fetched from the
sentence and answer to those sentences. If match is discovered or significant answer will be
given or similar answers will be displayed. Bot will diagnosis which type of disease you have
based on user symptoms and also gives doctor details of particular disease.It may reduce their
health issues by using this application system. The system is developed to reduce the
healthcare cost and time of the users as it is not possible for the users to visit the doctors or
experts when immediately needed.
       Artificial Intelligence is based on how any device perceives its Environment and takes
actions based on the perceived data to achieve the result successfully. It is the study of
intelligent agents. The term "artificial intelligence" is applied when a machine mimics
"cognitive" functions that humans associate with other human minds, such as "learning" and
"problem solving. Artificial Intelligence gives the supreme power to mimic the human way of
thinking and behaving to a computer. A chatbot (also known as a talkbot, chatterbot, Bot,
IMbot, interactive agent, or Artificial(ConversationalEntity) is a computer        program which
conducts a conversation via auditory or textual methods. These programs are designed to
provide a clone of how a human will chat and thereby it acts as a conversational partner rather
than humans. For various practical purposes like customer service or information acquisition, ,
chatbot is being used in the dialog system. Mostly chatbots uses natural language processing
for interpreting the user input and generating the corresponding response but certain simpler
systems searches for the keyword within the text and then provides a reply based on the
matching keywords or certain pattern. Today, chatbots are part of virtual assistants such as
Google Assistant, and are accessed via many organizations' apps, websites, and on instant
                                                 1
messaging platforms. Non-assistant applications include chat bots used for entertainment
purposes, for    research, and social bots which promote a particular product, candidate, or
issue.
Chatbot‘s are such kind of computer programs that interact with users using natural
languages. For all kind of chat bots the flow is same, though each chatbot is specific in its
own area knowledge that is one input from human is matched against the knowledge base of
chatbot. Chatbot‘s work basically on Artificial intelligence so using this capability we have
decided to add some contribution to the Health Informatics.The high cost of our healthcare
system can often be attributed to the lack of patient engagement after they leave clinics or
hospitals. Various surveys in this area have proved that that chatbot can provide healthcare in
low costs and improved treatment if the doctors and the patient keep in touch after their
consultation. To answer the questions of the user chatbot is used. There is very less number of
chatbots in medical field.
The main purpose of the scheme is to build the language gap between the user and health
providers by giving immediate replies to the Questions asked by the user. Today‘s people are
more likely addicted to internet but they are not concern about their personal health. They
avoid to go in hospital for small problem which may become a major disease in future.
Establishing question answer forums is becoming a simple way to answer those queries rather
than browsing through the list of potentially relevant document from the web. Many of the
existing systems have some limitation such as There is no instant response given to the
patients they have to wait for experts acknowledgement for a long time. Some of             the
processes may charge amount to perform live chat or telephony communication with doctors
online.This system allows computer to communication between human to computer by using
natural language processing (NLP). There are three analyses which understand natural
language i.e. identification of main linguistic relations is completed to parse subject into
object of the sentences. After that Chatbot is an Entity which imitate human discussion in its
particular accepted set-up together with a text or vocal language with techniques such as
Natural Language Processing (NLP). The aim of this system is to replicate a person‘s
discussion. The development of chatbot application canbe done with making a user interface
to send input and receive response. It is a system that interact with user by keeping the track
of the state of interaction and recollecting the preceding commands to give functionality. The
medical chat-bots can be developed by using artificial algorithms that scrutinize user's queries
and recognize it and give reply to related query. A big disease can start from small problems
such as headache which feels normal but it may beginning of big disease such as brain tumor
                                               2
.most of the disease can be identified by common symptoms so the disease can be predicted if
the patient body is analyzed periodically[6].The system give response by use of an efficient
Graphical User Interface such that if actual person is chatting with the user. chatterbot that can
be used in various fields like education, healthcare, and route assistance[8]The central part of
the chat-bots includes MySQL. It is an interactive system solve users query regarding
medicine. so they can get correct guidance for treatment through android app by using Google
API.
Computers give us information; they engage us and help us in a lot of manners. A chatbot is a
program intended to counterfeit smart communication on a text or speech. Yet, this paper
concentrates only on text.
These systems can learn themselves and restore their knowledge using human assistance or
using web resources. This application is incredibly fundamental since knowledge is stored in
advance. The system application uses the question and answer protocol in the form of a
chatbot to answer user queries. This system is developed to reduce the healthcare cost and
time of the users, as it is not possible for the users to visit the doctors or experts when
immediately needed.
The response to the question will be replied based on the user query and knowledge base. The
significant keywords are fetched from the sentence and answer to those sentences. If the
match is discovered or the significant answer will be given or similar answers will be
displayed.
The complex questions and answers present in the database are viewed and answered by an
expert. Here the users can personally ask any questions regarding healthcare, as not much
time will be wasted by the user for consulting a doctor. The input sentence of the chat pattern
is stored in an RDBMS. The chatbot would coordinate the input sentence from the user
question with the knowledge base. Each query is compared with the knowledge database of
the chatbot. The important keywords are extracted from the given input sentence and the
sentence similarity is found. The keyword ranking and sentence similarity are found using the
N-gram, TF-IDF, and cosine .similarity. The interfaces are standalone built using the JAVA
programming language.
                                                3
                               2. LITERATURE REVIEW
           Simon Hoermann[1] discuss the current evidence for the feasibility and effectiveness
of online one-on-one mental health interventions that use text-based synchronous chat.
Synchronous written conversations (or ―chats‖) are becoming increasingly popular as Web-
based mental health interventions.This review is based on an evaluation of individual
synchronous Web-based chat technologies. Through the current evidence of the application of
this technology, the tentative support for mode of intervention is seen. Interventions utilizing
text-based synchronous communication showed better outcomes compared with Waitlist
conditions and overall equivalent outcomes compared with Treatment As usual, and were at
least as good as the comparison interventions. However, the issue of whether these
technologies are cost effective in clinical practice remains a consideration for future research
studies.
         Saurav Kumar Mishra[2] says that the chatbot will act as a virtual doctor and makes
possible for the patient to interact with virtual doctor. Natural language processing and pattern
matching algorithm for the development of this chatbot. It is developed using the python
Language. Based on the survey given it is found that the no of correct answer given by the
chatbot is 80% and incorrect/ambiguous answer given is 20%. From this survey of chatbot
and analysis of result suggested that this software can be used for teaching and as a virtual
doctor for awareness and primary care.
         DivyaMadhu[3] proposed an idea in which the AI can predict the diseases based on the
symptoms and give the list of available treatments If a person‘s body is analyzed periodically,
it is possible to predict any possible problem even before they start to cause any damage to the
body. Some Challenges are research and implementation costs, and government regulations
for the successful implementation of personalized medicine, they are not mentioned in the
paper.
         HameedullahKazi[4], describes the development of a chatbot for medical students, that
is based on the open source AIML based Chatterbean. The AIML based chatbot is customized
to convert natural language queries into relevant SQL queries. A total of 97 question samples were
collected and then those questions were divided into categories depending on the type of
question. According to the number of questions in each category the resultant categories were
ranked. Questions were based on quries, where 47% are of posed questions
                                                4
Other categories has less than 7%. The system has not been specially designed for the task of
supporting natural dialog in chatbots or, providing responses to student queries Banks
implement technology to strengthen their processing capacity, acquire a larger customer base
and expand the services they could offer (Consoli2005). The use of internet banking has
grown in demand enormously in the last decade. ―15% of branch customers use online
banking once a day, 59% once a week, 77% at least once a month and 53% were confident in
carrying out the best part of their banking online‖ Online banking has become more popular as
it negates the need for customers to visit their local branch as they can manage their finances
on the go to meet the demand of modern life. This is evident as branchless banks are now
emerging from the industry such as Atom Bank and many banks now closing some of their
branches. This is evident with the recent closure of 11 Ulster Bank Branches in NI due to the
increased number of customers performing their banking online (The Belfast Telegraph).
recent study by Ling et al., (2016), notes that most internet banking service providers struggle
to get many of their customers to use their service. They identify lack of customer satisfaction
when using online banking services to be a major cause. ―Service quality, web design and
content, security, privacy, speed and convenience‖ (Ling et al., 2016) are as the top factors
influencing customer satisfaction This suggests that there is a lack of technology in place to
enhance the customer online banking experience which could be improved by integrating a
chatbot to provide an efficient, convenient and personal service
   Most businesses and organizations are understanding the potential benefits of machine
learning and artificial intelligence to have a positive change on how they perform business.
Artificial intelligence has progressed to allow the development of more sophisticated chatbots.
Organizations are focusing on specific areas of user engagement that take up a lot of time but
can be replaced through the use of a chatbot. Chatbots can understand what the customer
needs from a single text instead of the customer having to follow a process of multiple steps.
Chatbots are used to automate customer service and reduce manual tedious tasks performed
by employees so they can spend their time more productively on higher priority tasks.
   Most online banking services would benefit from having a chatbot integrated into their
services. The uses of bots help internet banking service providers establish a better
relationship with its customers. Customers can get answers to query‘s immediately, conduct
e-commerce and banking operations all from within the one bot conversation. This is another
                                               5
benefit of using an online banking system with and integrated chatbot as ―87% customers that
bank online prefer to execute their personal finance operations within a single site‖ (Dauda, et
al., 2015).
WHAT IS CHATBOT?
          In general terms, a bot is nothing but a software that will perform automatic tasks.
In other terms, a bot is a computer program that is designed to communicate with human users
through the internet. The most natural definition of a chatbot is – a developed a program that
can have a discussion/conversation with a human.For example, any user could ask the bot an
inquiry or a statement,and the bot will respond or perform an activity as appropriate chatbot
interacts on a format similar to instant messaging.By artificially replicating the patterns of
human interactions in machine learning allows computers to learn by themselves without
programming natural language processing. While a bot is a computer‘s ability to understand
human speech or text short for chat robot. A chatbot is merely a computer program that
fundamentally simulates human conversations. It allows a form of interaction between a
human and a machine the communication,which happens via messages or voice command.A
chatbot is programmed to work independently from a human Operator.It can answer questions
formulated to it in natural language and Respond like a real person.It provides responses
based on a combination of predefined scripts and machine learning applications.When it is
asked a question, the chatbot will respond based on the knowledge database available to it at
that point in time. If the conversation introduces a concept it is not programmed to
understand, it will either deflect the conversation or potentially pass the Communication to a
human operator.Either way, it will also learn from that interaction as well as from future
interactions.Thus, the chatbot will gradually grow in scope and gain relevance.
          Enter chatbot, healthcare chatbots are software integrated into either a website or
mobile app and possess any combination of the following attributes:
    Natural language processing :The ability for a chatbot or other form of artificial
intelligence to understand aspects of human language including syntax and semantics from
users of various backgrounds.
    Contextual AI: contextual AI takes into consideration the intent of the user as they ask
questions and submit responses, thus ensuring the best relevant conversation takes place.
                                               6
Chatbot Architecture
   Previously chat bots solely supported a single adjacency pair, also known as a
one-shot conversation. However, modern chatbots can sustain multiple adjacency
pairs, remembering states and contexts between conversations and have the
capability to associate data in different adjacency pairs which is related. This is the
bots ability to preserve the conversation. A chatbot consists of four main parts:
front- end, knowledge-base, back-end and corpus which is the training data. The
front end is accountable for enabling communication between the bot and the user.
The NLU utilises Artificial intelligence methods to identify the intent and context
of the user input. An appropriate response is generated from the users‘ intent. The
knowledge base defines the chatbot knowledge, which is created within the NLU
and supported by the back-end, the back-end applies the domains corpus to
produce the knowledge base. Input can be supplied to the chatbot in the form of
text or speech. The Input is sent to the dialog management system which is the
NLU in this case, which determines an appropriate response and amends the
chatbots state accordingly to carry out the required action. The chatbot will
produce text and speech responses in the form of both text and speech.
                                                 7
                             3. SYSTEM ANALYSIS
                                               8
Here they use n-gram technique for extracting the words from the sentences. Here n-gram is
used for comparison and deduction of the input with case data using Moro phonemes and
phonemes as the deciding parameter. Probability analysis for the closest match is performed.
The final expression is redirected through an expert system. [5]
   The chatbot developed here for healthcare purposes for the android application. The user
sends the text message or voice message using Google API. Here the user gets only related
answer from the chatbot. SVM algorithm is used to classify the dataset. Here the Porter
algorithm is used to discard unwanted words like suffixes or prefixes. [6]
   The different documents served in web, the content is checked by tagging the dataset
using n-gram based low dimensional demonstration, TF-IDF matrix that generates S, U, and
V and finally multiplying the 3 matrices cosine similarity is calculated. [7]
    Here the chatbot is created for the customer service that functions as public health
service. The application uses N- gram, TF-IDF and cosine similarity. The knowledge base is
created for storing the question and answer. The application clearly shows extracted the
keyword from the question ad by using unigram, bigram, and trigram which helps in fast
answering. [8]
       Here says that the chatbot will act as a virtual doctor and makes possible for the patient
to interact with virtual doctor. Natural language processing and pattern matching algorithm
for the development of this chatbot. It is developed using the python Language. Based on the
survey given it is found that the no of correct answer given by the chatbot is 80% and
incorrect/ambiguous answer given is 20%.From this survey of chatbot and analysis of result
suggested that this software can be used for teaching and as a virtual doctor for awareness
and primary care.
Disadvantages in Existing system:
3.2PROPOSED SYSTEM:
The proposed system provides a text-to- text(or) voice conversational agent that asks the user
about their health issue .The user can chat as if chatting with a human. The bot then ask the
user a series of questions about their symptoms to diagnose the disease. It gives suggestions
about the different symptoms to clarify the disease. Based on the reply from the user the
accurate disease is found and it suggests the doctor who needs to be consulted in case of major
                                                 9
disease. The system remembers past responses and asks progressively more specific questions
in order to obtain a good diagnosis.
      In our proposed system the user can chat with the bot regarding the query through
       voice or text.
      The system uses an expert system to answer the queries
      User can also view the available doctors and booking appointments for that particular
       disease.
      This system can be used by the multiple users to get the counselling sessions online.
      The data of the chatbot stored in the database in the form of pattern-template.
      Bot will provide analgesics and food suggestions that means which food you have to
       take based on the disease
       Advantages in proposed system:
3.3FEASIBILITY STUDY
           The feasibility of the project is analyzed in this phase and business proposal is put
forth with a very general plan for the project and some cost estimates. During system analysis
the feasibility study of the proposed system is to be carried out. This is to ensure that the
proposed system is not a burden to the company. For feasibility analysis, some understanding
of the major requirements for the system is essential.
    Three key considerations involved in the feasibility analysis are
        ECONOMICAL FEASIBILITY
        TECHNICAL FEASIBILITY
        SOCIAL FEASIBILITY
                                               10
            This study is carried out to check the economic impact that the system will have
on the organization. The amount of fund that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus the developed
system as well within the budget and this was achieved because most of the technologies used
are freely available. Only the customized products had to be purchased.
    The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
users solely depends on the methods that are employed to educate the user about the system
and to make him familiar with it. His level of confidence must be raised so that he is also able
to make some constructive criticism, which is welcomed, as he is the final user of the system.
                                              11
                          4. SYSTEM REQUIREMENTS
         Python is the popular programming language. In-fact you will see the code
of python language as English language. Python 2 and Python 3 are the two major
versions of Python. But , Python Installation for both the versions are different. In
addition ,Commands and path environment variables for both the versions are
different. You can choose your python version according to your requirement.
Beginners always faces challenges of installing Python in their operating system.
                                              12
‗ABC‘. It‘s first version was released in 1991. The name Python was picked by
Guido van Rossum from a TV show named Monty Python‘s Flying Circus. It is an
open source programming language which means that we can freely download it and
use it to develop programs. It can be downloaded from www.python.org.. Python
programming language is having the features of Java and C both. It is having the
elegant ‗C‘ code and on the other hand, it is having classes and objects like Java for
object-oriented programming. It is an interpreted language, which means the source
code of Python program would be first converted into bytecode and then executed by
Python virtual machine.
     You make sure to install python carefully by reading all the steps described
here otherwise it may be wrongly install.Python Installation Tutorial for Windows
In this section, you will know how to do Python installation in the Windows OS.
First we will cover for the latest Python 3 version and then Python 2 version. You
can either install both the versions or choose the version according to your end goal.
Python Features
Python is a dynamic, high level, free open source and interpreted programming
language. It supports object-oriented programming as well as procedural oriented
programming.
In Python, we don‘t need to declare the type of variable because it is a dynamic typed
language.
Forexample,x=10
here x can be anything such as String, int etc.
Features in Python
There are many features in Python, some of which are discussed below –
1.Easytocode:
Python is high level programming language.Python is very easy to learn language as
                                                  13
compared to other language like c, c#, java script, java etc.It is very easy to code in
python language and anybody can learn python basic in few hours or days.It is also
developer-friendly language.
2.FreeandOpenSource:
Python language is freely available at official website and you can download it from
the given download link below click on the Download Python keyword.
Since, it is open-source, this means that source code is also available to the public. So
you can download it as, use it as well as share it.
3.Object-OrientedLanguage:
One of the key features of python is Object-Oriented programming. Python supports
object oriented language and concepts of classes, objects encapsulation etc.
4.GUIProgrammingSupport:
Graphical Users interfaces can be made using a module such as PyQt5, PyQt4,
wxPython (or)Tk in python.PyQt5 is the most popular option for creating graphical
apps with Python.
5.High-LevelLanguage:
Python is a high-level language.When we write programs in python, we do not need
to remember the system architecture, nor do we need to manage the memory.
6.Extensiblefeature:
Python is a Extensible language.we can write our some python code into c or c++
language and also we can compile that code in c/c++ language.
7.PythonisPortablelanguage:
Python language is also a portable language.for example, if we have python code for
windows and if we want to run this code on other platform such as Linux, Unix and
Mac then we do not need to change it, we can run this code on any platform.
8.PythonisIntegratedlanguage:
Python is also an Integrated language because we can easily integrated python with
other language like c, c++ etc.
9.InterpretedLanguage:
Python is an Interpreted Language. because python code is executed line by line at a
                                                14
time. like other language c, c++, java etc there is no need to compile python code this
makes it easier to debug our code.The source code of python is converted into an
immediate form called bytecode.
10.LargeStandardLibrary
Python has a large standard library which provides rich set of module and functions
so you do not have to write your own code for every single thing.There are many
libraries present in python for such as regular expressions, unit-testing, web browsers
etc.
11.DynamicallyTypedLanguage:
Python is dynamically-typed language. That means the type (for example- int,
double, long etc) for a variable is decided at run time not in advance. because of this
feature we don‘t need to specify the type of variable.
Applications of Python
 Software Development
 Education
 Database Access
 Network Programming
Python lets you develop a web application without too much trouble. It has libraries
for internet protocols like HTML and XML, JSON, e-mail processing, FTP, IMAP,
and easy-to-use socket interface. Yet, the package index has more libraries:
                                               15
      Requests – An HTTP client library
Most binary distributions of Python ship with Tk, a standard GUI library. It lets you
draft a user interface for an application. Apart from that, some toolkits are available:
 wxWidgets
 GTK+
 Delphi
This is one of the very common applications of Python programming. With its
power, it comes as no surprise that Python finds its place in the scientific community.
For this, we have:
      IPython – A powerful shell for easy editing and recording of work sessions.
       It also supports visualizations and parallel computing.
                                                16
4. Software Development
Software developers make use of Python as a support language. They use it for build-
control and management, testing, and for a lot of other things:
5. Education
Thanks to its simplicity, brevity, and large community, Python makes for a great
introductory programming language. Applications of Python programming in
education has a huge scope as it is a great language to teach in schools or even learn
on your own.
6. Business
7. Database Access
8. Network Programming
                                              17
With all those possibilities, how would Python slack in network programming? It
does provide support for lower-level network programming:
Safe to say, this one is the most interesting. When people hear someone say they‘re
learning Python, the first thing they get asked is – ‗So, did you make a game yet?‘
PyGame, PyKyra are two frameworks for game development with Python. Apart
from this, we also get a variety of 3D-rendering libraries.
The IT industry went far beyond the science fiction ideas and our future is moving
towards Artificial Intelligence. People are keen to move to technologies where
machines can mimic human behaviours and most of the human work is being
automated by machines. There is also a need to process and analyze huge volumes of
data.
Statistically speaking that Python is the most popular language for Artificial
intelligence and Machine Learning.
The several libraries and frameworks for Artificial intelligence are listed below.
 Tensorflow
 Scikit-learn
 NLTK
 Caffee
 PyTorch
 Keras
 Pandas
 Accord.NET
                                               18
11. Prototyping
Programming in Python is easy when you compare it with other languages. It has
easy syntax and it offers concise solutions for implementing all types of
functionalities. This is the main reason why Python can be applied in prototyping
stages of software development.
Although it is tough for a normal person to believe that programming languages like
Python are important in healthcare. There‘s not only one reason that makes python in
the limelight of healthcare. There are a number of reasons which make Python an
important asset for the ones researching in the healthcare department.
                                                19
Before moving ahead in Python in Healthcare article, read a little about Python
Frameworks that are Django and Flask.
Its trustworthy modules are so effective that you don‘t need to develop them by
yourself. Also, the built-in maintenance against the web-app attack adds to its utility.
Django framework allows developers to meet their requirements of any business idea
related to eHealth or telemedicine projects.
There is also Flask, again a Python-based framework often used for building
prototypes because of its great efficiency and can be extended to the full-stack
framework with existing extensions. Its uses are still less than that of Django because
it requires more time for configuration.
 Below are some important reasons for using Python in Healthcare sector, have a
 look
                                               20
   1. Python and its frameworks work on principles that are grounded equally and
       agreed upon the HIPAA checklist.
   2. A full look at the big data healthcare allows the organization to exchange
       information for seeking patient outcomes.
 Roam Analysis
According to the official description, ―Roam‘s machine learning and data platform
powers rich analysis of patient journeys to reveal the factors affecting treatment
decisions and outcomes.‖
 AiCure
It is an NIH and VC-funded healthcare startup in New York. AiCure automates the
process of ensuring that patients are taking their medicines, that too at their assigned
time. It has combined artificial intelligence and mobile technology together.
For example, it uses computer vision to identify the patient (face recognition) and
verify the right pill for the specific patient (using pill recognition) and they are
actually consuming them (action recognition). They develop their backend
applications using Django frameworks and use python base coding and research
engineers to develop it.
Amazed by the magic of Python in Healthcare? Here are some more startups –
 Drchrono
                                               21
It is a software as a service patient care platform that consists of a web and cloud-
based app. This American company is for doctors and patients that make electronic
health records available digitally and provides management and medical billing
services. This is also a phone and web concentrated platform.
 Fathom Health
Again a Healthcare startup with deep learning NLP system for reading and
understanding electronic health records. This startup with headquarters in San
Francisco, California is backed up by Google. Their employees are familiar with
Flask for API programming and data engineers prefer Python‘s NLTK.
Python Installation:
If the binary code for your platform is not available, you need a C compiler to compile the
source code manually. Compiling the source code offers more flexibility in terms of choice
of features that you require in your installation.
                                                22
Here the above screen is for searching python download in Google.
                                            23
After clicking downloads we get python releases for windows.
For downloading python 2.7.15, we have to download Windows x86-64 MSI installer.
                                            24
After downloading we have to install python 2.7.15.
                                             25
Selecting destination directory.
                                        26
After installing click on finish.
                                    27
Here after installing the Python we have to set the specific path of it for the further process.
For setting the path we go to the advanced settings in the system by clicking windows+r.
Here we have the ability to set the path.
 We have clicked on the Advanced to set the path for the further process. Here in the
advances the settings can be changed to set the path of the specific version that is been
installed and been using in our systems.
                                               28
In the Advances settings we click on the Environmental Variables we get the System
Variables. Where the path is allowed to set. In the System Variables we have to click on edit
to set the path of the specific system that is been using in our systems.
                                                29
Here in the System variables we can see the path data where it has to be edited. We have to
click on the path settings to edit the path and further click on OK to continue.
                                               30
Fig: Selecting the path of the Python
                 31
Here in this screen we can see the edit option where the path is to be set. We have to click on
the NEW to set the path that is copied and should be pasted in the new row. The path of the
Python is been copied in the new row.
                                              32
Here in this screen we can see the edit option where the path is to be set. We have to click on
the NEW to set the path that is copied and should be pasted in the new row. The path of the
Script is been copied in the new row.
                                              33
  Fig: The path of the Script that is been pasted successfully
                               34
  Here the version of the Python is been shown in the command prompt by entering the word
Python in the cmd. It further shows the version that is been installed and used in the systems
for our project.
For installing the library file named numpy we have to type ―pip install numpy‖ and press
enter. It further installs all the library files and functions that are needed to run the file.
                                                  35
                          Fig: The successful installation of numpy
Here we can see the successful installation of the numpy library files that are been installed
by using the command ―pip install numpy‖ in the command prompt.
                                              36
         Here the library files of the pandas are needed to be installed by writing the
command as ―pip install pandas‖ in the command prompt where it installs all the related
library files of the pandas for the project that are needed and for the further process.
                                                37
Pandas in python
    Pandas is an open-source, BSD-licensed Python library providing high-performance,
easy-to-use data structures and data analysis tools for the Python programming language.
Python with Pandas is used in a wide range of fields including academic and commercial
domains including finance, economics, Statistics, analytics, etc.In this tutorial, we will learn
the various features of Python Pandas and how to use them in practice.Pandas is an open-
source Python Library providing high-performance data manipulation and analysis tool using
its powerful data structures. The name Pandas is derived from the word Panel Data – an
Econometrics from Multidimensional data.
In 2008, developer Wes McKinney started developing pandas when in need of high
performance, flexible tool for analysis of data.Prior to Pandas, Python was majorly used for
data munging and preparation. It had very little contribution towards data analysis. Pandas
solved this problem. Using Pandas, we can accomplish five typical steps in the processing
sand analysis of data, regardless of the origin of data — load, prepare, manipulate, model,
and analyze.Python with Pandas is used in a wide range of fields including academic and
commercial domains including finance, economics, Statistics, analytics, etc.
 Fast and efficient DataFrame object with default and customized indexing.
 Tools for loading data into in-memory data objects from different file formats.
Standard Python distribution doesn't come bundled with Pandas module. A lightweight
alternative is to install NumPy using popular Python package installer, pip
                                                38
If you install Anaconda Python package, Pandas will be installed by default with the
following −
Windows
       Anaconda (from https://www.continuum.io) is a free Python distribution for SciPy
        stack. It is also available for Linux and Mac.
       Python (x,y) is a free Python distribution with SciPy stack and Spyder IDE for
        Windows OS. (Downloadable from http://python-xy.github.io/)
Linux
Package managers of respective Linux distributions are used to install one or more packages
in SciPy stack.
python-nose atlas-devel
 Series
 DataFrame
 Panel
These data structures are built on top of Numpy array, which means they are fast.
                                               39
   Data           Dimensions                              Description
 Structure
Building and handling two or more dimensional arrays is a tedious task, burden is placed on
the user to consider the orientation of the data set when writing functions. But using Pandas
data structures, the mental effort of the user is reduced.
For example, with tabular data (DataFrame) it is more semantically helpful to think of
the index (the rows) and the columns rather than axis 0 and axis 1.
Mutability
All Pandas data structures are value mutable (can be changed) and except Series all are size
mutable. Series is size immutable.
Note − DataFrame is widely used and one of the most important data structures. Panel is
used much less.
Series
Series is a one-dimensional array like structure with homogeneous data. For example, the
following series is a collection of integers 10, 23, 56, …
10 23 56 17 52 61 73 90 26 72
Key Points
        Homogeneous data
        Size Immutable
        Values of Data Mutable
DataFrame
DataFrame is a two-dimensional array with heterogeneous data. For example,
                                                40
        Name                 Age                   Gender                     Rating
The table represents the data of a sales team of an organization with their overall
performance rating. The data is represented in rows and columns. Each column represents an
attribute and each row represents a person.
Column Type
Name String
Age Integer
Gender String
Rating Float
Key Points
       Heterogeneous data
       Size Mutable
       Data Mutable
Panel
Panel is a three-dimensional data structure with heterogeneous data. It is hard to represent the
panel in graphical representation. But a panel can be illustrated as a container of DataFrame.
                                              41
Key Points
         Heterogeneous data
         Size Mutable
         Data Mutable
Series is a one-dimensional labeled array capable of holding data of any type (integer, string,
float, python objects, etc.). The axis labels are collectively called index.
pandas.Series
A pandas Series can be created using the following constructor −
1 Data
2 Index
3 Dtype
4 Copy
         Array
         Dict
         Scalar value or constant
                                                 42
FLASK:
    Flask is a web framework. This means flask provides you with tools, libraries and
technologies that allow you to build a web application. This web application can be some web
pages, a blog, a wiki or go as big as a web-based calendar application or a commercial
website.Flask is part of the categories of the micro-framework. Micro-framework are
normally framework with little to no dependencies to external libraries. This has pros and
cons. Pros would be that the framework is light, there are little dependency to update and
watch for security bugs, cons is that some time you will have to do more work by yourself or
increase yourself the list of dependencies by adding plugins.Flask is a lightweight WSGI web
application framework. It is designed to make getting started quick and easy, with the ability
to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja
and has become one of the most popular Python web application frameworks.Flask offers
suggestions, but doesn't enforce any dependencies or project layout. It is up to the developer
to choose the tools and libraries they want to use. There are many extensions provided by the
community that make adding new functionality easy.
    Flask is considered more Pythonic than the Django web framework because in common
situations the equivalent Flask web application is more explicit. Flask is also easy to get
started with as a beginner because there is little boilerplate code for getting a simple app up
and running.
Install Flask
Within the activated environment, use the following command to install Flask:
HTML:
       HTML stands for Hypertext Markup Language. It allows the user to create and
structure sections, paragraphs, headings, links, and blockquotes for web pages and
applications.HTML is not a programming language, meaning it doesn‘t have the ability to
create dynamic functionality. Instead, it makes it possible to organize and format documents,
similarly to Microsoft Word.When working with HTML, we use simple code structures (tags
and attributes) to mark up a website page. For example, we can create a paragraph by placing
the enclosed text within a starting <p> and closing </p> tag.
                                              43
The History of HTML
       HTML was invented by Tim Berners-Lee, a physicist at the CERN research institute
in Switzerland. He came up with the idea of an Internet-based hypertext system.Hypertext
means a text that contains references (links) to other texts that viewers can access
immediately. He published the first version of HTML in 1991, consisting of 18 HTML tags.
Since then, each new version of the HTML language came with new tags and attributes (tag
modifiers) to the markup.According to Mozilla Developer Network‘s HTML Element
Reference, currently, there are 140 HTML tags, although some of them are already obsolete
(not supported by modern browsers).Due to a quick rise in popularity, HTML is now
considered an official web standard. The HTML specifications are maintained and developed
by the World Wide Web Consortium (W3C). You can check out the latest state of the
language anytime on W3C‘s website.The biggest upgrade of the language was the
introduction of HTML5 in 2014. It added several new semantic tags to the markup, that
reveal the meaning of their own content, such as <article>, <header>, and <footer>.
       HTML documents are files that end with a .html or .htm extension. You can view then
using any web browser (such as Google Chrome, Safari, or Mozilla Firefox). The browser
reads the HTML file and renders its content so that internet users can view it.
       Usually, the average website includes several different HTML pages. For instance:
home pages, about pages, contact pages would all have separate HTML documents.
       Each HTML page consists of a set of tags (also called elements), which you can refer
to as the building blocks of web pages. They create a hierarchy that structures the content
into sections, paragraphs, headings, and other content blocks.
HTML :HTML stands for Hyper Text Markup Language.HTML describes the structure of
web pages using mark up .
                                              44
<b> :-Forbolding or otherwise styling text without conveying any additional meaningsuch as
with <em> and <strong> etc.,
<li>:- This represents a list item with an <ol> or <ul>.<meta>:-Used for specifying various
meta information about the document.
                                              45
<select>:- Used with <option> for selecting a particular option.
<u>:- Useful for annotating text for various reasons.no longer specifically for
underlining.
       Cascading Style Sheets (CSS) is a style sheet language used for describing the
presentation of a document written in a markup language like HTML.[1] CSS is a
cornerstone technology of the World Wide Web, alongside HTML and JavaScript.CSS is
designed to enable the separation of presentation and content, including layout, colors, and
fonts.[3] This separation can improve content accessibility, provide more flexibility and
control in the specification of presentation characteristics, enable multiple web pages to share
formatting by specifying the relevant CSS in a separate .css file, and reduce complexity and
repetition in the structural content.Separation of formatting and content also makes it feasible
to present the same markup page in different styles for different rendering methods, such as
on-screen, in print, by voice (via speech-based browser or screen reader), and on Braille-
based tactile devices. CSS also has rules for alternate formatting if the content is accessed on
a mobile device.The name cascading comes from the specified priority scheme to determine
which style rule applies if more than one rule matches a particular element. This cascading
priority scheme is predictable.
                                              46
CSS:-CSS stands for Cascading Style Sheet.CSS describes how Html elements are to be
displayed on screen ,paper ,or in other media.
Font Properties :-
Font-Family :-Changes the font family of certain words, sentences, paragraphs, etc.
Text Properties :-
 Vertical-Align :-Used to alter the vertical positioning of an inline element, relative to its
 parent element or to the element's line.
 Text-Transform :-Allows for capitalizing the first letter of each word (capitalize),
 capitalizing all letters of a word(uppercase), using all small letters in each word(lowercase),
 and the initial value(none).
Text-Indent :-Used to specify the amount of indentation prior to the first line of text.
                                                 47
Background-Color :-Sets the background color of an element.
Box Properties :-
Margin :-Sets the margins of an element by specifying top, bottom, left and right margins --
all either specifying length or percentage.
Padding-Top :-Describes the amount of space between the top border and the content of the
selector.
Padding-Right :-Describes the amount of space between the right border and the content of
the selector.
Padding-Bottom :-Describes the amount of space between the bottom border and the
content of the selector.
padding-Left :-Describes the amount of space between the left border and the content of the
selector.
                                                 48
Border-Width :-Used to set the width of an element's border (either all borders, or
specifying top border, right border, bottom border, left border).
Border-Radius:-Sets all the four border. Radius properties for rounded conrners.
Height :-Each block-level or replaced element can be given a height, specified as a length or
as auto.
Clear :-Specifies whether an element allows floating elements to its sides (left, right, none).
Transition:-CSS transitions allow you to change property values smoothly ,over a given
duration.
BOOTSTRAP :-Bootstrap is the most popular HTML, CSS, and javascript framework for
faster and easier web development.
.col-* :- This class is used for grid columns to determine the column width and the
breakpoint you would like it to be active. The classes work from the breakpoint you set and
everything larger.
.d-print-* :- Changes the display of elements when you print the document.
.fixed-* :- This class makes an element fixed to the top/bottom of the browser window. Here
is what the CSS ruleset looks like.
.form-control-plaintext :- Use the class to remove the default form field styling and
preserve the correct margin and padding.
.form-row :- Works similar to a grid. but is more compact to make the form look more
uniform.
                                              49
.nav-fill :- Makes all nav items use all available horizontal space. Nav items are different
widths based on their content
.nav-justified :- Makes all nav items equal width and use all available horizontal space.
.navbar-collapse :- The nav links that are collapsed and shown when toggled on mobile
widths.
.navbar-expand-* :- Since the navbar is displayed collapse on mobile first, this class
specifies what breakpoint you want the navbar to not be collapsed
.form-inline :- Use this class to have a series of labels and form elements on a single
horizontal row
.form-text :- This class is used for help text alongside form elements. You can add .text-
muted to make the text lighter in color
.input-group-text :- This class adds the background color and text styles to the text inside an
input group
.list-inline :- Change ul or ol list to be listed horizontally with a little margin between each li
.media-left :- Add this class the div wrapping the media object image to align it to the left
.nav-item :- If your nav uses a list add this class to each list item for the proper spacing
.nav-link :- Each anchor link inside your nav is given this class in order to have the proper
styling
.navbar-light :- Add this class to your navbar if you would like it to have a light background
and dark text
                                                50
.position-* :- Not responsive, but a group of utility classes to add common position values.
.position-(absolute, fixed, relative, static, sticky)
.container :- Fixed width container with widths determined by screen sites. Equal margin on
the left and right
.media :- Media components are image heading and description text items. Blog comments,
portfolio projects, album covers, etc.
.modal-header :- The header section of the modal that contains the title and close button
.navbar-brand :- Most navbars contain a logo or brand. This class is added to the anchor.
.navbar-nav :- The wrapper class of the navigation elements excluding the brand.
.align:- A set of utility classes that are equivalent to writing the css property. You can use
this on inline and table cell elements.
.align-content:- Added to the parent flexbox container to determining how the elements are
aligned horizontally.
.border:- A versatile border utility class that lets you add/remove borders on a side or
change a border color.
.carousel-control:- When you have an image carousel with pagination you will use this class
on the previous and next anchor links.
.justify-content:- Class specifies where the flex items will be positioned inside the container.
.navbar-justified:- Makes all nav items equal width and use all available horizontal space.
                                               51
.navbar-text:- Vertically centres text inside a navbar.
.display:- The set of classes increases the font size of headings in 4 stages. These classes are
used for headings outside of the main content of the page like page headers.
.dropdown-item:- This class is added to each link item shown in a dropdown menu.
.form-text:- This class is used for help text alongside form elements. You can add .text-
muted to make the text lighter in color.
.container:- Fixed width container with widths determined by screen sites. Equal margin on
the left and right.
JAVA Script:
Event Description
                                               52
onmouseout      The user moves the mouse away from an HTML element
Methods Description
concat() Joins two or more strings, and returns a new joined strings
repeat() Returns a new string with a specified number of copies of an existing string
replace()          Searches a string for a specified value, or a regular expression, and returns a
new string where the specified values are replaced.
search()         Searches a string for a specified value, or regular expression, and returns the
position of the match.
                                                53
Array Methods
concat() Joins two or more arrays, and returns a copy of the joined arrays
find() Returns the value of the first element in an array that pass a test
keys() Returns a Array Iteration Object, containing the keys of the original array
pop() Removes the last element of an array, and returns that element
push() Adds new elements to the end of an array, and returns the new length
shift() Removes the first element of an array, and returns that element
unshift() Adds new elements to the beginning of an array, and returns the new length
Date functions
Method Description
PHP:- PHP is a server scripting language, and a powerful tool for making dynamic and
interactive web pages.
 include():-It is used to insert the contentof one PHP file into another PHP file. If   will only
 produce a warning(E_WARNING) and the script will continue.
                                                 54
Session _start():-A session is started with the session _start() function.
date():-It is a function that formats a timestamp to a more readable date and time.echo():-
This function outputs one or more strings.
while(): -The while loop execute a block of code while the specified condition is true.
 mysqli_ error():-This function returns the last error description for the most recent function
 call ,if any.
ob_ start():-Turn on output buffering and no output is sent from the script.
mysqli_ fetch_ assoc :-This function fetches a result row as an associative array.
 $_POST[]:- It is widely used to pass variables and to collect from data after submitting an
 HTML form with method=‖post‖.
 $_GET[]:- It is used to collect from data after submitting an HTML form with
 method=‖get‖ and also collect data sent in the URL.
mysqli_ num_ rows():-This function returns the number of rows in a result set.
                                                   55
unset():-The function unset only local variable and it does not return any values.
ob_ end_ flush():-This function flush(send) the output bufferand turn off output buffering.
substr():-It returns the portion of string specified by the start and length parameters.
md5:-This function calculates the MD5 hash of str and returns that hash.
Bind-param():-This function binds the parameters to the SQL query and tells the database
what the parameters are.
                                                56
                          5. MODULE DESCRIPTION
PROJECT MODULES:
The validation of the user login details occurs here. Then Symptoms are extracted using
String Searching Algorithm where substring representing the symptoms is identified in the
natural language text input. When users give directly the symptom name such as(e.g. ―I have
cough, fever, and nausea‖), the system will easily identify it. But however, the system
should also be able to handle input like, ―When I read, I‘m okay at first, but over time, my
eyes seem to get tired, and I start to see double.‖ In this case, the system should extract
substrings like ―eyes tired‖ and ―see double‖ (and not substrings like ―read‖ or ―okay‖).
                                              57
                                           6. SYSTEM DESIGN
INPUT DESIGN
    The input design is the link between the information system and the user. It comprises the
developing specification and procedures for data preparation and those steps are necessary to
put transaction data in to a usable form for processing can be achieved by inspecting the
computer to read data from a written or printed document or it can occur by having people
keying the data directly into the system. The design of input focuses on controlling the
amount of input required, controlling the errors, avoiding delay, avoiding extra steps and
keeping the process simple. The input is designed in such a way so that it provides security
and ease of use with retaining the privacy. Input Design considered the following things:
OBJECTIVES
1.Input Design is the process of converting a user-oriented description of the input into a
computer-based system. This design is important to avoid errors in the data input process and
show the correct direction to the management for getting correct information from the
computerized system.
2. It is achieved by creating user-friendly screens for the data entry to handle large volume of
data. The goal of designing input is to make data entry easier and to be free from errors. The
data entry screen is designed in such a way that all the data manipulates can be performed. It
also provides record viewing facilities.
3. When the data is entered it will check for its validity. Data can be entered with the help of
screens. Appropriate messages are provided as when needed so that the user
will not be in maize of instant. Thus the objective of input design is to create an input layout
that is easy to follow
                                              58
OUTPUT DESIGN
    A quality output is one, which meets the requirements of the end user and presents the
information clearly. In any system results of processing are communicated to the users and to
other system through outputs. In output design it is determined how the information is to be
displaced for immediate need and also the hard copy output. It is the most important and
direct source information to the user. Efficient and intelligent output design improves the
system‘s relationship to help user decision-making.
1. Designing computer output should proceed in an organized, well thought out manner; the
right output must be developed while ensuring that each output element is designed so that
people will find the system can use easily and effectively. When analysis design computer
output, they should Identify the specific output that is needed to meet the requirements.
3.Create document, report, or other formats that contain information produced by the system.
The output form of an information system should accomplish one or more of the following
objectives.
                                               59
6.1 SYSTEM ARCHITECTURE:
The above Figure proceeds with the user can start their conversation with the chatbot like user
friendlyand it will be stored in the database for future reference. The chatbot will clarify the
users symptoms with serious of questions and the symptom conformation will be done. The
disease will be categorized as minor and major disease. Chatbot will reply whether it‘s a
major or minor disease. If it‘s a major one user will be suggested with the doctor details near
by you for further treatment and display the analagesics and also provides food suggestions
that means which food you have to take more to recover the disease.the chatbot user interface
can chat with like user friendly.by using chatbot don‘t go to hospitals for even small problems
                                                60
6.2 DATA FLOW DIAGRAM:
                                               61
6.3 METHODOLOGY:
Natural language processing:
It doesn‘t matter whether it‘s processing an automatic translation or a conversation with a chat
bot all natural language processing methods are the same in that they all involve
understanding the hierarchies that dictate interplay between individual words. But this isn‘t
easy – many words have double meanings. ‗Pass‘ for example can mean a physical handover
of something, a decision not to partake in something, and a measure of success in an exam or
another test format. It also operates in the same conjugation as both a verb and a noun. The
difference in meaning comes from the words that surround ‗pass‘ within the sentence or
phrase (I passed the butter/on the opportunity/the exam).
These difficulties are the main reason that natural language processing is seen as one of the
most complicated topics in computer science. Language is often littered with double
meanings, so understanding the differences requires an extensive knowledge of the content in
which the different meanings are used. Many users have first-hand experience of failed
communication with chat bots due to their continued use as replacements for live chat support
in customer service.But despite these difficulties, computers are improving their
                                              62
understanding of human language and its intricacies. To help speed this process up, computer
linguists rely on the knowledge of various traditional linguistic fields:The term morphology is
concerned with the interplay between words and their relationship with other words
Syntax defines how words and sentences are put together Semantics is the study of the
meaning of words and groups of words Pragmatics is used to explain the content of spoken
expressions And lastly, phonology covers the acoustic structure of spoken language and is
essential for language recognition
We are using three algorithms to implement making health care chatbot using nlp technique
1.n-gram algorithm
N-gram algorithm:
EXAMPLES:
resulting Markov
                                                              0            1             2
      model
                                              63
                                                                                   …, Cys-
                                                                      …, Cys-
                                                    …, Cys,                        Gly-Leu,
                                                                      Gly, Gly-
Protein Order of   amino      … Cys-Gly-Leu-Ser-Trp Gly, Leu,                      Gly-Leu-
                                                                      Leu, Leu-
sequencing         acid       …                     Ser, Trp,                      Ser, Leu-
                                                                      Ser, Ser-
                                                    …                              Ser-Trp,
                                                                      Trp, …
                                                                                   …
                                                                                   …, AGC,
                                                                      …, AG,
                                                         …, A, G,                  GCT,
                                                                      GC, CT,
                                                         C, T, T,                  CTT,
DNA sequencing base pair …AGCTTCGA…                                   TT, TC,
                                                         C, G, A,                  TTC,
                                                                      CG, GA,
                                                         …                         TCG,
                                                                      …
                                                                                   CGA, …
                                                                                   …, to_,
                                                              …, to, o_,           o_b, _be,
                                                  …, t, o, _, _b, be, e_,          be_, e_o,
                                                  b, e, _, o, _o, or, r_,          _or, or_,
Computational
                   character …to_be_or_not_to_be… r, _, n, o, _n, no, ot,          r_n, _no,
linguistics
                                                  t, _, t, o, t_, _t, to,          not, ot_,
                                                  _, b, e, … o_, _b, be,           t_t, _to,
                                                              …                    to_, o_b,
                                                                                   _be, …
                                                                                   …, to be
                                                                      …, to be,
                                                         …, to, be,                or, be or
Computational                                                         be or, or
                   word       … to be or not to be …     or, not, to,              not, or not
linguistics                                                           not, not to,
                                                         be, …                     to, not to
                                                                      to be, …
                                                                                   be, …
Applications:
n-gram models are widely used in statistical natural language processing. In speech
recognition, phonemes and sequences of phonemes are modeled using a n-gram distribution.
For parsing, words are modeled such that each n-gram is composed of n words. For language
identification, sequences of characters/graphemes (e.g., letters of the alphabet) are modeled
for different languages. For sequences of characters, the 3-grams (sometimes referred to as
"trigrams") that can be generated from "good morning" are "goo", "ood", "od ", "d m", " mo",
"mor" and so forth, counting the space character as a gram (sometimes the beginning and end
of a text are modeled explicitly, adding "_ _g", "_go", "ng_", and "g_ _"). For sequences of
                                             64
words, the trigrams (shingles) that can be generated from "the dog smelled like a skunk" are
"# the dog", "the dog smelled", "dog smelled like", "smelled like a", "like a skunk" and "a
skunk #".
    N-Grams are one way to help machines understand a word in the content to get a
       better understanding of word.
    Items can be characters , words , sentences. When n is 2 then we can call it as bigrams
       and n is 3 then we can call it as trigrams.Based on sentence we can change the value of
       ‗n‘. Example1:I am suffering from fever.
n=3(trigram)
example1:
example2:
Term frequency( tf ):
Suppose we have a set of English text documents and wish to rank which document is most
relevant to the query, "the brown cow". A simple way to start out is by eliminating documents
that do not contain all three words "the", "brown", and "cow", but this still leaves many
documents. To further distinguish them, we might count the number of times each term occurs
in each document; the number of times a term occurs in a document is called its term
frequency. However, in the case where the length of documents varies greatly, adjustments
                                                65
are often made (see definition below). The weight of a term that occurs in a document is
simply proportional to the term frequency.
   Often times, when building a model with the goal of understanding text, you‘ll see all of
stop words being removed. Another strategy is to score the relative importance of words using
TF-IDF.
The number of times a word appears in a document divided by the total number of words in
the document. Every document has its own term frequency.
 Example1: Example2:
 Tf(am)=1/5=0.2 Tf(am)=1/5=0.2
 Tf(suffering)=1/5=0.2 Tf(suffering)=1/5=0.2
 Tf(from)=1/5=0.2 Tf(from)=1/5=0.2
 Tf(fever)=1/5=0.2 Tf(headache)=1/5=0.2
   Because the term "the" is so common, term frequency will tend to incorrectly emphasize
   documents which happen to use the word "the" more frequently, without giving enough
   weight to the more meaningful terms "brown" and "cow". The term "the" is not a good
   keyword to distinguish relevant and non-relevant documents and terms, unlike the less-
   common words "brown" and "cow". Hence an inverse document frequency factor is
   incorporated which diminishes the weight of terms that occur very frequently in the
   document set and increases the weight of terms that occur rarely.
           The log of the number of documents divided by the number of documents that
       contain the word w. Inverse data frequency determines the weight of rare words across
       all documents in the corpus.
                                              66
Exmaple1: I am suffering from fever.
Idf(I) = log(2/2) = 0
Idf(am) = log(2/2) = 0
Idf(suffering) = log(2/2) = 0
Idf(from) = log(2/2) = 0
Tf -idf = Tf*idf
Output of TF-IDF:
                                       67
The above fig represents the importance of keword in the document which means
calculate the term frequency and inverse data frequency which is used for find the
keywords in the document .so tf-idf algorithm is used for calculate the keyword
importance in the document
                                    68
Cosine similarity algorithm:
   The technique is also used to measure cohesion within clusters in the field of data
      mining.
 Cosine similarity=AB/|A||B|.
   Introduction on Chat bot techniques There are two main technique involved in chat bot
      to understand the user input such as Pattern matching and Intent classification. Types
      of response: Static Response: The simplest way is to have a static response, with
      eventually a list of variants, for each user input. These static responses could be
      templates, such as ―John is located in <Location details>‖, where <Location details> is
      a variable computed by the chat bot. Dynamic Response: A different approach would
      be to use resources, such as a knowledge base, to get a list of potential responses, and
      then score them to choose the better response. This is particularly appropriate if the
      chat bot acts mainly like a question-answering system. Generated Response: If you
      have a huge corpus of examples of conversations, you could use a deep learning
      technique (Recurrent Neural Network) to train a generative model that, given an input,
      will generate the answer. You will need millions of examples to reach a decent quality
      and sometimes the results are going to be unexpected, but it could be interesting.
   Introduction on Text Similarity 1. Words are similar in two ways lexically and
      semantically. 2. Words are similar lexically if they have a similar character sequence.
      3. Words are similar semantically if they have the same thing, are opposite of each
      other, used in the same way , used in the same context. 4. Lexical similarity is
      introduced through String based algorithms and semantic similarity is introduced
      through Corpus based and Knowledge based algorithms. 5. String based measures
      operates on string sequences and character composition.
   Text similarity approaches 1. Measuring the similarity between words, sentences,
      paragraphs and documents is an important component in various tasks such as
      information retrieval, document clustering, word-sense disambiguation, automatic
      essay scoring, short answer grading, machine translation, topic tracking, question
      generation, question answering and text summarization. 2. Text similarity is
                                             69
   partitioned into three approaches Text similarity String based similarity Corpus based
   similarity Knowledge based similarity
 String based Character based Jaro LCS Levenshtein Jaro - winkler Smith waterman
   Needleman Wunsch N gram Term based Dice‘s coefficient Block distance Cosine
   similarity Euclidean distance Matching coefficient Jaccard similarity Overlap
   coefficient String based similarity measures
 Term Based Example 1: Cosine similarity Term based Distances: Let us consider two
   example sentences to calculate the term based text similarity - Jenny loves burger
   more than Linda loves pizza - Jane likes pizza more than Jenny loves burger Cosine
   Similarity: Words = [burger, jenny, loves, linda, than, more, likes, jane, pizza ] If you
   take the word count , you will get a matrix like mentioned on right side. Now
   calculating cosine similarity between a and b a : [1,1,2,1,1,1,0,0,1] b :
   [1,1,1,0,1,1,1,1,1] The cosine of the angle between vectors is their similarity , cos α =
   𝑎 . 𝑏 𝑎 ⋅ 𝑏 = dot product of vectors / Vectors magnitude Cos α = 7 / 8.942 = 0.782 and
   cos dissimilarity = 1 – 0.782 = 0.217 Terms Seq 1 Seq 2 Burger 1 1 Jenny 1 1 Loves 2
   1 Linda 1 0 Than 1 1 More 1 1 Likes 0 1 Jane 0 1 pizza 1 1
 Term Based Example 2 : Jaccard Similarity Jaccard similarity : J(a , b) = a ∩ 𝑏/a ∪ 𝑏 a
   : { jenny, loves, burger, more, than, pizza, Linda} b : { jane, likes, pizza, more, than,
   burger, loves, jenny} a ∩ 𝑏 : { jenny, loves, burger, more, pizza, than} a ∪ 𝑏 : {
   burger, jenny, loves, linda, than, more, likes, jane, pizza } Jaccard similarity = 6 / 9 =
   0.666 Removing stop words by parsing , Jaccard similarity = 5 / 8 = 0.625 and Jaccard
   dissimilarity = 1 - Jaccard similarity
 Cosine distance is nothing but getting distance between two vectors in n dimension
   space.Distance represent how words are related to each other
 Example:‖fever‖ and ―low fever‖ will have a cosine distance very low
                                            70
The above diagram shows the similarity between the two sentences or documents.Cosine
similarity is been used to check the similarity between two sentences. The similarity between
the query and document is directly proportional to the number of query weights. The
similarity calculation result of the two documents ranges from 0 to 1 since the term frequency
cannot be negative.it caluculats similarity between two sentences using cosine formula The
technique is also used to measure cohesion within clusters in the field of data mining.Cosine
similarity=AB/|A||B|.Cosine distance is nothing but getting distance between two vectors in n
dimension space.Distance represent how words are related to each other
                                             71
                                              7.CODING
from flask import Flask, render_template, request
import os
filenumber=int(os.listdir('saved_conversations')[-1])
filenumber=filenumber+1
file= open('saved_conversations/'+str(filenumber),"w+")
file.close()
app = Flask(__name__)
english_bot = ChatBot('Bot',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
'import_path': 'chatterbot.logic.BestMatch'
},
],
trainer='chatterbot.trainers.ListTrainer')
                                                    72
english_bot.set_trainer(ListTrainer)
@app.route("/")
def home():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
response = str(english_bot.get_response(userText))
appendfile=os.listdir('saved_conversations')[-1]
appendfile= open('saved_conversations/'+str(filenumber),"a")
appendfile.write('user : '+userText+'\n')
appendfile.write('bot : '+response+'\n')
appendfile.close()
return response
if __name__ == "__main__":
app.run()
import os
try:
os.remove("db.sqlite3")
except:
                                                73
english_bot = ChatBot('Bot')
english_bot.set_trainer(ListTrainer)
english_bot.train(convData)
                                               74
                                     8. SYSTEM TESTING
           The purpose of testing is to discover errors. Testing is the process of trying to discover
every conceivable fault or weakness in a work product. It provides a way to check the
functionality of components, sub assemblies, assemblies and/or a finished product It is the
process of exercising software with the intent of ensuring that the Software system meets its
requirements and user expectations and does not fail in an unacceptable manner. There are
various types of test. Each test type addresses a specific testing requirement.
TYPES OF TESTS
8.1.1 Unit testing
      Unit testing involves the design of test cases that validate that the internal program logic
is functioning properly, and that program inputs produce valid outputs. All decision branches
and internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests
perform basic tests at component level and test a specific business process, application, and/or
system configuration. Unit tests ensure that each unique path of a business process performs
accurately to the documented specifications and contains clearly defined inputs and expected
results.
                                                  75
Valid Input            : identified classes of valid input must be accepted.
Unit Testing:
         Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.
                                                 76
        Field testing will be performed manually and functional tests will be written in detail.
Test objectives
       All field entries must work .9properly.
       Pages must be activated from the identified link.
       The entry screen, messages and responses must not be delayed.
Features to be tested
       Verify that the entries are of the correct format
       No duplicate entries should be allowed
       All links should take the user to the correct page.
Integration Testing
        Software integration testing is the incremental integration testing of two or more
integrated software components on a single platform to produce failures caused by interface
defects.
        The task of the integration test is to check that components or software applications,
e.g. components in a software system or – one step up – software applications at the company
level – interact without error.
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant participation by the
end user. It also ensures that the system meets the functional requirements.
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.
                                                   77
                   9. SCREEN SHOTS
                          78
TRAINED DATASETS:
                    79
Stopped Growth :--> pred_diseases:'Growth Disorder, Turner Syndrome',
diet:'iron supplements'.
diet: 'Only yelow or white foods such as rice, potatoes or pasta and strictly avoid diary'.
pred_diseases: 'Depression',
treatment scans:'Constantly praise him, teach skills, and give self-development talks',
                                                 80
analgesics: 'Morphine or Ibuprofen',
pred_diseases:'Chickenpox',
analgesics: 'Acetaminophen',
diet: 'Raw fruits, Vegetables, Meat, Pastured eggs and avoid salty foods'.
pred_diseases:'Obesity',
treatment scans:'building heathy eating ang drinking habits and physical activities like
exercise',
pred_diseases:'Cavities\r\n',
pred_diseases: 'Diabetes',
                                                81
High body temperature, severe headache and tiredness-->
pred_diseases: 'Fever',
treatment scans:'Visiting Rehabilitation Centers, Help teens choose good friends and learn to
say NO',
analgesics: 'Tamoxifen',
treatment scans: 'heart-smart diet and indulge in physical activity and avoid smoking',
pred_diseases: 'Stroke',
pred_diseases: 'COPD',
                                                  82
analgesics: 'Tudorza or Brovana',
Forgetfulness or Confusion-->
analgesics: 'Levofloxacin',
pred_diseases: 'Diabetes',
treatment scans:'Dialysis',
                                                    83
Fever, chills, rapid breathing and heart rate-->
Fragile bones-->
treatment scans:'Physical activity like exercise and avoid smoking and srinking',
                                                   84
diet:'low-fat diary, whole grains and Fruits'.
pred_diseases: 'Menopause',
pred_diseases: 'Sinusitis',
                                                 85
analgesics: 'Carvedilol or Metoprolol',
                                                   86
                                    10. CONCLUSION
        Chatbot is great tool for conversation between human and machine. The application is
developed for getting a quick response from the bot which means without any delay it gives
the accurate result to the user.
It is concluded that, the usage of chatbot is user friendly and can be used by any person who
knows how to type in their own language.Chatbot provides personalized diagnosis based on
symptoms. From the review of various journals, it is concluded that, the usage of Chatbot is
user friendly and can be used by any person who knows how to type in their own language in
mobile app or desktop version. A medical chatbot provides personalized diagnoses based on
symptoms. In the future, the bot‘s symptom recognition and diagnosis performance could be
greatly improved by adding support for more medical features, such as location, duration, and
intensity of symptoms, and more detailed symptom description. The implementation of
Personalized Medical assistant heavily relies on AI algorithms as well as the training data. At
last, the implementation of personalized medicine would successfully save many lives and
create a medical awareness among the people. As said before, the future era is the era of
messaging app because people going to spend more time in messaging app than any other
apps. A text-to-text diagnosis Bot engages patients in conversation about their medical issues
and provides a personalized diagnosis based on their symptoms. Hence, people will have an
idea about their health and have the right protection.
Thus medical chatbot has wide and vast future scope. No matter how far people are, they can
have this medical conversation. The only requirement they need is a simple desktop or
smartphone with internet connection. The efficient of the chatbot can be improved by adding
more combination of words and increasing the use of database so that of the medical chabot
could handle all type of diseases. Even voice conversation can be added in the system to make
it more easy to use.
                                               87
                           11. FUTURE ENHANCEMENT
       The future era is the era of messaging app because people going to spend more time in
messaging app than any other apps. The implementation of personalized medicine would
successfully save many lives and create a medical awareness among the people. No matter
how far people are, they can have this medical conversation. The only requirement they need
is a simple desktop or smartphone with internet connection. The efficient of chatbot can be
improved by adding more combination of words and increasing the use of database so that of
the medical chatbot could handle all type of diseases.
                                              88
                                   12. REFERENCES
  Reference:
                                                 89
   Pediatric Generic Medicine Consultant Chatbot ―,Journal of Automation and Control
   Engineering Vol. 3, No. 2, April 2015.
90