Author: pkluegl Date: Mon Mar 4 14:26:31 2013 New Revision: 1452323 URL: http://svn.apache.org/r1452323 Log: UIMA-2709 - added preference initializer - fixed some ids - skip TMB annotations
Added: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/preferences/TextRulerPreferenceInitializer.java Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/plugin.xml uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/core/TextRulerToolkit.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/NaiveLP2PreferencePage.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/OptimizedLP2PreferencePage.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/rapier/RapierPreferencePage.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/token/WhiskTokenPreferencePage.java uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/ui/LearnerConfigurator.java Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/plugin.xml URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/plugin.xml?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/plugin.xml (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/plugin.xml Mon Mar 4 14:26:31 2013 @@ -148,13 +148,13 @@ under the License. <page category="org.apache.uima.textmarker.textruler" class="org.apache.uima.textmarker.textruler.learner.lp2.NaiveLP2PreferencePage" - id="org.apache.uima.textmarker.textruler.lp2naive" + id="org.apache.uima.textmarker.textruler.preference.lp2naive" name="LP2 (naive)"> </page> <page category="org.apache.uima.textmarker.textruler" class="org.apache.uima.textmarker.textruler.learner.lp2.OptimizedLP2PreferencePage" - id="org.apache.uima.textmarker.textruler.lp2opt" + id="org.apache.uima.textmarker.textruler.preference.lp2opt" name="LP2 (optimized)"> </page> </extension> @@ -184,13 +184,13 @@ under the License. <page category="org.apache.uima.textmarker.textruler" class="org.apache.uima.textmarker.textruler.learner.whisk.generic.WhiskGenericPreferencePage" - id="org.apache.uima.textmarker.textruler.whisk.generic" + id="org.apache.uima.textmarker.textruler.preference.whisk.generic" name="Whisk (generic)"> </page> <page category="org.apache.uima.textmarker.textruler" class="org.apache.uima.textmarker.textruler.learner.whisk.token.WhiskTokenPreferencePage" - id="org.apache.uima.textmarker.textruler.whisk.token" + id="org.apache.uima.textmarker.textruler.preference.whisk.token" name="Whisk (token)"> </page> </extension> @@ -207,8 +207,14 @@ under the License. <page category="org.apache.uima.textmarker.textruler" class="org.apache.uima.textmarker.textruler.learner.rapier.RapierPreferencePage" - id="org.apache.uima.textmarker.textruler.rapier" + id="org.apache.uima.textmarker.textruler.preference.rapier" name="Rapier"> </page> </extension> + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.apache.uima.textmarker.textruler.preferences.TextRulerPreferenceInitializer"> + </initializer> + </extension> </plugin> Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/core/TextRulerToolkit.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/core/TextRulerToolkit.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/core/TextRulerToolkit.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/core/TextRulerToolkit.java Mon Mar 4 14:26:31 2013 @@ -46,6 +46,7 @@ import org.apache.uima.cas.impl.XmiCasDe import org.apache.uima.cas.impl.XmiCasSerializer; import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.resource.ResourceSpecifier; +import org.apache.uima.textmarker.engine.TextMarkerEngine; import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils; import org.apache.uima.textmarker.textruler.TextRulerPlugin; import org.apache.uima.textmarker.textruler.core.TextRulerTarget.MLTargetType; @@ -301,6 +302,7 @@ public class TextRulerToolkit { Type tmRootType = ts.getType(TM_ALL_TYPE_NAME); Set<String> allFilters = new HashSet<String>(); allFilters.add("uima.tcas.DocumentAnnotation"); + allFilters.add(TextMarkerEngine.BASIC_TYPE); if (filterSet != null) allFilters.addAll(filterSet); for (; it.isValid(); it.moveToNext()) { @@ -350,6 +352,7 @@ public class TextRulerToolkit { public static synchronized Set<String> getFilterSetWithSlotNames(String[] slotNames, Set<String> otherFilters) { Set<String> result = new HashSet<String>(otherFilters); + result.add(TextMarkerEngine.BASIC_TYPE); if (slotNames != null) for (String s : slotNames) result.add(s); Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/NaiveLP2PreferencePage.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/NaiveLP2PreferencePage.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/NaiveLP2PreferencePage.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/NaiveLP2PreferencePage.java Mon Mar 4 14:26:31 2013 @@ -42,7 +42,7 @@ import org.eclipse.ui.IWorkbenchPreferen public class NaiveLP2PreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - public static String ID = "org.apache.uima.textmarker.textruler.algorithmPages"; + public static String ID = "org.apache.uima.textmarker.textruler.preference.lp2naive"; private TextRulerLearnerController algorithmController; Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/OptimizedLP2PreferencePage.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/OptimizedLP2PreferencePage.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/OptimizedLP2PreferencePage.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/lp2/OptimizedLP2PreferencePage.java Mon Mar 4 14:26:31 2013 @@ -42,7 +42,7 @@ import org.eclipse.ui.IWorkbenchPreferen public class OptimizedLP2PreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - public static String ID = "org.apache.uima.textmarker.textruler.algorithmPages"; + public static String ID = "org.apache.uima.textmarker.textruler.preference.lp2opt"; private TextRulerLearnerController algorithmController; Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/rapier/RapierPreferencePage.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/rapier/RapierPreferencePage.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/rapier/RapierPreferencePage.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/rapier/RapierPreferencePage.java Mon Mar 4 14:26:31 2013 @@ -38,7 +38,7 @@ import org.eclipse.ui.IWorkbenchPreferen public class RapierPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - public static String ID = "org.apache.uima.textmarker.textruler.algorithmPages"; + public static String ID = "org.apache.uima.textmarker.textruler.preference.rapier"; private TextRulerLearnerController algorithmController; Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/generic/WhiskGenericPreferencePage.java Mon Mar 4 14:26:31 2013 @@ -42,7 +42,7 @@ import org.eclipse.ui.IWorkbenchPreferen public class WhiskGenericPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - public static String ID = "org.apache.uima.textmarker.textruler.algorithmPages"; + public static String ID = "org.apache.uima.textmarker.textruler.preference.whisk.generic"; private TextRulerLearnerController algorithmController; Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/token/WhiskTokenPreferencePage.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/token/WhiskTokenPreferencePage.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/token/WhiskTokenPreferencePage.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/learner/whisk/token/WhiskTokenPreferencePage.java Mon Mar 4 14:26:31 2013 @@ -42,7 +42,7 @@ import org.eclipse.ui.IWorkbenchPreferen public class WhiskTokenPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - public static String ID = "org.apache.uima.textmarker.textruler.algorithmPages"; + public static String ID = "org.apache.uima.textmarker.textruler.preference.whisk.token"; private TextRulerLearnerController algorithmController; Added: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/preferences/TextRulerPreferenceInitializer.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/preferences/TextRulerPreferenceInitializer.java?rev=1452323&view=auto ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/preferences/TextRulerPreferenceInitializer.java (added) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/preferences/TextRulerPreferenceInitializer.java Mon Mar 4 14:26:31 2013 @@ -0,0 +1,63 @@ +/* + * 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.textmarker.textruler.preferences; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.uima.textmarker.textruler.TextRulerPlugin; +import org.apache.uima.textmarker.textruler.extension.TextRulerController; +import org.apache.uima.textmarker.textruler.extension.TextRulerLearnerController; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +public class TextRulerPreferenceInitializer extends AbstractPreferenceInitializer { + + public TextRulerPreferenceInitializer() { + } + + public void initializeDefaultPreferences() { + IPreferenceStore store = TextRulerPlugin.getDefault().getPreferenceStore(); + + List<TextRulerLearnerController> availableControllers = TextRulerController.getAvailableControllers(); + for (TextRulerLearnerController each : availableControllers) { + String id = each.getID(); + Map<String, Object> defaultValues = each.getFactory().getAlgorithmParameterStandardValues(); + Set<Entry<String,Object>> entrySet = defaultValues.entrySet(); + for (Entry<String, Object> entry : entrySet) { + String key = id + "." + entry.getKey(); + Object value = entry.getValue(); + if(value instanceof Integer) { + store.setDefault(key, (Integer) value); + } else if(value instanceof Double) { + store.setDefault(key, (Double) value); + } else if(value instanceof Float) { + store.setDefault(key, (Float) value); + } else if(value instanceof Boolean) { + store.setDefault(key, (Boolean) value); + } else if(value instanceof String) { + store.setDefault(key, (String) value); + } + } + } + } +} Modified: uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/ui/LearnerConfigurator.java URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/ui/LearnerConfigurator.java?rev=1452323&r1=1452322&r2=1452323&view=diff ============================================================================== --- uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/ui/LearnerConfigurator.java (original) +++ uima/sandbox/textmarker/trunk/textmarker-ep-textruler/src/main/java/org/apache/uima/textmarker/textruler/ui/LearnerConfigurator.java Mon Mar 4 14:26:31 2013 @@ -151,19 +151,19 @@ public class LearnerConfigurator { String id = algorithmController.getID() + "." + p.id; switch (p.type) { case ML_BOOL_PARAM: { - result.put(p.id, store.getBoolean(id)); + result.put(id, store.getBoolean(id)); break; } case ML_FLOAT_PARAM: { - result.put(p.id, store.getFloat(id)); + result.put(id, store.getFloat(id)); break; } case ML_INT_PARAM: { - result.put(p.id, store.getInt(id)); + result.put(id, store.getInt(id)); break; } case ML_STRING_PARAM: { - result.put(p.id, store.getString(id)); + result.put(id, store.getString(id)); break; } // case ML_SELECT_PARAM: {