Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
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.
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.
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
Matches for Pattern 2
Matches for Pattern 3
Matches for Pattern 4
Partial matches for CEs 1 - 2
Partial matches for CEs 1 - 3
Partial matches for CEs 1 - 4
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.