Author: pkluegl
Date: Tue Jun  4 16:59:07 2013
New Revision: 1489514

URL: http://svn.apache.org/r1489514
Log:
UIMA-2859
- added some simple impl for reading/writing constraints

Added:
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportConstraintsHandler.java
      - copied, changed from r1489049, 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportAllConstraintsHandler.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintContentHandler.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLUtils.java
      - copied, changed from r1489049, 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLExporter.java
Removed:
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportAllConstraintsHandler.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLExporter.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLImporter.java
Modified:
    uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaConstraint.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaRuleConstraint.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaConstraintFactory.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaRuleListConstraint.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/SimpleRutaRuleConstraint.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintDialog.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectTableLabelProvider.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentViewRunHandler.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ImportConstraintsHandler.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/CDEComparatorFactory.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintData.java
    
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java

Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml Tue Jun  4 16:59:07 2013
@@ -703,7 +703,7 @@ under the License.
             name="RunFromDocumentView">
       </command>
       <command
-            
defaultHandler="org.apache.uima.ruta.cde.ui.ExportAllConstraintsHandler"
+            
defaultHandler="org.apache.uima.ruta.cde.ui.ExportConstraintsHandler"
             
id="toolbar:org.apache.uima.ruta.cde.ui.ConstraintSelectView.exportall"
             name="ExportAllConstraints">
       </command>

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaConstraint.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaConstraint.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaConstraint.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaConstraint.java
 Tue Jun  4 16:59:07 2013
@@ -23,8 +23,14 @@ import org.apache.uima.cas.CAS;
 
 public interface IRutaConstraint {
 
-       public Double processConstraint (CAS input) throws Exception;
-       
-       public String getDescription ();
-       
+  Double processConstraint(CAS input) throws Exception;
+
+  String getDescription();
+
+  void setDescription(String description);
+
+  String getData();
+
+  void setData(String data);
+
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaRuleConstraint.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaRuleConstraint.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaRuleConstraint.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/IRutaRuleConstraint.java
 Tue Jun  4 16:59:07 2013
@@ -21,16 +21,10 @@ package org.apache.uima.ruta.cde;
 
 public interface IRutaRuleConstraint extends IRutaConstraint {
   
-  public String getRule();
-  
-  public void setRule(String rule);
-  
-  
   public String getDescription();
   
   public void setDescription(String s);
   
-  
   public String getTypeSystemLocation();
   
   public void setTypeSystemLocation(String s);

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaConstraintFactory.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaConstraintFactory.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaConstraintFactory.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaConstraintFactory.java
 Tue Jun  4 16:59:07 2013
@@ -20,18 +20,15 @@
 package org.apache.uima.ruta.cde;
 
 public class RutaConstraintFactory {
-  
-  public RutaConstraintFactory () {
-    super();
-  }
 
-  public IRutaRuleConstraint createConstraint(String type) {
-    if (type.equals("SimpleTextMarkerConstraint")) {
-      return new SimpleRutaRuleConstraint("","");
-    }
-    if (type.equals("ListTextMarkerConstraint")) {
-      return new RutaRuleListConstraint("","");
+  public static IRutaConstraint createConstraint(String type) {
+    if (type.equals("SimpleRutaRuleConstraint")) {
+      return new SimpleRutaRuleConstraint("", "");
+    } else if (type.equals("RutaRuleListConstraint")) {
+      return new RutaRuleListConstraint("", "");
+    } else if(type.equals("RutaGEConstraint")) {
+      return new RutaGEConstraint("", "");
     }
-  return null;
+    return null;
   }
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaGEConstraint.java
 Tue Jun  4 16:59:07 2013
@@ -59,7 +59,6 @@ public class RutaGEConstraint implements
   }
 
   public Double processConstraint(CAS cas) throws Exception {
-    // TODO Auto-generated method stub
     // Constraint Format: "Peter":Author 0.44, Editor 0.50
     // counts for sysouts, remove later
     int runCount = 0;
@@ -113,10 +112,8 @@ public class RutaGEConstraint implements
 
     Type matchedType = cas.getTypeSystem().getType(
             "org.apache.uima.ruta.type.DebugMatchedRuleMatch");
-    Type ruleApplyType = cas.getTypeSystem().getType(
-            "org.apache.uima.ruta.type.DebugRuleApply");
-    Type blockApplyType = cas.getTypeSystem().getType(
-            "org.apache.uima.ruta.type.DebugBlockApply");
+    Type ruleApplyType = 
cas.getTypeSystem().getType("org.apache.uima.ruta.type.DebugRuleApply");
+    Type blockApplyType = 
cas.getTypeSystem().getType("org.apache.uima.ruta.type.DebugBlockApply");
 
     removeDebugAnnotations(cas, matchedType, ruleApplyType, blockApplyType);
     double applyAmount = 0;
@@ -172,7 +169,6 @@ public class RutaGEConstraint implements
 
     // calculate cosinus similarity for result values:
     return EvaluationMeasures.cosine(results);
-//    return getCosineSimilarity(results);
   }
 
   private void removeDebugAnnotations(CAS cas, Type matchedType, Type 
ruleApplyType,
@@ -199,44 +195,6 @@ public class RutaGEConstraint implements
     return this.description;
   }
 
-  public double getCosineSimilarity(ArrayList<Double[]> results) {
-
-    if (results.size() == 0) {
-      return 0;
-    }
-
-    double sumATimesB = 0;
-    double sumA = 0;
-    double sumB = 0;
-
-    for (Double[] resultPair : results) {
-
-      double a = resultPair[0];
-      double b = resultPair[1];
-
-      sumATimesB += (a * b);
-      sumA += Math.pow(a, 2);
-      sumB += Math.pow(b, 2);
-    }
-
-    if (sumATimesB != 0) {
-      double sqrtA = Math.sqrt(sumA);
-      double sqrtB = Math.sqrt(sumB);
-      double result = sumATimesB / (sqrtA * sqrtB);
-      return result;
-    }
-    return 0;
-
-  }
-
-  public String getConstraintText() {
-    return this.constraintText;
-  }
-
-  public void setConstraintText(String constraintText) {
-    this.constraintText = constraintText;
-  }
-
   public void setDescription(String description) {
     this.description = description;
   }
@@ -244,38 +202,44 @@ public class RutaGEConstraint implements
   public HashMap<String, Double> createRuleSet() {
     HashMap<String, Double> rulesMap = new HashMap<String, Double>();
     try {
-    String content = FileUtils.file2String(new File(constraintText));
-    
-//    System.out.println(content);
-    
-    String[] constraintTextArray = content.split("\n");
-    for (String constraintLine : constraintTextArray) {
-
-      String[] patternAndEstimates = constraintLine.split(":");
-      String pattern = patternAndEstimates[0];
-      pattern = pattern.trim();
-      String estimates = patternAndEstimates[1];
-      String[] singleEstimates = estimates.split(",");
-
-      for (String singleEstimate : singleEstimates) {
-        singleEstimate = singleEstimate.trim();
-        String[] typeAndRatio = singleEstimate.split("\\s+");
-        String typeName = typeAndRatio[0];
-        String ratio = typeAndRatio[1];
-        ratio.trim();
-        String rule = "";
-
-        if (pattern.startsWith("\"")) {
-          rule = pattern + "{PARTOF(" + typeName + ")};";
-        } else {
-          rule = pattern + "{PARTOF(" + typeName + ")};";
+      String content = FileUtils.file2String(new File(constraintText));
+
+      String[] constraintTextArray = content.split("\n");
+      for (String constraintLine : constraintTextArray) {
+
+        String[] patternAndEstimates = constraintLine.split(":");
+        String pattern = patternAndEstimates[0];
+        pattern = pattern.trim();
+        String estimates = patternAndEstimates[1];
+        String[] singleEstimates = estimates.split(",");
+
+        for (String singleEstimate : singleEstimates) {
+          singleEstimate = singleEstimate.trim();
+          String[] typeAndRatio = singleEstimate.split("\\s+");
+          String typeName = typeAndRatio[0];
+          String ratio = typeAndRatio[1];
+          ratio.trim();
+          String rule = "";
+
+          if (pattern.startsWith("\"")) {
+            rule = pattern + "{PARTOF(" + typeName + ")};";
+          } else {
+            rule = pattern + "{PARTOF(" + typeName + ")};";
+          }
+          rulesMap.put(rule, Double.valueOf(ratio));
         }
-        rulesMap.put(rule, Double.valueOf(ratio));
       }
-    }
-    }catch(IOException e) {
+    } catch (IOException e) {
       e.printStackTrace();
     }
     return rulesMap;
   }
+
+  public String getData() {
+    return constraintText;
+  }
+
+  public void setData(String data) {
+    this.constraintText = data;
+  }
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaRuleListConstraint.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaRuleListConstraint.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaRuleListConstraint.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/RutaRuleListConstraint.java
 Tue Jun  4 16:59:07 2013
@@ -186,16 +186,7 @@ public class RutaRuleListConstraint impl
     }
   }
   
-  public String getRule() {
-    return rules;
-  }
-
-  public void setRule(String rule) {
-    this.rules=rule;
-  }
-  
   public String getDescription() {
-    // TODO Auto-generated method stub
     return description;
   }
   
@@ -211,4 +202,12 @@ public class RutaRuleListConstraint impl
     return typeSystemLocation;
   }
 
+  public String getData() {
+    return rules;
+  }
+
+  public void setData(String data) {
+   this.rules = data;
+  }
+
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/SimpleRutaRuleConstraint.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/SimpleRutaRuleConstraint.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/SimpleRutaRuleConstraint.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/SimpleRutaRuleConstraint.java
 Tue Jun  4 16:59:07 2013
@@ -174,14 +174,6 @@ public class SimpleRutaRuleConstraint im
     }
   }
 
-  public String getRule() {
-    return rule;
-  }
-  
-  public void setRule(String rule) {
-    this.rule=rule;
-  }
-
   public String getDescription() {
     return StringUtils.isBlank(description) ? rule : description;
   }
@@ -197,4 +189,13 @@ public class SimpleRutaRuleConstraint im
   public String getTypeSystemLocation() {
     return typeSystemLocation;
   }
+
+  public String getData() {
+    return rule;
+  }
+
+  public void setData(String data) {
+    this.rule = data;    
+  }
+
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintDialog.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintDialog.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintDialog.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintDialog.java
 Tue Jun  4 16:59:07 2013
@@ -57,7 +57,7 @@ public class ConstraintDialog extends Di
 
   public void create(SimpleRutaRuleConstraint constraint) {
     super.create();
-    rule = constraint.getRule();
+    rule = constraint.getData();
     description = constraint.getDescription();
 
     ruleText.setText(rule);
@@ -66,7 +66,7 @@ public class ConstraintDialog extends Di
 
   public void create(RutaRuleListConstraint constraint) {
     super.create();
-    rule = constraint.getRule();
+    rule = constraint.getData();
     description = constraint.getDescription();
 
     ruleText.setText(rule);
@@ -75,7 +75,7 @@ public class ConstraintDialog extends Di
   
   public void create (RutaGEConstraint constraint) {
     super.create();
-    rule = constraint.getConstraintText();
+    rule = constraint.getData();
     description = constraint.getDescription();
 
     ruleText.setText(rule);
@@ -87,52 +87,6 @@ public class ConstraintDialog extends Di
     GridLayout layout = new GridLayout();
     layout.numColumns = 3;
     parent.setLayout(layout);
-    // Label label0 = new Label(parent, SWT.FILL);
-    // label0.setText("TypeSystem :");
-    //
-    // GridData label0GridData = new GridData();
-    // label0GridData.grabExcessVerticalSpace = true;
-    // label0GridData.horizontalAlignment = GridData.CENTER;
-    // label0GridData.verticalAlignment = GridData.CENTER;
-    // label0GridData.minimumHeight = 25;
-    // label0GridData.horizontalSpan = 1;
-    // label0GridData.verticalIndent = 5;
-    // label0.setLayoutData(label0GridData);
-    //
-    // dirText = new Text(parent, SWT.SINGLE | SWT.BORDER);
-    //
-    //
-    //
-    // dirButton = new Button(parent, SWT.PUSH);
-    // dirButton.setSize(25, 25);
-    // GridData buttonGridData = new GridData();
-    // buttonGridData.horizontalAlignment = GridData.CENTER;
-    // buttonGridData.verticalAlignment = GridData.CENTER;
-    // buttonGridData.horizontalSpan = 1;
-    // Image folderIcon = getImage("folder");
-    // dirButton.setImage(folderIcon);
-    // buttonGridData.minimumHeight = 25;
-    // buttonGridData.minimumWidth = 25;
-    // dirButton.setLayoutData(buttonGridData);
-    // dirButton.addSelectionListener(new SelectionAdapter() {
-    // @Override
-    // public void widgetSelected(SelectionEvent event) {
-    // FileDialog dlg = new FileDialog(getShell());
-    // dlg.setText("Input Directory");
-    // String dir = dlg.open();
-    // if (dir != null) {
-    // File f = new File(dir);
-    // dirText.setText(f.getAbsolutePath());
-    // }
-    // }
-    // });
-    //
-    // GridData dirTextGridData = new GridData();
-    // dirTextGridData.grabExcessHorizontalSpace = true;
-    // dirTextGridData.horizontalAlignment = GridData.FILL;
-    // dirTextGridData.horizontalSpan = 1;
-    // dirTextGridData.minimumHeight = 25;
-    // dirText.setLayoutData(dirTextGridData);
 
     Label label1 = new Label(parent, SWT.FILL);
     label1.setText("Constraint Rule :");

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java
 Tue Jun  4 16:59:07 2013
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.uima.ruta.addons.RutaAddonsPlugin;
 import org.apache.uima.ruta.cde.IRutaConstraint;
@@ -91,7 +92,7 @@ public class ConstraintSelectComposite e
 
   private TableEditor editor;
 
-  private ArrayList<ConstraintData> constraintList;
+  private List<ConstraintData> constraintList;
 
   private int EDITABLECOLUMN = 1;
 
@@ -438,7 +439,7 @@ public class ConstraintSelectComposite e
     return images.get(name);
   }
 
-  public ArrayList<ConstraintData> getConstraintList() {
+  public List<ConstraintData> getConstraintList() {
     return this.constraintList;
   }
 
@@ -452,7 +453,7 @@ public class ConstraintSelectComposite e
         IMemento currentMemento = memento.createChild("constraint", 
"SimpleRutaConstraint");
         SimpleRutaRuleConstraint constraint = (SimpleRutaRuleConstraint) 
constraintData
                 .getConstraint();
-        currentMemento.createChild("Rule", constraint.getRule());
+        currentMemento.createChild("Rule", constraint.getData());
         currentMemento.createChild("Description", constraint.getDescription());
       }
 
@@ -460,14 +461,14 @@ public class ConstraintSelectComposite e
         IMemento currentMemento = memento.createChild("constraint", 
"ListRutaConstraint");
         RutaRuleListConstraint constraint = (RutaRuleListConstraint) 
constraintData
                 .getConstraint();
-        currentMemento.createChild("Rule", constraint.getRule());
+        currentMemento.createChild("Rule", constraint.getData());
         currentMemento.createChild("Description", constraint.getDescription());
       }
 
       if (constraintData.getConstraint() instanceof RutaGEConstraint) {
         IMemento currentMemento = memento.createChild("constraint", 
"GEConstraint");
         RutaGEConstraint constraint = (RutaGEConstraint) 
constraintData.getConstraint();
-        currentMemento.createChild("Rule", constraint.getConstraintText());
+        currentMemento.createChild("Rule", constraint.getData());
         currentMemento.createChild("Description", constraint.getDescription());
       }
     }
@@ -505,12 +506,7 @@ public class ConstraintSelectComposite e
     return RutaAddonsPlugin.getImageDescriptor(path).createImage();
   }
 
-  // public void exportConstraint (ConstraintData data) {
-  // String type = "";
-  // String ruleText = "";
-  // String description = "";
-  // }
-  public void setConstraints(ArrayList<ConstraintData> constraints) {
+  public void setConstraints(List<ConstraintData> constraints) {
     this.constraintList = constraints;
   }
   

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectTableLabelProvider.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectTableLabelProvider.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectTableLabelProvider.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectTableLabelProvider.java
 Tue Jun  4 16:59:07 2013
@@ -52,7 +52,7 @@ public class ConstraintSelectTableLabelP
                        if(columnIndex == 0) {
                          if(StringUtils.isBlank(data.getDescription()) && 
data.getConstraint() instanceof SimpleRutaRuleConstraint) {
                            SimpleRutaRuleConstraint c = 
(SimpleRutaRuleConstraint) data.getConstraint();
-                           return c.getRule();
+                           return c.getData();
                          } else {
                            return data.getDescription();
                          }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentViewRunHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentViewRunHandler.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentViewRunHandler.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/DocumentViewRunHandler.java
 Tue Jun  4 16:59:07 2013
@@ -24,6 +24,7 @@ import java.io.FileInputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.cas.CAS;
@@ -103,15 +104,15 @@ public class DocumentViewRunHandler impl
 
   private class DocumentViewRunHandlerJob extends Job {
 
-    private ArrayList<ConstraintData> constraints;
+    private List<ConstraintData> constraints;
 
-    private ArrayList<DocumentData> documents;
+    private List<DocumentData> documents;
 
     private File typeSystem;
 
     private String testDataPath;
 
-    DocumentViewRunHandlerJob(ExecutionEvent event, ArrayList<ConstraintData> 
constraints,
+    DocumentViewRunHandlerJob(ExecutionEvent event, List<ConstraintData> 
constraints,
             ArrayList<DocumentData> documents, File typeSystem, String 
testDataPath) {
       super("UIMA Ruta CDE");
       this.constraints = constraints;
@@ -213,7 +214,7 @@ public class DocumentViewRunHandler impl
               .showView("org.apache.uima.ruta.cde.ui.ConstraintSelectView");
       ConstraintSelectComposite composite = (ConstraintSelectComposite) 
constraintView
               .getComposite();
-      ArrayList<ConstraintData> constraintList = composite.getConstraintList();
+      List<ConstraintData> constraintList = composite.getConstraintList();
       DocumentView docView = (DocumentView) 
HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench()
               .getActiveWorkbenchWindow().getActivePage()
               .showView("org.apache.uima.ruta.cde.ui.DocumentView");

Copied: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportConstraintsHandler.java
 (from r1489049, 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportAllConstraintsHandler.java)
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportConstraintsHandler.java?p2=uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportConstraintsHandler.java&p1=uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportAllConstraintsHandler.java&r1=1489049&r2=1489514&rev=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportAllConstraintsHandler.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ExportConstraintsHandler.java
 Tue Jun  4 16:59:07 2013
@@ -19,80 +19,59 @@
 
 package org.apache.uima.ruta.cde.ui;
 
-import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.uima.ruta.addons.RutaAddonsPlugin;
 import org.apache.uima.ruta.cde.utils.ConstraintData;
-import org.apache.uima.ruta.cde.utils.ConstraintXMLExporter;
+import org.apache.uima.ruta.cde.utils.ConstraintXMLUtils;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-public class ExportAllConstraintsHandler implements IHandler {
+public class ExportConstraintsHandler implements IHandler {
 
   private class ExportAllConstraintsJob extends Job {
 
-    private IPath outputPath;
+    private String outputLocation;
 
-    private ArrayList<ConstraintData> constraints;
+    private List<ConstraintData> constraints;
 
-    ExportAllConstraintsJob(IPath outputPath, ArrayList<ConstraintData> 
constraints) {
-      super("Exporting all the constraints");
-      this.outputPath = outputPath;
+    ExportAllConstraintsJob(String outputLocation, List<ConstraintData> 
constraints) {
+      super("Exporting constraints");
+      this.outputLocation = outputLocation;
       this.constraints = constraints;
-
     }
 
     public IStatus run(IProgressMonitor monitor) {
-      ConstraintXMLExporter exporter = new ConstraintXMLExporter(constraints);
       try {
-        exporter.saveConstraints(outputPath);
-        
-        
//ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(outputPath).getParent().refreshLocal(1,
 monitor);
-        
-        
+        ConstraintXMLUtils.writeConstraints(outputLocation, constraints);
+        IPath path = Path.fromPortableString(outputLocation);
+        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+        IFile ifile = root.getFileForLocation(path);
+        if(ifile != null) {
+          ifile.getParent().refreshLocal(IResource.DEPTH_INFINITE, monitor);
+        }
       } catch (Exception e) {
-        e.printStackTrace();
+        RutaAddonsPlugin.error(e);
       }
       return Status.OK_STATUS;
     }
   }
 
-  private class ExportAllConstraintsJobAdapter extends JobChangeAdapter {
-
-    private ConstraintSelectComposite composite;
-
-    ExportAllConstraintsJobAdapter(ConstraintSelectComposite composite) {
-      super();
-      this.composite = composite;
-    }
-
-    public void done(IJobChangeEvent event) {
-      if (event.getResult().isOK()) {
-        composite.getDisplay().asyncExec(new Runnable() {
-          public void run() {
-            try {
-
-            } catch (Exception e) {
-
-            }
-          }
-        });
-      }
-    }
-  }
-
   public void addHandlerListener(IHandlerListener arg0) {
   }
 
@@ -104,12 +83,8 @@ public class ExportAllConstraintsHandler
     FileDialog dlg = new FileDialog(HandlerUtil.getActiveShell(event), 
SWT.SAVE);
     String[] extensions = new String[] { "*.xml" };
     dlg.setFilterExtensions(extensions);
-//    String test = dlg.open();
     String s = dlg.open();
-    IPath outputPath = null;
-    if (s != null) {
-      outputPath = Path.fromPortableString(s);
-    } else {
+    if (s == null) {
       return Status.CANCEL_STATUS;
     }
     ConstraintSelectView constraintView;
@@ -123,15 +98,11 @@ public class ExportAllConstraintsHandler
               .showView("org.apache.uima.ruta.cde.ui.ConstraintSelectView");
       ConstraintSelectComposite composite = (ConstraintSelectComposite) 
constraintView
               .getComposite();
-      ArrayList<ConstraintData> constraintList = composite.getConstraintList();
-      
-
-      
-      ExportAllConstraintsJob job = new ExportAllConstraintsJob(outputPath, 
constraintList);
+      List<ConstraintData> constraintList = composite.getConstraintList();
+      ExportAllConstraintsJob job = new ExportAllConstraintsJob(s, 
constraintList);
       job.schedule();
-
     } catch (Exception e) {
-      e.printStackTrace();
+      RutaAddonsPlugin.error(e);
     }
     return null;
   }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ImportConstraintsHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ImportConstraintsHandler.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ImportConstraintsHandler.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ImportConstraintsHandler.java
 Tue Jun  4 16:59:07 2013
@@ -19,18 +19,16 @@
 
 package org.apache.uima.ruta.cde.ui;
 
-import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.uima.ruta.cde.utils.ConstraintData;
-import org.apache.uima.ruta.cde.utils.ConstraintXMLImporter;
+import org.apache.uima.ruta.cde.utils.ConstraintXMLUtils;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.commands.IHandlerListener;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.SWT;
@@ -41,26 +39,22 @@ public class ImportConstraintsHandler im
   
   private class ImportJob extends Job {
    
-    IPath inputPath;
+    String inputLocation;
     ConstraintSelectComposite composite;
-    ArrayList<ConstraintData> constraints;
     
-    public ImportJob(ExecutionEvent event, ConstraintSelectComposite 
composite, IPath inputPath) {
+    public ImportJob(ExecutionEvent event, ConstraintSelectComposite 
composite, String inputLocation) {
       super("Importing constraints");
-      this.inputPath = inputPath; 
+      this.inputLocation = inputLocation; 
       this.composite = composite;
-      constraints = new ArrayList<ConstraintData>();
     }
 
     protected IStatus run(IProgressMonitor monitor) {
-      ConstraintXMLImporter importer = new ConstraintXMLImporter();
       try {
-        constraints = importer.readXML(inputPath);
-        composite.setConstraints(constraints);
+        final List<ConstraintData> constraints = 
ConstraintXMLUtils.readConstraints(inputLocation);
         composite.getDisplay().asyncExec(new Runnable() {
           public void run() {
-            composite.setConstraints(constraints);
-            composite.getViewer().setInput(constraints);
+            composite.getConstraintList().addAll(constraints);
+            composite.getViewer().setInput(composite.getConstraintList());
             composite.getViewer().refresh();
             composite.update();
           } 
@@ -95,9 +89,7 @@ public class ImportConstraintsHandler im
     dlg.setFilterExtensions(extensions);
     String s = dlg.open();
     if (s != null) {
-      IPath path = Path.fromPortableString(s);
-      ImportJob job = new ImportJob(event, composite, path);
-      
+      ImportJob job = new ImportJob(event, composite, s);
       job.schedule();
     } else {
       return Status.CANCEL_STATUS;

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/CDEComparatorFactory.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/CDEComparatorFactory.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/CDEComparatorFactory.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/CDEComparatorFactory.java
 Tue Jun  4 16:59:07 2013
@@ -26,139 +26,127 @@ import java.util.Locale;
 import org.eclipse.swt.widgets.TableColumn;
 
 public class CDEComparatorFactory {
-  
+
   private int updown;
-  
-  public CDEComparatorFactory () {
+
+  public CDEComparatorFactory() {
     updown = 1;
   }
-  
-  private Comparator<DocumentData> stringDocumentComparator = new Comparator 
<DocumentData>() {
+
+  private Comparator<DocumentData> stringDocumentComparator = new 
Comparator<DocumentData>() {
 
     public int compare(DocumentData object1, DocumentData object2) {
       Collator collator = Collator.getInstance();
-      
+
       String docName1 = object1.getDocument().getName();
       String docName2 = object2.getDocument().getName();
-      
+
       int result = collator.compare(docName1, docName2) * updown;
       return result;
     }
   };
 
-  private Comparator<DocumentData> resultComparator = new Comparator 
<DocumentData> () {
-    
+  private Comparator<DocumentData> resultComparator = new 
Comparator<DocumentData>() {
+
     public int compare(DocumentData object1, DocumentData object2) {
-     
+
       double augment1 = object1.getAugmentedResult();
       double augment2 = object2.getAugmentedResult();
-      
+
       if (augment1 <= augment2) {
         return 1 * updown;
-      } 
-      else {
-        return -1 *updown;
+      } else {
+        return -1 * updown;
       }
-      
+
     }
   };
-  
-  
-private Comparator<DocumentData> f1ScoreComparator = new Comparator 
<DocumentData> () {
-    
+
+  private Comparator<DocumentData> f1ScoreComparator = new 
Comparator<DocumentData>() {
+
     public int compare(DocumentData object1, DocumentData object2) {
-     
+
       double augment1 = object1.getFMeasure();
       double augment2 = object2.getFMeasure();
-      
+
       if (augment1 <= augment2) {
         return 1 * updown;
-      } 
-      else {
-        return -1 *updown;
+      } else {
+        return -1 * updown;
       }
-      
+
     }
   };
-  
-  
-  
-  
-  private Comparator<ConstraintData> stringConstraintComparator = new 
Comparator <ConstraintData>() {
+
+  private Comparator<ConstraintData> stringConstraintComparator = new 
Comparator<ConstraintData>() {
 
     public int compare(ConstraintData object1, ConstraintData object2) {
       Collator collator = Collator.getInstance();
-      
+
       String constraintName1 = object1.getDescription();
       String constraintName2 = object2.getDescription();
-      
+
       int result = collator.compare(constraintName1, constraintName2) * updown;
       return result;
     }
-    
+
   };
-  
-  private Comparator<ConstraintData> intConstraintComparator = new Comparator 
<ConstraintData> () {
-    
-    public int compare(ConstraintData object1, ConstraintData object2) {;
-      
+
+  private Comparator<ConstraintData> intConstraintComparator = new 
Comparator<ConstraintData>() {
+
+    public int compare(ConstraintData object1, ConstraintData object2) {
+      ;
+
       int weight1 = object1.getWeight();
       int weight2 = object2.getWeight();
-      
-      return (weight1-weight2) * updown;
+
+      return (weight1 - weight2) * updown;
     }
-    
+
   };
-  
-  private Comparator <String[]> resultNameComparator = new 
Comparator<String[]> () {
+
+  private Comparator<String[]> resultNameComparator = new 
Comparator<String[]>() {
     public int compare(String[] object1, String[] object2) {
-      
+
       Collator collator = Collator.getInstance(Locale.getDefault());
       int result = collator.compare(object1[0], object2[0]) * updown;
       return result;
     }
   };
-  
-  private Comparator <String[]> resultValueComparator = new 
Comparator<String[]> () {
-    public int compare(String[] object1, String[] object2) {  
+
+  private Comparator<String[]> resultValueComparator = new 
Comparator<String[]>() {
+    public int compare(String[] object1, String[] object2) {
       double result1 = Double.valueOf(object1[1]);
       double result2 = Double.valueOf(object2[1]);
       if (result1 >= result2)
         return 1 * updown;
       else {
-        return -1 *updown;
+        return -1 * updown;
       }
     }
   };
-  
-  public Comparator getComparator (TableColumn tc) {
+
+  public Comparator getComparator(TableColumn tc) {
     this.updown = updown * (-1);
     String columnName = tc.getText();
 
-    if(columnName.equals("CDE")) {
+    if (columnName.equals("CDE")) {
       return resultComparator;
     }
-    if(columnName.equals( "F1")) {
+    if (columnName.equals("F1")) {
       return f1ScoreComparator;
-    }
-    else if (columnName.equals("Document")) {
+    } else if (columnName.equals("Document")) {
       return stringDocumentComparator;
-    }
-    else if (columnName.equals("Constraint")) {
+    } else if (columnName.equals("Constraint")) {
       return stringConstraintComparator;
-    }
-    else if (columnName.equals("Weight")) {
-    return intConstraintComparator;
-    }
-    else if (columnName.equals("Constraint ")) {
+    } else if (columnName.equals("Weight")) {
+      return intConstraintComparator;
+    } else if (columnName.equals("Constraint ")) {
       return resultNameComparator;
-    }
-    else if (columnName.equals("Result")) {
+    } else if (columnName.equals("Result")) {
       return resultValueComparator;
     }
     return Collator.getInstance();
   }
-  
-  
-}
 
+}

Added: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintContentHandler.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintContentHandler.java?rev=1489514&view=auto
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintContentHandler.java
 (added)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintContentHandler.java
 Tue Jun  4 16:59:07 2013
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.cde.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.ruta.cde.IRutaConstraint;
+import org.apache.uima.ruta.cde.RutaConstraintFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class ConstraintContentHandler extends DefaultHandler {
+
+  private List<ConstraintData> constraints = new ArrayList<ConstraintData>();
+
+  private ConstraintData current = null;
+
+  private String currentString;
+
+  public void startElement(String uri, String localName, String qName, 
Attributes attributes) {
+    if (localName.equals("constraint")) {
+      String type = attributes.getValue("type");
+      String weight = attributes.getValue("weight");
+      IRutaConstraint c = RutaConstraintFactory.createConstraint(type);
+      current = new ConstraintData(c);
+      current.setWeight(Integer.valueOf(weight));
+    } 
+  }
+
+  public void characters(char[] ch, int start, int length) {
+    currentString = new String(ch, start, length);
+  }
+
+  public void endElement(String uri, String localName, String qName) {
+    if (localName.equals("constraint")) {
+      constraints.add(current);
+    } else if (localName.equals("data")) {
+      current.getConstraint().setData(currentString);
+    } else if (localName.equals("description")) {
+      current.getConstraint().setDescription(currentString);
+    }
+  }
+
+  public List<ConstraintData> getConstraints() {
+    return constraints;
+  }
+
+}

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintData.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintData.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintData.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintData.java
 Tue Jun  4 16:59:07 2013
@@ -22,35 +22,54 @@ package org.apache.uima.ruta.cde.utils;
 import org.apache.uima.ruta.cde.IRutaConstraint;
 
 public class ConstraintData {
-       
-       private IRutaConstraint constraint;
-       
-       private int weight;
-
-       public ConstraintData (IRutaConstraint constraint) {
-               this.constraint = constraint;
-               weight  =  1;
-       }
-
-       public int getWeight() {
-               return weight;
-       }
-
-       public void setWeight(int weight) {
-               this.weight = weight;
-       }
-
-       public IRutaConstraint getConstraint () {
-               return constraint;
-       }
-       
-       public void setConstraint (IRutaConstraint constraint) {
-               this.constraint= constraint;
-       }
-       
-       public String getDescription () {
-               return constraint.getDescription();
-       }
-       
+
+  private IRutaConstraint constraint;
+
+  private int weight;
+
+  public ConstraintData(IRutaConstraint constraint) {
+    this.constraint = constraint;
+    weight = 1;
+  }
+
+  public int getWeight() {
+    return weight;
+  }
+
+  public void setWeight(int weight) {
+    this.weight = weight;
+  }
+
+  public IRutaConstraint getConstraint() {
+    return constraint;
+  }
+
+  public void setConstraint(IRutaConstraint constraint) {
+    this.constraint = constraint;
+  }
+
+  public String getDescription() {
+    return constraint.getDescription();
+  }
+
+  public String toXML() {
+    StringBuilder sb = new StringBuilder();
+    sb.append("<constraint type=\"" + constraint.getClass().getSimpleName() + 
"\" weight=\""+weight+"\">");
+    sb.append("\n");
+    sb.append("<data>");
+    sb.append("<![CDATA[");
+    sb.append(constraint.getData());
+    sb.append("]]>");
+    sb.append("</data>");
+    sb.append("\n");
+    sb.append("<description>");
+    sb.append("<![CDATA[");
+    sb.append(getDescription());
+    sb.append("]]>");
+    sb.append("</description>");
+    sb.append("\n");
+    sb.append("</constraint>");
+    return sb.toString();
+  }
 
 }

Copied: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLUtils.java
 (from r1489049, 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLExporter.java)
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLUtils.java?p2=uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLUtils.java&p1=uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLExporter.java&r1=1489049&r2=1489514&rev=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLExporter.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/ConstraintXMLUtils.java
 Tue Jun  4 16:59:07 2013
@@ -19,113 +19,39 @@
 
 package org.apache.uima.ruta.cde.utils;
 
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IPath;
-
-@SuppressWarnings("restriction")
-public class ConstraintXMLExporter {
-
-  IPath outputPath;
-
-  ArrayList<ConstraintData> constraints;
-
-  public ConstraintXMLExporter(ArrayList<ConstraintData> constraints) {
-    this.outputPath = outputPath;
-    this.constraints = constraints;
+import java.io.File;
+import java.io.FileReader;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+public class ConstraintXMLUtils {
+
+  public static void writeConstraints(String location, List<ConstraintData> 
constraints)
+          throws Exception {
+    StringBuilder sb = new StringBuilder();
+    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+    sb.append("\n");
+    sb.append("<constraints>");
+    sb.append("\n");
+    for (ConstraintData eachConstraint : constraints) {
+      sb.append(eachConstraint.toXML());
+      sb.append("\n");
+    }
+    sb.append("</constraints>");
+    FileUtils.writeStringToFile(new File(location), sb.toString(), "UTF-8");
   }
 
-  public void saveConstraints(IPath outputPath) throws Exception {
-    
-//    IWorkspace workspace = ResourcesPlugin.getWorkspace();
-//    IWorkspaceRoot root = workspace.getRoot();
-//    String rootPath = root.getRawLocation().toPortableString();
-      
-//      if(outputPath.getFileExtension() == null) {
-//        outputPath = outputPath.addFileExtension("xml");
-//        
-//        System.out.println("adsf :" + outputPath.toOSString());
-//      } else if
-//      
-//      (!outputPath.getFileExtension().equals("xml")) {
-//        outputPath.removeFileExtension();
-//        outputPath = outputPath.addFileExtension("xml");
-//    }
-    
-//    String absolutPath = rootPath + System.getProperty("file.separator")  +  
 outputPath.toOSString();
-//    String absolutPath = outputPath.toOSString();
-//     File file = new File(absolutPath);
-//     
-// 
-//     file.createNewFile();
-//     
-//
-//     
-//    // outputPath = Path.fromOSString("C:/test/test1.xml");
-//    // Create a XMLOutputFactory
-//    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
-//    // Create XMLEventWriter
-//    XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new 
FileOutputStream(absolutPath));
-//    // Create a EventFactory
-//    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
-//    XMLEvent end = eventFactory.createDTD("\n");
-//    // Create and write Start Tag
-//    StartDocument startDocument = eventFactory.createStartDocument();
-//    eventWriter.add(startDocument);
-//    StartElement constraintListStartElement = 
eventFactory.createStartElement("", "",
-//            "constraintList");
-//    eventWriter.add(constraintListStartElement);
-//    eventWriter.add(end);
-//
-//    for (ConstraintData data : constraints) {
-//      String constraintType = "";
-//      if (data.getConstraint() instanceof IAugurTMConstraint) {
-//        IAugurTMConstraint constraint = (IAugurTMConstraint) 
data.getConstraint();
-//
-//        if (constraint instanceof SimpleRutaConstraint) {
-//          constraintType = "SimpleRutaConstraint";
-//
-//        }
-//        if (constraint instanceof ListRutaConstraint) {
-//          constraintType = "ListRutaConstraint";
-//        }
-//
-//        StartElement constraintStartElement = 
eventFactory.createStartElement("", "",
-//                constraintType);
-//        eventWriter.add(constraintStartElement);
-//        eventWriter.add(end);
-//
-//        createNode(eventWriter, "rule", constraint.getRule());
-//      }
-//      createNode(eventWriter, "description", data.getDescription());
-//      createNode(eventWriter, "weight", String.valueOf(data.getWeight()));
-//      eventWriter.add(eventFactory.createEndElement("", "", constraintType));
-//      eventWriter.add(end);
-//    }
-//    eventWriter.add(eventFactory.createEndElement("", "", "constraintList"));
-//    eventWriter.add(end);
-//    eventWriter.add(eventFactory.createEndDocument());
-//    eventWriter.close();
+  public static List<ConstraintData> readConstraints(String location) throws 
Exception {
+    XMLReader xmlReader = XMLReaderFactory.createXMLReader();
+    FileReader reader = new FileReader(location);
+    InputSource inputSource = new InputSource(reader);
+    ConstraintContentHandler handler = new ConstraintContentHandler();
+    xmlReader.setContentHandler(handler);
+    xmlReader.parse(inputSource);
+    return handler.getConstraints();
   }
-
-//  private void createNode(XMLEventWriter eventWriter, String name, String 
value)
-//          throws XMLStreamException {
-//
-//    XMLEventFactory eventFactory = XMLEventFactory.newInstance();
-//    XMLEvent end = eventFactory.createDTD("\n");
-//    XMLEvent tab = eventFactory.createDTD("\t");
-//    // Create Start node
-//    StartElement sElement = eventFactory.createStartElement("", "", name);
-//    eventWriter.add(tab);
-//    eventWriter.add(sElement);
-//    // Create Content
-//    Characters characters = eventFactory.createCharacters(value);
-//    eventWriter.add(characters);
-//    // Create End node
-//    EndElement eElement = eventFactory.createEndElement("", "", name);
-//    eventWriter.add(eElement);
-//    eventWriter.add(end);
-//
-//  }
-
 }

Modified: 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java?rev=1489514&r1=1489513&r2=1489514&view=diff
==============================================================================
--- 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java
 (original)
+++ 
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java
 Tue Jun  4 16:59:07 2013
@@ -20,15 +20,12 @@
 package org.apache.uima.ruta.cde.utils;
 
 import java.text.DecimalFormat;
-import java.text.NumberFormat;
 import java.util.ArrayList;
 import java.util.Locale;
 
 import org.apache.commons.math3.linear.ArrayRealVector;
 import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;
 import org.apache.commons.math3.stat.correlation.SpearmansCorrelation;
-import org.apache.commons.math3.stat.inference.ChiSquareTest;
-import org.apache.commons.math3.stat.inference.TestUtils;
 
 public class EvaluationMeasures {
 


Reply via email to