[jboss-svn-commits] JBL Code SVN: r19229 - labs/jbossrules/contrib/machinelearning/decisiontree/src/id3.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 25 21:53:49 EDT 2008
Author: gizil
Date: 2008-03-25 21:53:49 -0400 (Tue, 25 Mar 2008)
New Revision: 19229
Added:
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RestaurantOld.java
Removed:
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Restaurant.java
Modified:
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukFileExample.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukObjectExample.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTree.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTreeBuilder.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Domain.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/FactSetFactory.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/LiteralDomain.java
labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RulePrinter.java
Log:
spitting a drl file (consisting only one type of object)
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukFileExample.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukFileExample.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukFileExample.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -34,7 +34,7 @@
//System.out.println(bocuksTree);
RulePrinter my_printer = new RulePrinter();
- my_printer.printer(bocuksTree);
+ my_printer.printer(bocuksTree, null, null);
}
}
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukObjectExample.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukObjectExample.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/BocukObjectExample.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -5,20 +5,20 @@
public class BocukObjectExample {
public static void main(String[] args) {
- Restaurant arest = new Restaurant(true, false, false, true, "Full", 1, false, false, "Thai", "30-60", false);
+ RestaurantOld arest = new RestaurantOld(true, false, false, true, "Full", 1, false, false, "Thai", "30-60", false);
Class<?> k = arest.getClass();
ArrayList<Object> facts = new ArrayList<Object>();
- facts.add(new Restaurant(true, false, false, true, "Full", 1, false, false, "Thai", "30-60", false));
- facts.add(new Restaurant(false, true, false, false, "Some", 1, false, false, "Burger", "0-10", true));
- facts.add(new Restaurant(true, false, true, true, "Full", 1, true, false, "Thai", "10-30", true));
- facts.add(new Restaurant(true, false, true, false, "Full", 3, false, true, "French", ">60", false));
- facts.add(new Restaurant(false, true, false, true, "Some", 2, true, true, "Italian", "0-10", true));
- facts.add(new Restaurant(false, true, false, false, "None", 1, true, false, "Burger", "0-10", false));
- facts.add(new Restaurant(false, false, false, true, "Some", 2, true, true, "Thai", "0-10", true));
- facts.add(new Restaurant(false, true, true, false, "Full", 1, true, false, "Burger", ">60", false));
- facts.add(new Restaurant(true, true, true, true, "Full", 3, false, true, "Italian", "10-30", false));
- facts.add(new Restaurant(false, false, false, false, "None", 1, false, false, "Thai", "0-10", false));
- facts.add(new Restaurant(true, true, true, true, "Full", 1, false, false, "Burger", "30-60", true));
+ facts.add(new RestaurantOld(true, false, false, true, "Full", 1, false, false, "Thai", "30-60", false));
+ facts.add(new RestaurantOld(false, true, false, false, "Some", 1, false, false, "Burger", "0-10", true));
+ facts.add(new RestaurantOld(true, false, true, true, "Full", 1, true, false, "Thai", "10-30", true));
+ facts.add(new RestaurantOld(true, false, true, false, "Full", 3, false, true, "French", ">60", false));
+ facts.add(new RestaurantOld(false, true, false, true, "Some", 2, true, true, "Italian", "0-10", true));
+ facts.add(new RestaurantOld(false, true, false, false, "None", 1, true, false, "Burger", "0-10", false));
+ facts.add(new RestaurantOld(false, false, false, true, "Some", 2, true, true, "Thai", "0-10", true));
+ facts.add(new RestaurantOld(false, true, true, false, "Full", 1, true, false, "Burger", ">60", false));
+ facts.add(new RestaurantOld(true, true, true, true, "Full", 3, false, true, "Italian", "10-30", false));
+ facts.add(new RestaurantOld(false, false, false, false, "None", 1, false, false, "Thai", "0-10", false));
+ facts.add(new RestaurantOld(true, true, true, true, "Full", 1, false, false, "Burger", "30-60", true));
WorkingMemory simple = new WorkingMemory();
@@ -40,6 +40,6 @@
System.out.println("Time"+dt+"\n"+bocuksTree);
RulePrinter my_printer = new RulePrinter();
- my_printer.printer(bocuksTree);
+ my_printer.printer(bocuksTree,"id3" , new String("src/id3/rules"+".drl"));
}
}
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTree.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTree.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTree.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -1,6 +1,8 @@
package id3;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Hashtable;
import java.util.List;
@@ -118,6 +120,64 @@
return sum;
}
+
+ private class FactNumericAttributeComparator implements Comparator<Fact> {
+ private String attr_name;
+ public FactNumericAttributeComparator(String _attr_name) {
+ attr_name = _attr_name;
+ }
+
+ public int compare(Fact f0, Fact f1) {
+ Number n0 = (Number)f0.getFieldValue(attr_name);
+ Number n1 = (Number)f1.getFieldValue(attr_name);
+ if (n0.doubleValue() < n1.doubleValue())
+ return -1;
+ else if (n0.doubleValue() > n1.doubleValue())
+ return 1;
+ else
+ return 0;
+ }
+ }
+
+ /* GLOBAL DISCRETIZATION
+ a a b a b b b b b (target)
+ 1 2 3 4 5 6 7 8 9 (attr c)
+ 0 0 0 0 1 1 1 1 1
+ "<5", ">=5"
+ "true" "false"
+ */
+
+ //*OPT* public double getGain(List<FactSet> facts, String attributeToSplit) {
+ public double getContinuousGain(List<Fact> facts, String attributeToSplit) {
+ System.out.println("What is the attributeToSplit? "+attributeToSplit);
+
+ List<?> boundaries = getPossibleValues(attributeToSplit);
+
+ /* sort the values */
+ Collections.sort(facts, new FactNumericAttributeComparator(attributeToSplit));
+
+ //Fact split_point = facts.get(facts.size() / 2);
+ // a b a a b
+ // 1 2 3 4 5
+ // 1.5
+ // 2.5
+ // 3.5
+ // 0.00001 0.00002 1 100
+ // 0.000015
+
+ // < 50 >
+ // 25 75
+ //HashTable<Boolean>
+
+ String attr_sum = "sum";
+
+ List<?> targetValues = getPossibleValues(target);
+ //Hashtable<Object, Integer> facts_in_class = new Hashtable<Object, Integer>(targetValues.size());
+
+ return 1.0;
+ }
+
+
//*OPT* public double getInformation(List<FactSet> facts) {
Hashtable<Object, Integer> getStatistics(List<Fact> facts, String target, List<?> targetValues) {
Hashtable<Object, Integer> facts_in_class = new Hashtable<Object, Integer>(targetValues.size());
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTreeBuilder.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTreeBuilder.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/DecisionTreeBuilder.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -208,7 +208,13 @@
double greatestGain = 0.0;
String attributeWithGreatestGain = attrs.get(0);
for (String attr : attrs) {
- double gain = dt_info - dt.getGain(facts, attr);
+ double gain = 0;
+ if (dt.getDomain(attr).isDiscrete()) {
+ gain = dt_info - dt.getGain(facts, attr);
+ } else {
+ gain = dt_info - dt.getContinuousGain(facts, attr);
+ }
+
System.out.println("Attribute: "+attr +" the gain: "+gain);
if (gain > greatestGain) {
greatestGain = gain;
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Domain.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Domain.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Domain.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -7,6 +7,9 @@
boolean isConstant();
void setConstant();
+ boolean isDiscrete();
+ //void setConstant();
+
boolean contains(T value);
String getName();
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/FactSetFactory.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/FactSetFactory.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/FactSetFactory.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -27,7 +27,7 @@
String filename = "../data/nursery/nursery.data.txt";
String separator = ",";
- String klass = "Nursey";
+ String klass = "Nursery";
ArrayList<Domain<?>> domains = new ArrayList<Domain<?>>();
domains.add(new LiteralDomain("parents", new String[]{"usual", "pretentious", "great_pret"}));
domains.add(new LiteralDomain("has_nurs", new String[]{"proper", "less_proper", "improper", "critical", "very_crit"}));
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/LiteralDomain.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/LiteralDomain.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/LiteralDomain.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -29,9 +29,9 @@
// }
-// public boolean isDiscrete() {
-// return discrete;
-// }
+ public boolean isDiscrete() {
+ return true;
+ }
public String getName() {
return fName;
Deleted: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Restaurant.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Restaurant.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Restaurant.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -1,147 +0,0 @@
-package id3;
-
-
-public class Restaurant {
-
-
- private boolean alternate; //yesno
- private boolean bar; //yesno
- private boolean fri_sat ; //yesno
- private boolean hungry; //yesno
- private String patrons; //String[]{"None","Some","Full"});
- private int price; //",new String[]{"$","$$","$$$"});
- private boolean raining; //yesno
- private boolean reservation; //yesno
- private String type; //",new String[]{"French","Italian","Thai","Burger"});
- private String wait_estimate; //",new String[]{"0-10","10-30","30-60",">60"});
- private boolean will_wait; //yesno
-
-
- public Restaurant (boolean alt, boolean b, boolean f_s, boolean hung, String pat, int pri,
- boolean rain, boolean reserv, String t, String wait, boolean will) {
- alternate = alt; //yesno
- bar = b; //yesno
- fri_sat = f_s; //yesno
- hungry = hung; //yesno
- patrons = pat; //",new String[]{"None","Some","Full"});
- price = pri; //",new String[]{"$","$$","$$$"});
- raining = rain; //yesno
- reservation = reserv; //yesno
- type = t; //",new String[]{"French","Italian","Thai","Burger"});
- wait_estimate = wait; //",new String[]{"0-10","10-30","30-60",">60"});
- will_wait = will; //yesno
- }
-
-
- public boolean getAlternate() {
- return alternate;
- }
-
-
- public void setAlternate(boolean alternate) {
- this.alternate = alternate;
- }
-
-
- public boolean getBar() {
- return bar;
- }
-
-
- public void setBar(boolean bar) {
- this.bar = bar;
- }
-
-
- public boolean getFri_sat() {
- return fri_sat;
- }
-
-
- public void setFri_sat(boolean fri_sat) {
- this.fri_sat = fri_sat;
- }
-
-
- public boolean getHungry() {
- return hungry;
- }
-
-
- public void setHungry(boolean hungry) {
- this.hungry = hungry;
- }
-
-
- public String getPatrons() {
- return patrons;
- }
-
-
- public void setPatrons(String patrons) {
- this.patrons = patrons;
- }
-
-
- public int getPrice() {
- return price;
- }
-
-
- public void setPrice(int price) {
- this.price = price;
- }
-
-
- public boolean getRaining() {
- return raining;
- }
-
-
- public void setRaining(boolean raining) {
- this.raining = raining;
- }
-
-
- public boolean getReservation() {
- return reservation;
- }
-
-
- public void setReservation(boolean reservation) {
- this.reservation = reservation;
- }
-
-
- public String getType() {
- return type;
- }
-
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- public String getWait_estimate() {
- return wait_estimate;
- }
-
-
- public void setWait_estimate(String wait_estimate) {
- this.wait_estimate = wait_estimate;
- }
-
-
- public boolean getWill_wait() {
- return will_wait;
- }
-
-
- public void setWill_wait(boolean will_wait) {
- this.will_wait = will_wait;
- }
-
-
-
-}
Copied: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RestaurantOld.java (from rev 19045, labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/Restaurant.java)
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RestaurantOld.java (rev 0)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RestaurantOld.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -0,0 +1,147 @@
+package id3;
+
+
+public class RestaurantOld {
+
+
+ private boolean alternate; //yesno
+ private boolean bar; //yesno
+ private boolean fri_sat ; //yesno
+ private boolean hungry; //yesno
+ private String patrons; //String[]{"None","Some","Full"});
+ private int price; //",new String[]{"$","$$","$$$"});
+ private boolean raining; //yesno
+ private boolean reservation; //yesno
+ private String type; //",new String[]{"French","Italian","Thai","Burger"});
+ private String wait_estimate; //",new String[]{"0-10","10-30","30-60",">60"});
+ private boolean will_wait; //yesno
+
+
+ public RestaurantOld (boolean alt, boolean b, boolean f_s, boolean hung, String pat, int pri,
+ boolean rain, boolean reserv, String t, String wait, boolean will) {
+ alternate = alt; //yesno
+ bar = b; //yesno
+ fri_sat = f_s; //yesno
+ hungry = hung; //yesno
+ patrons = pat; //",new String[]{"None","Some","Full"});
+ price = pri; //",new String[]{"$","$$","$$$"});
+ raining = rain; //yesno
+ reservation = reserv; //yesno
+ type = t; //",new String[]{"French","Italian","Thai","Burger"});
+ wait_estimate = wait; //",new String[]{"0-10","10-30","30-60",">60"});
+ will_wait = will; //yesno
+ }
+
+
+ public boolean getAlternate() {
+ return alternate;
+ }
+
+
+ public void setAlternate(boolean alternate) {
+ this.alternate = alternate;
+ }
+
+
+ public boolean getBar() {
+ return bar;
+ }
+
+
+ public void setBar(boolean bar) {
+ this.bar = bar;
+ }
+
+
+ public boolean getFri_sat() {
+ return fri_sat;
+ }
+
+
+ public void setFri_sat(boolean fri_sat) {
+ this.fri_sat = fri_sat;
+ }
+
+
+ public boolean getHungry() {
+ return hungry;
+ }
+
+
+ public void setHungry(boolean hungry) {
+ this.hungry = hungry;
+ }
+
+
+ public String getPatrons() {
+ return patrons;
+ }
+
+
+ public void setPatrons(String patrons) {
+ this.patrons = patrons;
+ }
+
+
+ public int getPrice() {
+ return price;
+ }
+
+
+ public void setPrice(int price) {
+ this.price = price;
+ }
+
+
+ public boolean getRaining() {
+ return raining;
+ }
+
+
+ public void setRaining(boolean raining) {
+ this.raining = raining;
+ }
+
+
+ public boolean getReservation() {
+ return reservation;
+ }
+
+
+ public void setReservation(boolean reservation) {
+ this.reservation = reservation;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+ public String getWait_estimate() {
+ return wait_estimate;
+ }
+
+
+ public void setWait_estimate(String wait_estimate) {
+ this.wait_estimate = wait_estimate;
+ }
+
+
+ public boolean getWill_wait() {
+ return will_wait;
+ }
+
+
+ public void setWill_wait(boolean will_wait) {
+ this.will_wait = will_wait;
+ }
+
+
+
+}
Modified: labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RulePrinter.java
===================================================================
--- labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RulePrinter.java 2008-03-26 01:47:21 UTC (rev 19228)
+++ labs/jbossrules/contrib/machinelearning/decisiontree/src/id3/RulePrinter.java 2008-03-26 01:53:49 UTC (rev 19229)
@@ -1,5 +1,6 @@
package id3;
+import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -27,7 +28,7 @@
nodes = new Stack<NodeValue>();
}
- public void printer(DecisionTree dt) {//, PrintStream object
+ public void printer(DecisionTree dt, String packageName, String outputFile) {//, PrintStream object
ruleObject = dt.getName();
dfs(dt.getRoot());
@@ -37,13 +38,36 @@
// System.out.println("Rule " +j + " suggests that \n"+ rule +".\n");
// }
+ //String outputFile = new String("src/id3/rules"+".drl");
+ if (outputFile!=null) {
+ if (packageName != null)
+ write("package " + packageName +";\n\n", false, outputFile);
+ else
+ try {
+ throw new Exception("The package is not specified");
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+// write("/* \n", false, outputFile);
+// write(" * Spitting the rules= \n", true, outputFile);
+// write(" */ \n", true, outputFile);
+ }
+
int i = 0;
Collections.sort(rules, Rule.getRankComparator());
for( Rule rule: rules) {
i++;
System.out.println("//rule " +i + " write to drl \n"+ rule +"\n");
+ if (outputFile!=null) {
+ write(rule.toString(), true, outputFile);
+ write("\n", true, outputFile);
+ }
}
}
+ public Object getRuleObject() {
+ return ruleObject;
+ }
private void dfs(TreeNode my_node) {
NodeValue node_value = new NodeValue(my_node);
@@ -55,7 +79,9 @@
//rule_list.add(spit(nodes));
// what if more than one condition (more than one leafNode)
- rules.add(spitRule(nodes));
+ Rule newRule = spitRule(nodes);
+ newRule.setId(rules.size());
+ rules.add(newRule);
return;
}
@@ -73,21 +99,11 @@
}
- private ArrayList<NodeValue> spit(Stack<NodeValue> nodes) {
- ArrayList<NodeValue> list_nodes = new ArrayList<NodeValue>(nodes.size());
- Iterator<NodeValue> it = nodes.iterator();
-
- while (it.hasNext()) {
-
- NodeValue current = it.next();
- list_nodes.add(current);
- }
- return list_nodes;
- }
private Rule spitRule(Stack<NodeValue> nodes) {
//, Stack<NodeValue> leaves // if more than one leaf
Rule newRule = new Rule(nodes.size());// (nodes, leaves) //if more than one leaf
+ newRule.setObject(getRuleObject().toString());
Iterator<NodeValue> it = nodes.iterator();
while (it.hasNext()) {
@@ -133,13 +149,44 @@
return out;
}
+ // --------------------------------------------------------------------------------
+ // Saves the string
+ //--------------------------------------------------------------------------------
+ public void write(String toWrite, boolean append, String data) {
+ //String data = new String("data/results_"+System.currentTimeMillis()+".m");
+ File file =new File(data);
+ if (append)
+ {
+ if(!file.exists())
+ System.out.println("File doesnot exit, creating...");
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter(data, true));
+ out.write(toWrite);
+ out.close();
+ //System.out.println("I wrote "+ toWrite);
+ } catch (IOException e) {
+ System.out.println("No I cannot write to the file");
+ System.exit(0);
+ }
+
+ } else {
+ if(file.exists()&& (file.length()>0))
+ file.delete();
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter(data));
+ out.write(toWrite);
+ out.close();
+ System.out.println("I wrote "+ toWrite);
+ } catch (IOException e) {
+ System.out.println("No I cannot write to the file");
+ }
+ }
+ }
}
-
-
-
class Rule {
-
+ private int id;
+ private String attr_obj;
private double rank;
private ArrayList<NodeValue> conditions;
private ArrayList<NodeValue> actions;
@@ -160,11 +207,27 @@
actions.add(new NodeValue(current.getNode(), current.getNodeValue()));
rank = ((LeafNode)current.getNode()).getRank();
}
+ public void setObject(String obj) {
+ attr_obj= obj;
+ }
+ public String getObject() {
+ return attr_obj;
+ }
+ private int getId() {
+ // TODO Auto-generated method stub
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id= id;
+ }
+
+
+
public String toString() {
- /*
-
+ /*
rule "Good Bye"
dialect "java"
when
@@ -173,30 +236,37 @@
System.out.println( "Goodbye: " + message );
end
*/
-
- String out = "rule \"#x rank:"+rank+"\" \n";
+
+ String out = ""; //"rule \"#"+getId()+" "+decision+" rank:"+rank+"\" \n";
out += "\t when";
- out += "\n\t\t Object("+ "";
+ out += "\n\t\t "+getObject() +"("+ "";
for (NodeValue cond: conditions) {
- out += cond + " & ";
+ out += cond + ", ";
}
-
- out = out.substring(0, out.length()-3) + ")\n";
-
String action = "";
+ String decision = "";
for (NodeValue act: actions) {
- action += act.getNodeValue() + " & ";
+ out += act.getDomain() + " : "+act.getDomain()+" , ";
+ action += act.getNodeValue() + " , ";
+ decision += act.getDomain() + " ";
}
action = action.substring(0, action.length()-3);
+ out = out.substring(0, out.length()-3) + ")\n";
- out += "\n\t then ";
- out += "\n\t\t System.out.println(\"Decision (\"+" + action + "+\")\");";
+ out += "\t then ";
+ out += "\n\t\t System.out.println(\"Decision on "+decision+"= \"+" + decision + "+\": ("+action+")\");\n";
+
+ out = "rule \"#"+getId()+" "+decision+ "= "+action+" with rank:"+rank+"\" \n" + out;
+
+ out += "end\n";
return out;
}
+
+
public static Comparator<Rule> getRankComparator() {
return new RuleComparator();
}
@@ -245,7 +315,10 @@
this.nodeValue = nodeValue;
}
public String toString() {
- return node.getDomain() + " == "+ nodeValue;
+ if (node.getDomain() instanceof LiteralDomain)
+ return node.getDomain() + " == "+ "\""+nodeValue+ "\"";
+ else
+ return node.getDomain() + " == "+ nodeValue;
}
}
More information about the jboss-svn-commits
mailing list