Question

I need to convert from rules defined as DROOLS .drl files to CLIPS .clp.

As I understand, it should be possible to convert DROOLS rules into ruleML, and ruleML into CLIPS .clp.

I understand well that the matter is more complex than converting between file formats. But as far as I dived into the matter (reading papers and info found on the net) it should be well possible. However, this is just not my domain (yet) and the matter is too complex for me to get going without practical advise and example.

Was it helpful?

Solution

If you're translating similar functionality between the two languages, then you could either write a program to do the translation or use search and replace preferably with grep expressions. Unless the program is very simple, you'll still have to do a good bit of work checking and tweaking the translation (which will require a working knowledge of both languages). For example, the code below is a rule translated from IRL (JRules) to CLIPS.

I'm not familiar with tools available for ruleML, but if there are some available that will do even a partial translation, that would be worthwhile to use to get started.

when 
  {
   Phase ( name == "match" ) ;
   Rank ( ?p : value; process == "yes" );
   Technique ( name == "Hidden-Single"; rank == ?p ) ;   
   Possible ( ?v : value; ?r : row; ?pid : id );
   not Possible ( value == ?v; row == ?r; id != ?pid ) ;
   Possible ( ?v2: value; value != ?v; row == ?r; id == ?pid ) ;
   not Impossible ( id == ?pid; value == ?v2; rank == ?p ) ;
  }
then 
  {
   insert Impossible() { id = ?pid; value = ?v2; rank = ?p; reason = "Hidden Single";  }  
  }

(defrule hidden-single-row   
   (phase match)
   (rank (value ?p) (process yes))
   (technique (name Hidden-Single) (rank ?p))
   (possible (value ?v) (row ?r) (id ?id))
   (not (possible (value ?v) (row ?r) (id ~?id)))
   (possible (value ?v2&~?v) (row ?r) (id ?id))
   (not (impossible (id ?id) (value ?v2) (rank ?p)))
   =>
   (assert (impossible (id ?id) (value ?v2) (rank ?p) (reason "Hidden Single"))))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top