pyRete status 3
I'm happy to announce that pyRete is coming close to having the public API that I've planned for it.
Since the last status report I've added Single Not nodes, a way of using expressions to construct new variables dynamically and a way of expressing a Pattern to match against Fact objects. I've also added several functions such as list_facts, list_rules, pp_defrule etc etc.
I've also started to implement modules and focus I still haven't come that far but I hope to have it done in a couple of days. I've also started to implement an alternative way of specifiying a rule's metadata using decorators. Currently there are 2 ways to set module and salience:
>>> @pyRete.Ruleor
... @pyRete.salience(50)
... @pyRete.module('Main')
... def foo(a = int):
... if a == 1:
... pass
>>> @pyRete.Rulethe two ways of doing it yield the same result. If you use *both* the second way has preference because it's interpreted last in the RuleParser. That's not really a decision, that's just the way it is :-)
... def foo(a = int):
... salience = 50
... module = 'Main'
... if a == 1:
... pass
Note that since Python doesn't have symbols you need to use a String as argument to the module decorator or assignment. Since the module is specified as part of a Rule there's no way to have two rules with the same name (as Clips allows you to) even if they're defined "in" different modules.
Inga kommentarer:
Skicka en kommentar