{"id":17998375,"url":"https://github.com/primaryobjects/knowledgebase","last_synced_at":"2025-03-26T05:30:46.868Z","repository":{"id":139343246,"uuid":"140478659","full_name":"primaryobjects/knowledgebase","owner":"primaryobjects","description":"An expert system using logic-based artificial intelligence and symbolic AI.","archived":false,"fork":false,"pushed_at":"2023-01-16T16:28:46.000Z","size":97,"stargazers_count":79,"open_issues_count":0,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-21T06:41:37.684Z","etag":null,"topics":["ai","artificial-intelligence","expert-system","expert-systems","javascript","knowledge","knowledge-discovery","knowledgebase","logic-based-artificial-intelligence","logical-knowledge-inference","nodejs","symbolic","symbolic-ai"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/primaryobjects.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["primaryobjects"]}},"created_at":"2018-07-10T19:31:49.000Z","updated_at":"2025-01-05T13:32:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7dcdd72-7266-473e-a183-d8182564bfed","html_url":"https://github.com/primaryobjects/knowledgebase","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fknowledgebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fknowledgebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fknowledgebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fknowledgebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primaryobjects","download_url":"https://codeload.github.com/primaryobjects/knowledgebase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597135,"owners_count":20641858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","artificial-intelligence","expert-system","expert-systems","javascript","knowledge","knowledge-discovery","knowledgebase","logic-based-artificial-intelligence","logical-knowledge-inference","nodejs","symbolic","symbolic-ai"],"created_at":"2024-10-29T21:24:59.639Z","updated_at":"2025-03-26T05:30:46.847Z","avatar_url":"https://github.com/primaryobjects.png","language":"JavaScript","readme":"Expert System Using Logic-Based Artificial Intelligence\n=======================================================\n\nThis project is an example of building an expert system, using a knowledge-base constructed with logic-based artificial intelligence, also called symbolic AI.\n\nSee also [Logical-Based Artificial Intelligence and Expert Systems](http://www.primaryobjects.com/2018/07/23/logical-based-artificial-intelligence-and-expert-systems/)\n\n## Usage\n\n```bash\nnpm install\nnode app.js\n```\n\n### First Example\n\nThe first example demonstrates forward-chaining. To use the example, provide the following example inputs below.\n\n```\nstem\nwoody\nposition\nupright\none main trunk\nyes\nbroad and flat\nno\n\u003cpress enter two times\u003e\n```\n\nYou should see the following output.\n\n```js\n[ { attribute: 'stem', value: 'woody' },\n  { attribute: 'position', value: 'upright' },\n  { attribute: 'one main trunk', value: 'yes' },\n  { attribute: 'broad and flat', value: 'no' },\n  { attribute: 'type', value: 'tree' },\n  { attribute: 'class', value: 'gymnosperm' } ]\n```\n\nThe first 4 items are our provided inputs. The second two are new attributes deduced from the knowledge-base.\n\n```\ntype is tree\nclass gymnosperm\n```\n\nWhy? The first output of `tree` is because of the original input attributes all being found for \"type = tree\". The second output of \"class gymnosperm\" is added due to the addition of \"type tree\" as a new attribute. In this manner, both the \"type\" and the \"class\" were intelligently deduced from the original input query.\n\n### Second Example\n\nThe second example demonstrates backward-chaining. To use the example, provide the following example inputs below.\n\n```\nclass\n```\n\nThe program will then prompt you for values for additional attributes as it narrows down on selecting a class for you.\n\n```\nstem: woody\nposition: upright\none main trunk: yes\nbroad and flat: yes\n```\n\nYou should see the output:\n\n```\nangiosperm\n```\n\nWhy? This is the attribute value for the `class` which satisfies all attributes provided in the input.\n\n## About\n\nLogic-based artificial intelligence is a form of classical AI that deals with representing knowledge as human-readable logical statements. In constrast to the machine learning statistical techniques that are currently popular, classical AI uses logical mechanisms for deducing intelligent statements and making decicisons.\n\nOne type of system that can be created with logical AI is an expert system.\n\n## Expert Systems\n\nAn expert system contains its knowledge usually in the form of a database, or, knowledge-base. By decoupling the knowledge from the actual software algorithm, an expert system can navigate through the database of facts to determine classifications and make decisions. The database is typically created by a human expert, and as such, the extent of knowledge that an expert system contains is typically confined to that of the human providing the content.\n\nFor example, a medical diagnosis expert system may contain a knowledge-base consisting of many different facts about diseases, symptoms, and conditions. The data can usually be represented by a tree hierarchy, from which one could navigate through the branches of symptoms until a particular conclusion is reached (i.e., disease or condition). By using a logic-based AI algorithm on the knowledge-base, such as forward-chaining and backward-chaining, an algorithm can intelligently traverse the tree, narrowing down the conclusion based upon the patient's provided symptoms.\n\n### Forward Chaining\n\nForward chaining is the process of traversing through the knowledge-base from top to bottom, seeking a rule by which all attributes are satisfied. For example, if every single one of a rule's attributes exist within the set of the patient's condition, then that rule triggers, thus providing a condition. If no rule is found with all of the attributes present from the patient, then a conclusion could not be found.\n\n### Backward Chaining\n\nIn contrast to forward-chaining, backward-chaining tries to first locate a rule who's conclusion matches one of the patient's provided attributes. When a rule is found, the process repeats, using the discovered rule's attributes as new goals. The user is prompted to enter new values for attributes as they are discovered through the process. Once the algorithm satisfies all attributes for the chain of rules it can return the response to the user's original query.\n\n## The Project\n\nThis project contains an implementation of forward-chaining and backward-chaining in JavaScript. It also contains two example knowledge-bases, written in JSON.\n\n#### data/plants.js\n\nA [knowledge-base](data/plants.js) consisting of traits and classifications for plants.\n\n#### data/etfs.js\n\nA [knowledge-base](data/etfs.js) consisting of classes and categories for selecting a stock/bond percentage based upon risk tolerance.\n\n## License\n\nMIT\n\n## Author\n\nKory Becker http://www.primaryobjects.com\n","funding_links":["https://github.com/sponsors/primaryobjects"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fknowledgebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimaryobjects%2Fknowledgebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fknowledgebase/lists"}