Created
April 28, 2018 02:21
-
-
Save Fcmam5/74d035e07e5c8e6f98aa8ba00c23219b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # # -*- coding: utf-8 -*- | |
| from pyknow import * | |
| class Personne(Fact): | |
| """Info about the patient""" | |
| pass | |
| class InreferenceEngine(KnowledgeEngine): | |
| @Rule() | |
| def probleme_orl(self): | |
| if sum([ | |
| self.facts[1]['maux_tete'], | |
| self.facts[1]['fievre'], | |
| self.facts[1]['fatigue'], | |
| self.facts[1]['courbatures'], | |
| self.facts[1]['frission'], | |
| self.facts[1]['toux'], | |
| self.facts[1]['face_pression'], | |
| self.facts[1]['nez_bouche'], | |
| self.facts[1]['nez_coule'], | |
| ]) > 4: | |
| print("Maladie ORL") | |
| self.declare(Fact(probleme_orl=True)) | |
| @Rule(Fact(probleme_orl=True)) | |
| def grippe_ou_sinusite(self): | |
| if sum([ | |
| self.facts[1]['maux_tete'], | |
| self.facts[1]['face_pression'], | |
| self.facts[1]['nez_coule'], | |
| self.facts[1]['maux_dents'], | |
| ]) > 3: | |
| print("Maladie Sinusite") | |
| self.declare(Fact(sinusite=True)) | |
| else: | |
| print("Maladie grippe") | |
| self.declare(Fact(grippee=True)) | |
| # Vérification s'il est diabétique | |
| @Rule() | |
| def hypoglycemie(self): | |
| if sum([ | |
| self.facts[1]['maux_tete'], | |
| self.facts[1]['pale'], | |
| self.facts[1]['sueur'], | |
| self.facts[1]['irritation'], | |
| self.facts[1]['faim'], | |
| self.facts[1]['fatigue'], | |
| self.facts[1]['etourdissement'], | |
| self.facts[1]['non_concentration'], | |
| ]) > 6: | |
| print("Il a une hypoglycemie") | |
| self.declare(Fact(hypoglycemie=True)) | |
| @Rule() | |
| def hyperglycimie(self): | |
| if sum([ | |
| self.facts[1]['fatigue'], | |
| self.facts[1]['urines'], | |
| self.facts[1]['soif'], | |
| self.facts[1]['faim'], | |
| self.facts[1]['irritation'], | |
| self.facts[1]['etourdissement'], | |
| ]) > 4: | |
| print("Il a une hyperglycimie") | |
| self.declare(Fact(hyperglycimie=True)) | |
| engine = InreferenceEngine() | |
| engine.reset() | |
| # Initial facts | |
| engine.declare(Personne(fievre=False, | |
| fatigue=False, | |
| frission=False, | |
| maux_tete=False, | |
| pale=False, | |
| courbatures=False, | |
| toux=False, | |
| nez_coule=False, | |
| nez_bouche=False, | |
| tremblement=False, | |
| sueur=False, | |
| palpitation=False, | |
| faim=False, | |
| etourdissement=False, | |
| non_concentration=False, | |
| soif=False, | |
| perte_de_poid=False, | |
| irritation=False, | |
| face_pression=False, | |
| maux_dents=False, | |
| urines=False, | |
| )) | |
| engine.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment