Expert Systems for Python
Experta is a Python library for building expert systems strongly inspired by CLIPS.
from random import choice from experta import * class Light(Fact): """Info about the traffic light.""" pass class RobotCrossStreet(KnowledgeEngine): @Rule(Light(color='green')) def green_light(self): print("Walk") @Rule(Light(color='red')) def red_light(self): print("Don't walk") @Rule(AS.light << Light(color=L('yellow') | L('blinking-yellow'))) def cautious(self, light): print("Be cautious because light is", light["color"])
>>> engine = RobotCrossStreet() >>> engine.reset() >>> engine.declare(Light(color=choice(['green', 'yellow', 'blinking-yellow', 'red']))) >>> engine.run() Be cautious because light is blinking-yellow
Migrating from Pyknow
Experta is a Pyknow fork. Just replace any pyknow references in your code/examples to experta and everything should work the same.
You can find some more examples on GitHub.
- Resolved #10. Corner case in DepthStrategy in which the first activation of the agenda didn’t get removed.
- Resolved #11 that was introduced with #7, that caused the same behavior under different conditions.
- Resolved #7. In some situations last activation was removed right after entering the agenda.
- Resolved #3. Rules should not be called with already retracted facts.
- Drop Python 3.4 support.
- Use setup.cfg to save all package metadata.
- Rebranded to Experta.
- Implemented the template system.
- Replaced warnings by watchers messages.
- Fixed freeze() with frozen objects.
- Fixed unfreeze() with unfrozen objects.
- Parametrized DefFacts via reset() kwargs.
- Improved overall performance.
- Added Python version 3.7 to tox.ini.
- Monkey and bananas example.
- Fixed bug, numeric index args gets repeated in a weird way introduced in 1.4.0.
- Pass only the defined args in absence of kwargs.
- Order integer facts keys after making a copy.
- as_dict method for Fact.
- freeze and unfreeze method documentation.
- unfreeze method in pyknow.utils.
- Zebra example from Clips.
- pyknow.operator module.
- Nested matching.
- Added Talk ‘Sistemas Expertos en Python con PyKnow - PyConES 2017’ to docs folder.
- Freeze fact values as the default behavior to address Issue #9.
- Added pyknow.utils.anyof to mitigate Issue #7.
- Raise RuntimeError if a fact value is modified after declare().
- Added MATCH and AS objects.
- Removing the borg optimization for P field constraints.
- Use the hash of the check in the sorting of the nodes to always generate the same alpha part of the network.
- Allow any kind of callable in Predicate Field Constraints (P()).
- DNF of OR clause inside AND or Rule was implemented wrong.
- RETE matching algorithm.
- Better Rule decorator system.
- Facts are dictionaries.
- Unestable API.
- Wrong matching algorithm.
- Bad performance
- PLEASE DON’T USE THIS.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size experta-1.9.4-py3-none-any.whl (35.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size experta-1.9.4.tar.gz (26.4 kB)||File type Source||Python version None||Upload date||Hashes View|