You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/11/07 17:59:30 UTC
svn commit: r1198813 - in
/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor:
AbstractCasChangeTrigger.java namefinder/EntityContentProvider.java
sentdetect/SentenceContentProvider.java
Author: joern
Date: Mon Nov 7 16:59:30 2011
New Revision: 1198813
URL: http://svn.apache.org/viewvc?rev=1198813&view=rev
Log:
OPENNLP-356 Updated change listener, to use common base class.
Added:
incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java (with props)
Modified:
incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java
Added: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java?rev=1198813&view=auto
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java (added)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java Mon Nov 7 16:59:30 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.opennlp.caseditor;
+
+import java.util.Collection;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.caseditor.editor.ICasDocumentListener;
+
+public abstract class AbstractCasChangeTrigger implements ICasDocumentListener {
+
+ /**
+ * Trigger a run of the opennlp component, a change to the CAS was detected.
+ */
+ protected abstract void trigger();
+
+ @Override
+ public void added(FeatureStructure fs) {
+ trigger();
+ }
+
+ @Override
+ public void added(Collection<FeatureStructure> featureStructures) {
+ trigger();
+ }
+
+ @Override
+ public void changed() {
+ trigger();
+ }
+
+ @Override
+ public void removed(FeatureStructure fs) {
+ trigger();
+ }
+
+ @Override
+ public void removed(Collection<FeatureStructure> featureStructures) {
+ trigger();
+ }
+
+ @Override
+ public void updated(FeatureStructure fs) {
+ trigger();
+ }
+
+ @Override
+ public void updated(Collection<FeatureStructure> featureStructures) {
+ trigger();
+
+ }
+
+ @Override
+ public void viewChanged(String oldView, String newView) {
+ trigger();
+ }
+}
Propchange: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/AbstractCasChangeTrigger.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java?rev=1198813&r1=1198812&r2=1198813&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java Mon Nov 7 16:59:30 2011
@@ -24,6 +24,7 @@ import java.util.List;
import opennlp.tools.util.Span;
+import org.apache.opennlp.caseditor.AbstractCasChangeTrigger;
import org.apache.opennlp.caseditor.OpenNLPPlugin;
import org.apache.opennlp.caseditor.OpenNLPPreferenceConstants;
import org.apache.opennlp.caseditor.util.ContainingConstraint;
@@ -58,50 +59,12 @@ public class EntityContentProvider imple
* TODO: Listener should only trigger a run if something changed which might change the results
* of the name finder run.
*/
- // TODO: Rename it ...
- private class CasChangeNameFinderTrigger implements ICasDocumentListener {
+ private class CasChangeNameFinderTrigger extends AbstractCasChangeTrigger {
@Override
- public void added(FeatureStructure fs) {
- runNameFinder();
- }
-
- @Override
- public void added(Collection<FeatureStructure> featureStructures) {
- runNameFinder();
- }
-
- @Override
- public void changed() {
- runNameFinder();
- }
-
- @Override
- public void removed(FeatureStructure fs) {
- runNameFinder();
- }
-
- @Override
- public void removed(Collection<FeatureStructure> featureStructures) {
- runNameFinder();
- }
-
- @Override
- public void updated(FeatureStructure fs) {
+ protected void trigger() {
runNameFinder();
}
-
- @Override
- public void updated(Collection<FeatureStructure> featureStructures) {
- runNameFinder();
-
- }
-
- @Override
- public void viewChanged(String oldView, String newView) {
- runNameFinder();
- }
-
}
/**
Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java?rev=1198813&r1=1198812&r2=1198813&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java Mon Nov 7 16:59:30 2011
@@ -18,18 +18,17 @@
package org.apache.opennlp.caseditor.sentdetect;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import opennlp.tools.util.Span;
+import org.apache.opennlp.caseditor.AbstractCasChangeTrigger;
import org.apache.opennlp.caseditor.OpenNLPPreferenceConstants;
import org.apache.opennlp.caseditor.namefinder.Entity;
import org.apache.opennlp.caseditor.namefinder.EntityContentProvider;
import org.apache.opennlp.caseditor.util.UIMAUtil;
import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.caseditor.editor.AnnotationEditor;
@@ -45,49 +44,11 @@ import org.eclipse.swt.widgets.Display;
public class SentenceContentProvider implements IStructuredContentProvider {
- private class CasChangeSDTrigger implements ICasDocumentListener {
-
- @Override
- public void added(FeatureStructure fs) {
- triggerSentenceDetector();
- }
-
- @Override
- public void added(Collection<FeatureStructure> featureStructures) {
- triggerSentenceDetector();
- }
-
- @Override
- public void changed() {
- triggerSentenceDetector();
- }
-
+ private class CasChangeSDTrigger extends AbstractCasChangeTrigger {
@Override
- public void removed(FeatureStructure fs) {
+ protected void trigger() {
triggerSentenceDetector();
}
-
- @Override
- public void removed(Collection<FeatureStructure> featureStructures) {
- triggerSentenceDetector();
- }
-
- @Override
- public void updated(FeatureStructure fs) {
- triggerSentenceDetector();
- }
-
- @Override
- public void updated(Collection<FeatureStructure> featureStructures) {
- triggerSentenceDetector();
-
- }
-
- @Override
- public void viewChanged(String oldView, String newView) {
- triggerSentenceDetector();
- }
-
}
private SentenceDetectorViewPage sentenceDetectorView;