How to programmatically define a rule in clipspy?

1.2k Views Asked by At

Just installed clipspy on Fedora 26. I can assert simple facts like so:

>>> from clips import Environment
>>> env = Environment()
>>> env.assert_string('(a)')
ImpliedFact: f-1     (a)

How do I programmatically define a rule please? I can't find any examples or documentation about that. TIA.

1

There are 1 best solutions below

4
On BEST ANSWER

You can find the documentation here: clipspy documentation

However, you can either use build or eval like in CLIPS:

>>> env.build(...your defrule)
>>> env.eval("(build ...)")

or you can create it with:

clips.agenda.Rule(env, rule_you_want_to_define)

Don't forget the " " around your rule definition.