{"id":27024369,"url":"https://github.com/ap-atul/expert-system","last_synced_at":"2026-03-07T22:01:40.293Z","repository":{"id":44418507,"uuid":"298165208","full_name":"ap-atul/Expert-System","owner":"ap-atul","description":"Generic Expert System with a custom Knowledgebase and Clause mappings.","archived":false,"fork":false,"pushed_at":"2023-04-10T03:51:59.000Z","size":39,"stargazers_count":15,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T21:19:15.682Z","etag":null,"topics":["artificial-intelligence","backward-chaining","expert","expert-system","forward-chaining","generic-expert-system","inference-engine","knowledgebase"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ap-atul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-24T04:05:20.000Z","updated_at":"2024-11-07T03:08:03.000Z","dependencies_parsed_at":"2022-09-16T10:10:33.929Z","dependency_job_id":null,"html_url":"https://github.com/ap-atul/Expert-System","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ap-atul/Expert-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-atul%2FExpert-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-atul%2FExpert-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-atul%2FExpert-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-atul%2FExpert-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ap-atul","download_url":"https://codeload.github.com/ap-atul/Expert-System/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ap-atul%2FExpert-System/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30233429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","backward-chaining","expert","expert-system","forward-chaining","generic-expert-system","inference-engine","knowledgebase"],"created_at":"2025-04-04T21:19:23.114Z","updated_at":"2026-03-07T22:01:40.276Z","avatar_url":"https://github.com/ap-atul.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Expert System \n* Generic expert system to generate rules and create relation between entries and knowledge base.\n* Implemented using Forward Chaining and Backward chaining.\n* Require to input well-formatted json files that correspond to the example in ```data``` folder\n* The clauses should relate to the Knowledge base or it won't make any sense when run.\n* Parsers are built to parse the json file and create objects on runtime.\n\n### Description\n* The Rule is a string that can be compared.\n* Knowledge is formed up of multiple rules\n* Knowledge Base is formed up of multiple knowledge\n* Clause is a set of questions\n* Clause has 3 attributes clause, negative, positive\n* For each clause, the knowledge base is searched, percent higher than Min Match is outputted\n* The constants can be changed from ```utils/constants.py```\n* Check out the examples ```data/```\n\n### Thought process\n* Json format file that can clearly define a structure to parse.\n* Reading the json file and building the Knowledge Base and the Clause Base.\n* The user input for each clause is converted to Knowledge Base.\n* Both Knowledge bases are compared and max percent matched is outputted.\n* There may be multiple matches, we could display details with percentage.\n* Finally answer is either True or False.\n\n   \n* Knowledge base syntax\n```json\n{\n  \"target\": [\n    {\n      \"name\": \"Kidney disease\",\n      \"rules\": {\n        \"1\": \"head aches\",\n        \"2\": \"vomiting\",\n        \"3\": \"body ache\",\n        \"4\": \"no sleep\"\n      }\n    },\n    {\n      \"name\": \"Some target\",\n      \"rules\": {\n        \"1\": \"rule1\",\n        \"2\": \"rule2\"\n      }\n    }\n  ]\n}\n```\n\n\n* Clause base syntax\n```json\n{\n  \"1\": {\n    \"question\": \"State your symptoms?\",\n    \"answer\": {\n      \"positive\": \"Yes, you are positive for \",\n      \"negative\": \"We don't see any signs of \"\n    }\n  },\n  \"2\": {\n    \"question\": \"question/statement\",\n    \"answer\": {\n      \"positive\": \"positive statement with potential to add target at end\",\n      \"negative\": \"negative statement, target will be added at end\"\n    }\n  }\n}\n```\n\n----------------------------------\n### Example\n* Backward Chaining\n```console\nChankya \u003e\u003e\u003e Tell me some features of this bird?\nYou \u003e\u003e\u003e high flight, strong legs, yellow legs\n[DEBUG] Target :: Falcons, Eagles ---\u003e  Matched :: 33.33333333333333\n\n[INFO] I am not sure if this is the bird Falcons, Eagles\n[INFO] Hope that you are satisfied with your answers !\n```\n\n* Forward Chaining\n```console\nChankya \u003e\u003e\u003e Tell me some features of this bird?\nYou \u003e\u003e\u003e high flight, strong legs, yellow legs\n[DEBUG] Target :: Falcons, Eagles ---\u003e  Matched :: 33.33333333333333\n[DEBUG] Target :: Peacock ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Hen ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Albatrosses ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Paradise birds ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Crows ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Cuckoos ---\u003e  Matched :: 0.0\n[DEBUG] Target :: Ducks, Geese and Swans ---\u003e  Matched :: 0.0\n\n[INFO] I am not sure if this is the bird Falcons, Eagles\n[INFO] Hope that you are satisfied with your answers !\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap-atul%2Fexpert-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fap-atul%2Fexpert-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fap-atul%2Fexpert-system/lists"}