What's the best way to access Clips (matches <rulename>) function in PyClips, in order to find partial matches for a rule?
I tried doing env.Eval("(matches myrule)"), which seems to run without error, but I can't see the output. Eva() doesn't return anything, so I'm assuming the results would be printed to stdout, but print env.StdoutStream.Read() says the Environment object has no stdout, and clips.StdoutStream.Read() displays nothing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The best way would be a call to Rule.PrintMatches() (see manual) once you've got the Rule object. When you create the rule using the BuildRule() function, you have the object from the start, else you can use the FindRule() function to retrieve it. Some of the CLIPS "functions" require you to use SendCommand() function in PyCLIPS, because Eval() makes sense only for functions that return a value.
F.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks. Is there an easy to determine which patterns and CEs aren't matched, as in retrieving the their actual text?
PrintMatches() gives me output like:
Matches for Pattern 1
f-1
f-4
Matches for Pattern 2
f-3
f-5
Matches for Pattern 3
None
Matches for Pattern 4
f-3
f-5
Partial matches for CEs 1 - 2
f-1,f-3
Partial matches for CEs 1 - 3
None
Partial matches for CEs 1 - 4
None
Activations
None
How would I determine that the unmatched Pattern 3 was, say, "(myfact ?value)"?
My first idea is to parse my rule's text, but I'm not even sure how I'd capture the text and parse it, since it's sent straight to stdout. Even if I could parse the text, I'd still have to reverse engineer all of Clips' syntax rules for what is a pattern and what is a CE, which I'd rather avoid.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What's the best way to access Clips (matches <rulename>) function in PyClips, in order to find partial matches for a rule?
I tried doing env.Eval("(matches myrule)"), which seems to run without error, but I can't see the output. Eva() doesn't return anything, so I'm assuming the results would be printed to stdout, but print env.StdoutStream.Read() says the Environment object has no stdout, and clips.StdoutStream.Read() displays nothing.
Hi.
The best way would be a call to Rule.PrintMatches() (see manual) once you've got the Rule object. When you create the rule using the BuildRule() function, you have the object from the start, else you can use the FindRule() function to retrieve it. Some of the CLIPS "functions" require you to use SendCommand() function in PyCLIPS, because Eval() makes sense only for functions that return a value.
F.
Thanks. Is there an easy to determine which patterns and CEs aren't matched, as in retrieving the their actual text?
PrintMatches() gives me output like:
How would I determine that the unmatched Pattern 3 was, say, "(myfact ?value)"?
My first idea is to parse my rule's text, but I'm not even sure how I'd capture the text and parse it, since it's sent straight to stdout. Even if I could parse the text, I'd still have to reverse engineer all of Clips' syntax rules for what is a pattern and what is a CE, which I'd rather avoid.