规则引擎及使用 - peter-xbs/CommonCodes GitHub Wiki
规则引擎
典型规则引擎drools所使用的的rete算法
https://houbb.github.io/2020/05/26/rule-engine-03-rete
常见python rule based engine
- https://stackoverflow.com/questions/53421492/python-rule-based-engine
- CLIPS
- PyKE
- Durable Rules
- PyKnow
- Intellect
- Business Rules
rule_engine
-
https://zerosteiner.github.io/rule-engine/ 下次一定要尝试一次 比如我们此次的急诊分诊功能,完全适配这种场景 再比如我们的日期归一也建议采纳这种方案
使用示例1:
# first define the rule to use for matching / filtering
rule = rule_engine.Rule('date == $today and "Alice" in donors')
# next define the event object with it's attributes which will be symbols
event = {
'date': datetime.date.today(),
'donors': ['Alice', 'Bob'], # new ARRAY type
'title': 'Annual Fundraiser'
}
# apply the rule on the event object
rule.matches(event) # => True
使用示例2:
# check for 3 or more events of tcp traffic going to port 4444
rule = rule_engine.Rule(
'protocol == "tcp" and dst.port == 4444 and seen.length >= 3'
)
# evaluate the
rule.matches({
'dst': {'addr': '172.16.50.81', 'port': 4444},
'src': {'addr': '192.168.1.20', 'port': 53718},
'protocol': 'tcp',
'seen': [
datetime.date(2019, 7, 6),
datetime.date(2019, 8, 17),
datetime.date(2019, 9, 29)
]
}) # => True