Usually, business analyst execute their Rule Learner projects by a simple double-click on the file “learn.bat” (“learn.sh” for Linux or Mac). This bat-file looks as follows:
It calls the standard class “com.openrules.learner.Launcher” passing the name of the package as the first parameter. The second (optional) parameter can be the name of the file into which the generated rules will be saved.
However, you may invoke Rule Learner from any Java application using a simple Java API. Here is an example of a Java program “org.credits.Learner.java” from the project “Credits”:
This code is similar to traditional Java API for OpenRules Decision Manager. After the project is built (using “build.bat”) the package “org.credits” already has automatically generated Java classes DecisionModelCredits, instanceArray, and ProjectConfiguration. So, first we create a new decision model and its goal. Then we get an array “instances” of the type “TrainingInstance” created based on the data in the Excel table “instances”. The next line creates a “problem” using the standard Rule Learner constructor LearningProblem with 3 parameters: goal, instances, and ProjectConfiguration.getProperties(). And finally, we create a “learner” using the constructor of the class RuleLearnerWeka with one parameter problem. After calling goal.execute() the problem shows its classified instances.
To make sure that we will use this Java class “Learner” instead of the standard “Launcher”, we need to add one more property “run.class” into the file “project.properties”:
and run the standard OpenRules batch file “test.bat” instead of “learn.bat”. A similar launcher can be used to invoke Rule Learner from any Java program.
If you have any questions and/or want to become a contributor, send a request to email@example.com.