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/02 16:46:23 UTC

svn commit: r1196648 - in /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect: SentenceDetectorViewPage.java SentenceLabelProvider.java

Author: joern
Date: Wed Nov  2 15:46:22 2011
New Revision: 1196648

URL: http://svn.apache.org/viewvc?rev=1196648&view=rev
Log:
OPENNLP-353 New label provider shows begin and end of a sentence.

Added:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java   (with props)
Modified:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java?rev=1196648&r1=1196647&r2=1196648&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java Wed Nov  2 15:46:22 2011
@@ -17,19 +17,15 @@
 
 package org.apache.opennlp.caseditor.sentdetect;
 
-import org.apache.opennlp.caseditor.OpenNLPPlugin;
-import org.apache.opennlp.caseditor.OpenNLPPreferenceConstants;
 import org.apache.opennlp.caseditor.OpenPreferenceDialog;
 import org.apache.opennlp.caseditor.namefinder.ConfirmAnnotationAction;
 import org.apache.opennlp.caseditor.namefinder.Entity;
-import org.apache.opennlp.caseditor.namefinder.EntityLabelProvider;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
 import org.apache.uima.caseditor.editor.ICasEditor;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
@@ -90,7 +86,7 @@ public class SentenceDetectorViewPage ex
     
     // TODO: Label provider needs support to display being and end of long texts ...
     //       text in-between can be replaced by three dots.
-    sentenceList.setLabelProvider(new EntityLabelProvider());
+    sentenceList.setLabelProvider(new SentenceLabelProvider());
     
     SentenceDetectorJob sentenceDetector = new SentenceDetectorJob();
     

Added: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java?rev=1196648&view=auto
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java (added)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java Wed Nov  2 15:46:22 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.sentdetect;
+
+import java.text.DecimalFormat;
+
+import org.apache.opennlp.caseditor.namefinder.Entity;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class SentenceLabelProvider implements ITableLabelProvider {
+  private DecimalFormat df = new DecimalFormat("#.#");
+  
+  public void addListener(ILabelProviderListener listener) {
+  }
+
+  public void removeListener(ILabelProviderListener listener) {
+  }
+
+  public boolean isLabelProperty(Object element, String property) {
+    return false;
+  }
+
+  public Image getColumnImage(Object element, int columnIndex) {
+    return null;
+  }
+
+  public String getColumnText(Object element, int columnIndex) {
+    String result = null;
+    
+    Entity entity = (Entity) element;
+    
+    if (columnIndex == 0) {
+      if (entity.getConfidence() != null)
+        result = df.format(entity.getConfidence() * 100);
+      else
+        result = "";
+    }
+    else if (columnIndex == 1) {
+      
+      String text = entity.getEntityText();
+      
+      if (text.length() > 35) {
+        result = text.substring(0, 15) + " ... " + text.substring(text.length() - 15);
+      }
+      else {
+        result = text;
+      }
+    }
+    
+    return result;
+  }
+
+  public void dispose() {
+  }
+}

Propchange: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain