This is an automated email from the ASF dual-hosted git repository.

pkluegl pushed a commit to branch 
bugfix/139-Unexpected-behavior-of-plus-operator
in repository https://gitbox.apache.org/repos/asf/uima-ruta.git


The following commit(s) were added to 
refs/heads/bugfix/139-Unexpected-behavior-of-plus-operator by this push:
     new 2fef068e Issue #139: Unexpected behavior of plus operator
2fef068e is described below

commit 2fef068e19a4a73b82d420b0ef6f17fd6bf7e96a
Author: kluegl <[email protected]>
AuthorDate: Fri Oct 13 12:04:28 2023 +0200

    Issue #139: Unexpected behavior of plus operator
    
    - fixed rule inference
    - some cleanup
---
 .../apache/uima/ruta/rule/ComposedRuleElement.java | 37 ++++++++++++
 .../ComposedRuleElementWithQuantifierTest.java     | 65 +++++++++++-----------
 ruta-ep-engine/pom.xml                             |  2 +
 .../textruler/learner/kep/KEPPreferencePage.java   | 18 +++---
 .../learner/lp2/NaiveLP2PreferencePage.java        | 18 +++---
 .../learner/lp2/OptimizedLP2PreferencePage.java    | 18 +++---
 .../learner/rapier/RapierPreferencePage.java       | 23 +++++---
 .../whisk/generic/WhiskGenericPreferencePage.java  | 18 +++---
 .../whisk/token/WhiskTokenPreferencePage.java      | 18 +++---
 9 files changed, 141 insertions(+), 76 deletions(-)

diff --git 
a/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java 
b/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
index ade9153b..7663fd8a 100644
--- a/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
+++ b/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
@@ -23,6 +23,7 @@ import static java.util.Arrays.asList;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -498,6 +499,42 @@ public class ComposedRuleElement extends 
AbstractRuleElement implements RuleElem
     if (evaluateMatches.isEmpty()) {
       return annotation;
     }
+
+    // ensure correct ordering
+    Collections.sort(evaluateMatches, new Comparator<RuleElementMatch>() {
+
+      @Override
+      public int compare(RuleElementMatch rem1, RuleElementMatch rem2) {
+        List<AnnotationFS> textsMatched1 = rem1.getTextsMatched();
+        List<AnnotationFS> textsMatched2 = rem2.getTextsMatched();
+        if ((textsMatched1 == null || textsMatched1.isEmpty())
+                && (textsMatched2 == null || textsMatched2.isEmpty())) {
+          return 0;
+        }
+        if (textsMatched1 == null
+                || textsMatched1.isEmpty() && !(textsMatched2 == null || 
textsMatched2.isEmpty())) {
+          return -1;
+        }
+        if (!(textsMatched1 == null || textsMatched1.isEmpty())
+                && (textsMatched2 == null || textsMatched2.isEmpty())) {
+          return 1;
+        }
+        if (textsMatched1.equals(textsMatched2)) {
+          return 0;
+        }
+        AnnotationFS first1 = textsMatched1.get(0);
+        AnnotationFS last1 = textsMatched1.get(textsMatched1.size() - 1);
+        AnnotationFS first2 = textsMatched2.get(0);
+        AnnotationFS last2 = textsMatched2.get(textsMatched2.size() - 1);
+        int compareBegin = Integer.compare(first1.getBegin(), 
first2.getBegin());
+        if (compareBegin != 0) {
+          return compareBegin;
+        }
+        int compareEnd = Integer.compare(last1.getEnd(), last2.getEnd());
+        return compareEnd;
+      }
+    });
+
     if (after) {
       List<AnnotationFS> textsMatched = 
evaluateMatches.get(evaluateMatches.size() - 1)
               .getTextsMatched();
diff --git 
a/ruta-core/src/test/java/org/apache/uima/ruta/rule/ComposedRuleElementWithQuantifierTest.java
 
b/ruta-core/src/test/java/org/apache/uima/ruta/rule/ComposedRuleElementWithQuantifierTest.java
index fa749a69..03450c32 100644
--- 
a/ruta-core/src/test/java/org/apache/uima/ruta/rule/ComposedRuleElementWithQuantifierTest.java
+++ 
b/ruta-core/src/test/java/org/apache/uima/ruta/rule/ComposedRuleElementWithQuantifierTest.java
@@ -6,9 +6,9 @@
  * 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
@@ -27,51 +27,52 @@ import org.junit.jupiter.api.Test;
 public class ComposedRuleElementWithQuantifierTest {
 
   @Test
-  public void test() {
+  public void test() throws Exception {
     String document = "Bla DDD, Bla, DDD,DDD, Bla, DDD,DDD Bla.";
     String script = "";
     script += "\"DDD\" -> T1;\n";
     script += "(T1 COMMA)+? (T1 W){->MARKONCE(T2,1,2)};\n";
-    CAS cas = null;
-    try {
-      cas = RutaTestUtils.getCAS(document);
-      Ruta.apply(cas, script);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script);
 
     RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "DDD,DDD Bla");
 
     cas.release();
   }
-  
+
   @Test
-  public void testStackedWithWildCard() {
+  public void testStackedWithWildCard() throws Exception {
     String document = "some text\n 1 HEADLINE\n some text";
     String script = "";
-    
-    script +="\"1 HEADLINE\"-> T1;\n";
-    script +="DOUBLE n;\n";
-    script +="BLOCK(eachTag) T1{} {\n";
-    script +="((NUM{STARTSWITH(T1)} (PERIOD NUM)?){PARSE(n)} (W #){-> T2})\n";
-    script +=" {-> T3};\n";
-    script +="}\n";
-    
-    CAS cas = null;
-    try {
-      cas = RutaTestUtils.getCAS(document);
-      Ruta.apply(cas, script);
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
+
+    script += "\"1 HEADLINE\"-> T1;\n";
+    script += "DOUBLE n;\n";
+    script += "BLOCK(eachTag) T1{} {\n";
+    script += "((NUM{STARTSWITH(T1)} (PERIOD NUM)?){PARSE(n)} (W #){-> T2})\n";
+    script += " {-> T3};\n";
+    script += "}\n";
+
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script);
 
     RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "HEADLINE");
     RutaTestUtils.assertAnnotationsEquals(cas, 3, 1, "1 HEADLINE");
+  }
 
-    cas.release();
-    
+  @Test
+  public void testRightToLeftMatching() throws Exception {
+    String document = "Indicator x y z a";
+
+    String script = "";
+    script += "\"Indicator\"-> T1;\n";
+    script += "SW{REGEXP(\"a\")-> T2};";
+    script += "T1 (SW)+ @T2{-> T3};";
+
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script);
+
+    RutaTestUtils.assertAnnotationsEquals(cas, 1, 1, "Indicator");
+    RutaTestUtils.assertAnnotationsEquals(cas, 2, 1, "a");
+    RutaTestUtils.assertAnnotationsEquals(cas, 3, 1, "a");
   }
-  
-  
-  
 }
diff --git a/ruta-ep-engine/pom.xml b/ruta-ep-engine/pom.xml
index 805300ff..3f8b84b9 100644
--- a/ruta-ep-engine/pom.xml
+++ b/ruta-ep-engine/pom.xml
@@ -234,10 +234,12 @@
                   org.htmlparser.*,
                   org.apache.commons.text.*,
                   org.apache.commons.lang3.*,
+                  org.apache.commons.collections4.*,
                   org.apache.commons.logging,
                   org.apache.commons.io.*,
                   org.apache.uima.fit.*,
                   org.apache.commons.math3.*,
+                  com.github.benmanes.caffeine.cache.*,
                   org.springframework.*
                 </_exportcontents>
 
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPPreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPPreferencePage.java
index 7be2a1b5..13315fd1 100644
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPPreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/kep/KEPPreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -48,12 +48,12 @@ public class KEPPreferencePage extends PreferencePage 
implements IWorkbenchPrefe
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public KEPPreferencePage() {
     TextRulerLearnerController ctrl = TextRulerController
             .getControllerForID("org.apache.uima.ruta.textruler.kep");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
@@ -84,6 +84,7 @@ public class KEPPreferencePage extends PreferencePage 
implements IWorkbenchPrefe
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, top);
             fields.add(l);
@@ -100,20 +101,23 @@ public class KEPPreferencePage extends PreferencePage 
implements IWorkbenchPrefe
     return top;
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/NaiveLP2PreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/NaiveLP2PreferencePage.java
index d89be2d4..c40ecb3a 100755
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/NaiveLP2PreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/NaiveLP2PreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -48,12 +48,12 @@ public class NaiveLP2PreferencePage extends PreferencePage 
implements IWorkbench
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public NaiveLP2PreferencePage() {
     TextRulerLearnerController ctrl = TextRulerController
             .getControllerForID("org.apache.uima.ruta.textruler.lp2naive");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
@@ -84,6 +84,7 @@ public class NaiveLP2PreferencePage extends PreferencePage 
implements IWorkbench
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, top);
             fields.add(l);
@@ -100,20 +101,23 @@ public class NaiveLP2PreferencePage extends 
PreferencePage implements IWorkbench
     return top;
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/OptimizedLP2PreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/OptimizedLP2PreferencePage.java
index c61ce8e7..c6dd2094 100755
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/OptimizedLP2PreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/lp2/OptimizedLP2PreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -48,12 +48,12 @@ public class OptimizedLP2PreferencePage extends 
PreferencePage implements IWorkb
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public OptimizedLP2PreferencePage() {
     TextRulerLearnerController ctrl = TextRulerController
             .getControllerForID("org.apache.uima.ruta.textruler.lp2opt");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
@@ -84,6 +84,7 @@ public class OptimizedLP2PreferencePage extends 
PreferencePage implements IWorkb
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, top);
             fields.add(l);
@@ -100,20 +101,23 @@ public class OptimizedLP2PreferencePage extends 
PreferencePage implements IWorkb
     return top;
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPreferencePage.java
index 3762a973..0b231f30 100755
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/rapier/RapierPreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -35,8 +35,8 @@ import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-public class RapierPreferencePage extends FieldEditorPreferencePage implements
-        IWorkbenchPreferencePage {
+public class RapierPreferencePage extends FieldEditorPreferencePage
+        implements IWorkbenchPreferencePage {
 
   public static String ID = "org.apache.uima.ruta.textruler.preference.rapier";
 
@@ -44,20 +44,22 @@ public class RapierPreferencePage extends 
FieldEditorPreferencePage implements
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public RapierPreferencePage() {
     super(FieldEditorPreferencePage.GRID);
     TextRulerLearnerController ctrl = TextRulerController
             .getControllerForID("org.apache.uima.ruta.textruler.rapier");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
+  @Override
   protected void createFieldEditors() {
     TextRulerLearnerFactory f = algorithmController.getFactory();
     TextRulerLearnerParameter[] params = f.getAlgorithmParameters();
@@ -79,6 +81,7 @@ public class RapierPreferencePage extends 
FieldEditorPreferencePage implements
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, getFieldEditorParent());
             fields.add(l);
@@ -96,15 +99,17 @@ public class RapierPreferencePage extends 
FieldEditorPreferencePage implements
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java
index 20382850..cbc841cf 100755
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -48,12 +48,12 @@ public class WhiskGenericPreferencePage extends 
PreferencePage implements IWorkb
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public WhiskGenericPreferencePage() {
     TextRulerLearnerController ctrl = TextRulerController
             
.getControllerForID("org.apache.uima.ruta.textruler.whisk.generic");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
@@ -84,6 +84,7 @@ public class WhiskGenericPreferencePage extends 
PreferencePage implements IWorkb
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, top);
             fields.add(l);
@@ -100,20 +101,23 @@ public class WhiskGenericPreferencePage extends 
PreferencePage implements IWorkb
     return top;
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }
diff --git 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/token/WhiskTokenPreferencePage.java
 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/token/WhiskTokenPreferencePage.java
index cfccd4b3..8a120539 100755
--- 
a/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/token/WhiskTokenPreferencePage.java
+++ 
b/ruta-ep-textruler/src/main/java/org/apache/uima/ruta/textruler/learner/whisk/token/WhiskTokenPreferencePage.java
@@ -6,9 +6,9 @@
  * 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
@@ -48,12 +48,12 @@ public class WhiskTokenPreferencePage extends 
PreferencePage implements IWorkben
 
   private IPreferenceStore store;
 
-  private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+  private ArrayList<FieldEditor> fields = new ArrayList<>();
 
   public WhiskTokenPreferencePage() {
     TextRulerLearnerController ctrl = TextRulerController
             .getControllerForID("org.apache.uima.ruta.textruler.whisk.token");
-    this.algorithmController = ctrl;
+    algorithmController = ctrl;
     store = TextRulerPlugin.getDefault().getPreferenceStore();
     setPreferenceStore(store);
   }
@@ -84,6 +84,7 @@ public class WhiskTokenPreferencePage extends PreferencePage 
implements IWorkben
 
           case ML_FLOAT_PARAM:
           case ML_INT_PARAM:
+          case ML_DOUBLE_PARAM:
           case ML_STRING_PARAM: {
             l = new StringFieldEditor(id, p.name, top);
             fields.add(l);
@@ -100,20 +101,23 @@ public class WhiskTokenPreferencePage extends 
PreferencePage implements IWorkben
     return top;
   }
 
+  @Override
   public void init(IWorkbench workbench) {
   }
 
   @Override
   protected void performDefaults() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.loadDefault();
-    // super.performDefaults();
+      // super.performDefaults();
+    }
   }
 
   @Override
   public boolean performOk() {
-    for (FieldEditor f : fields)
+    for (FieldEditor f : fields) {
       f.store();
+    }
     // return super.performOk();
     return true;
   }

Reply via email to