SlideShare a Scribd company logo
1 of 2
Introduction
This code is an implementation of an expert system which is Applying Forward Chaining using the
experta library in Python. The system prompts the user with a series of questions regarding their
symptoms, and then uses rules to determine what disease the user might have based on their
responses.
The system is able to identify 14 diseases: Jaundice, Alzheimer's, Arthritis, Asthmas, Corona Virus,
Diabetes, Epilepsy, Glaucoma, Heart Disease, Head Stroke, Hyper Hypothyroidism, Hypothermia
Jaundice, Sinusitis and Tuberculosis, and discuss each disease after detect the disease of the user and
help them about the next step they should do. The rules for each disease are defined using a series of
Fact objects that represent the user's symptoms. If all of the facts for a given rule match the user's
symptoms, the system declares a Fact object representing the matched disease.
Overall, this Project appears to be a simple implementation of an expert system, but it only covers a very
limited range of diseases and symptoms.
Methods
The __init__ method of the Greetings class initializes the object with a symptom map, a function to call if
no disease is matched, a function to get treatments, and a function to get details about the matched
disease.
The system uses a series of Rule objects to match the user's symptoms to a disease. The @Rule
decorator is used to define each rule, and the Fact class is used to represent a user's response to a
symptom. The salience parameter is used to give priority to certain rules over others.
The DefFacts decorator is used to define initial facts and actions for the system. In this case, the system
introduces itself and prompts the user for input.
The preprocess() function reads in the disease information from the text files and creates several
dictionaries that map from symptoms to diseases, from diseases to descriptions, and from diseases to
treatments. These dictionaries are then used by the other functions to provide the diagnostic output.
The identify_disease() function takes in one or more symptoms as arguments, creates a list of those
symptoms, converts that list to a string, looks up the disease associated with that string in the symptom
map dictionary, and returns the name of the disease.
The get_details() and get_treatments() functions take in a disease name as an argument and return the
description and treatments for that disease, respectively.
The if_not_matched() function is called when the symptom input doesn't match any disease in the
system. It takes in a disease name (which is actually "None" in this case) and uses the get_details() and
get_treatments() functions to print information about the most probable disease based on the
symptoms that were input.
The if __name__ == "__main__": block initializes the program by calling preprocess() to load the disease
information and create the necessary dictionaries. It then creates an instance of the Greetings class
(which is defined in the greetings.py file) and enters a loop that allows the user to input symptoms and
receive diagnostic output. The loop continues until the user enters "no" when asked if they would like to
diagnose more symptoms.

More Related Content

Similar to Report of Introduction and methods Explination.docx

Information extraction from EHR
Information extraction from EHRInformation extraction from EHR
Information extraction from EHRAshis Chanda
 
Health Analyzer System
Health Analyzer SystemHealth Analyzer System
Health Analyzer SystemIRJET Journal
 
IRJET- Disease Analysis and Giving Remedies through an Android Application
IRJET- Disease Analysis and Giving Remedies through an Android ApplicationIRJET- Disease Analysis and Giving Remedies through an Android Application
IRJET- Disease Analysis and Giving Remedies through an Android ApplicationIRJET Journal
 
Dengue Prediction Model using Machine Learning techniques and Internet of Things
Dengue Prediction Model using Machine Learning techniques and Internet of ThingsDengue Prediction Model using Machine Learning techniques and Internet of Things
Dengue Prediction Model using Machine Learning techniques and Internet of ThingsTarun Swarup
 
Disease inference from health-related uestions vissparse deep learning
Disease inference from health-related uestions vissparse deep learningDisease inference from health-related uestions vissparse deep learning
Disease inference from health-related uestions vissparse deep learningvishnuRajan20
 
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNING
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNINGDISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNING
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNINGvishnuRajan20
 
Humira repositioning report
Humira repositioning reportHumira repositioning report
Humira repositioning reportAnton Yuryev
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert Systems
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert SystemsAnalytical Comparison of Mathematical Modeling in the Diagnostic Expert Systems
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert SystemsEditor IJCATR
 
Multiple Disease Prediction System
Multiple Disease Prediction SystemMultiple Disease Prediction System
Multiple Disease Prediction SystemIRJET Journal
 
A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...JPINFOTECH JAYAPRAKASH
 
A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...IEEEFINALYEARPROJECTS
 
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSISDENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIScsandit
 
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSISDENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIScscpconf
 
Smart Health Prediction Report
Smart Health Prediction ReportSmart Health Prediction Report
Smart Health Prediction ReportArhind Gautam
 
Seminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTIONSeminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTIONArhind Gautam
 

Similar to Report of Introduction and methods Explination.docx (20)

Information extraction from EHR
Information extraction from EHRInformation extraction from EHR
Information extraction from EHR
 
Health Analyzer System
Health Analyzer SystemHealth Analyzer System
Health Analyzer System
 
I04735762
I04735762I04735762
I04735762
 
Expert systems
Expert systemsExpert systems
Expert systems
 
IRJET- Disease Analysis and Giving Remedies through an Android Application
IRJET- Disease Analysis and Giving Remedies through an Android ApplicationIRJET- Disease Analysis and Giving Remedies through an Android Application
IRJET- Disease Analysis and Giving Remedies through an Android Application
 
Dengue Prediction Model using Machine Learning techniques and Internet of Things
Dengue Prediction Model using Machine Learning techniques and Internet of ThingsDengue Prediction Model using Machine Learning techniques and Internet of Things
Dengue Prediction Model using Machine Learning techniques and Internet of Things
 
Disease inference from health-related uestions vissparse deep learning
Disease inference from health-related uestions vissparse deep learningDisease inference from health-related uestions vissparse deep learning
Disease inference from health-related uestions vissparse deep learning
 
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNING
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNINGDISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNING
DISEASE INFERENCE FROM HEALTH-RELATED QUESTIONS VIA SPARSE DEEP LEARNING
 
Mycin
MycinMycin
Mycin
 
Humira repositioning report
Humira repositioning reportHumira repositioning report
Humira repositioning report
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert Systems
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert SystemsAnalytical Comparison of Mathematical Modeling in the Diagnostic Expert Systems
Analytical Comparison of Mathematical Modeling in the Diagnostic Expert Systems
 
Multiple Disease Prediction System
Multiple Disease Prediction SystemMultiple Disease Prediction System
Multiple Disease Prediction System
 
A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...
 
A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...A method for mining infrequent causal associations and its application in fin...
A method for mining infrequent causal associations and its application in fin...
 
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSISDENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
 
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSISDENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
DENGUE DETECTION AND PREDICTION SYSTEM USING DATA MINING WITH FREQUENCY ANALYSIS
 
Smart Health Prediction Report
Smart Health Prediction ReportSmart Health Prediction Report
Smart Health Prediction Report
 
Seminar report irm
Seminar report irmSeminar report irm
Seminar report irm
 
Seminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTIONSeminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTION
 

More from MohamedAyman183185

More from MohamedAyman183185 (10)

Kareem Atif Mohamed 1851711195.pptx
Kareem Atif Mohamed 1851711195.pptxKareem Atif Mohamed 1851711195.pptx
Kareem Atif Mohamed 1851711195.pptx
 
sheet 3 answers.docx
sheet 3 answers.docxsheet 3 answers.docx
sheet 3 answers.docx
 
sheet 3-4.pdf
sheet 3-4.pdfsheet 3-4.pdf
sheet 3-4.pdf
 
sheet 1.docx
sheet 1.docxsheet 1.docx
sheet 1.docx
 
file organization sheet 2 .pdf
file organization sheet 2 .pdffile organization sheet 2 .pdf
file organization sheet 2 .pdf
 
Task mo7drt File Organization.docx
Task mo7drt File Organization.docxTask mo7drt File Organization.docx
Task mo7drt File Organization.docx
 
sheet 4.docx
sheet 4.docxsheet 4.docx
sheet 4.docx
 
sheet 5.docx
sheet 5.docxsheet 5.docx
sheet 5.docx
 
file organization sheet 2 .docx
file organization sheet 2 .docxfile organization sheet 2 .docx
file organization sheet 2 .docx
 
Mohamed Ayman Task3 RAID.docx
Mohamed Ayman Task3 RAID.docxMohamed Ayman Task3 RAID.docx
Mohamed Ayman Task3 RAID.docx
 

Recently uploaded

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Recently uploaded (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Report of Introduction and methods Explination.docx

  • 1. Introduction This code is an implementation of an expert system which is Applying Forward Chaining using the experta library in Python. The system prompts the user with a series of questions regarding their symptoms, and then uses rules to determine what disease the user might have based on their responses. The system is able to identify 14 diseases: Jaundice, Alzheimer's, Arthritis, Asthmas, Corona Virus, Diabetes, Epilepsy, Glaucoma, Heart Disease, Head Stroke, Hyper Hypothyroidism, Hypothermia Jaundice, Sinusitis and Tuberculosis, and discuss each disease after detect the disease of the user and help them about the next step they should do. The rules for each disease are defined using a series of Fact objects that represent the user's symptoms. If all of the facts for a given rule match the user's symptoms, the system declares a Fact object representing the matched disease. Overall, this Project appears to be a simple implementation of an expert system, but it only covers a very limited range of diseases and symptoms. Methods The __init__ method of the Greetings class initializes the object with a symptom map, a function to call if no disease is matched, a function to get treatments, and a function to get details about the matched disease. The system uses a series of Rule objects to match the user's symptoms to a disease. The @Rule decorator is used to define each rule, and the Fact class is used to represent a user's response to a symptom. The salience parameter is used to give priority to certain rules over others. The DefFacts decorator is used to define initial facts and actions for the system. In this case, the system introduces itself and prompts the user for input. The preprocess() function reads in the disease information from the text files and creates several dictionaries that map from symptoms to diseases, from diseases to descriptions, and from diseases to treatments. These dictionaries are then used by the other functions to provide the diagnostic output. The identify_disease() function takes in one or more symptoms as arguments, creates a list of those symptoms, converts that list to a string, looks up the disease associated with that string in the symptom map dictionary, and returns the name of the disease. The get_details() and get_treatments() functions take in a disease name as an argument and return the description and treatments for that disease, respectively. The if_not_matched() function is called when the symptom input doesn't match any disease in the system. It takes in a disease name (which is actually "None" in this case) and uses the get_details() and get_treatments() functions to print information about the most probable disease based on the symptoms that were input.
  • 2. The if __name__ == "__main__": block initializes the program by calling preprocess() to load the disease information and create the necessary dictionaries. It then creates an instance of the Greetings class (which is defined in the greetings.py file) and enters a loop that allows the user to input symptoms and receive diagnostic output. The loop continues until the user enters "no" when asked if they would like to diagnose more symptoms.