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/12/02 12:57:56 UTC

svn commit: r1209429 - in /incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor: ./ namefinder/ sentdetect/

Author: joern
Date: Fri Dec  2 11:57:55 2011
New Revision: 1209429

URL: http://svn.apache.org/viewvc?rev=1209429&view=rev
Log:
OPENNLP-410 Refactored Entity class into PotentialAnnotation and removed old Entity left overs.

Added:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/ConfirmAnnotationAction.java   (contents, props changed)
      - copied, changed from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmAnnotationAction.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotation.java   (contents, props changed)
      - copied, changed from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.java   (contents, props changed)
      - copied, changed from r1209161, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityComperator.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/PotentialEntityAnnotationLabelProvider.java   (contents, props changed)
      - copied, changed from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityLabelProvider.java
Removed:
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmAnnotationAction.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityComperator.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityLabelProvider.java
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/namefinder/NameFinderJob.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceContentProvider.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorViewPage.java
    incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java

Copied: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/ConfirmAnnotationAction.java (from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmAnnotationAction.java)
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/ConfirmAnnotationAction.java?p2=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/ConfirmAnnotationAction.java&p1=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmAnnotationAction.java&r1=1209115&r2=1209429&rev=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/ConfirmAnnotationAction.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/ConfirmAnnotationAction.java Fri Dec  2 11:57:55 2011
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.opennlp.caseditor.namefinder;
+package org.apache.opennlp.caseditor;
 
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.caseditor.editor.ICasEditor;
@@ -41,15 +41,7 @@ public class ConfirmAnnotationAction ext
   
   @Override
   protected boolean updateSelection(IStructuredSelection selection) {
-    
-    boolean result = false;
-    
-    if (!selection.isEmpty()) {
-      Entity entity = (Entity) selection.getFirstElement();
-      return !entity.isConfirmed();
-    }
-    
-    return result;
+    return !selection.isEmpty();
   }
   
   // Note: Action can only handle one element.
@@ -65,14 +57,12 @@ public class ConfirmAnnotationAction ext
     Object elements[] = selection.toArray();
 
     if (elements.length > 0) {
-      Entity selectedEntity = (Entity) elements[0];
-      if (!selectedEntity.isConfirmed()) {
+      PotentialAnnotation selectedEntity = (PotentialAnnotation) elements[0];
         
-        FeatureStructure nameAnnotation = editor.getDocument().getCAS().createAnnotation(
-            editor.getDocument().getCAS().getTypeSystem().getType(selectedEntity.getType()),
-            selectedEntity.getBeginIndex(), selectedEntity.getEndIndex());
-        editor.getDocument().addFeatureStructure(nameAnnotation);
-      }
+      FeatureStructure nameAnnotation = editor.getDocument().getCAS().createAnnotation(
+          editor.getDocument().getCAS().getTypeSystem().getType(selectedEntity.getType()),
+          selectedEntity.getBeginIndex(), selectedEntity.getEndIndex());
+      editor.getDocument().addFeatureStructure(nameAnnotation);
     }
   }
 }
\ No newline at end of file

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

Copied: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotation.java (from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java)
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotation.java?p2=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotation.java&p1=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java&r1=1209115&r2=1209429&rev=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/Entity.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotation.java Fri Dec  2 11:57:55 2011
@@ -15,31 +15,23 @@
  * limitations under the License.
  */
 
-package org.apache.opennlp.caseditor.namefinder;
-
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.eclipse.core.runtime.IAdaptable;
+package org.apache.opennlp.caseditor;
 
 // TODO: Rename to PotentialAnnotation, should also contain a type, then we can use
 //       reuse the code to create an annotation for it.
-public class Entity implements IAdaptable {
+public class PotentialAnnotation {
 
   private int beginIndex;
   private int endIndex;
 
   private String entityText;
 
-  private boolean isConfirmed;
-
   private Double confidence;
   
   private String type;
 
-  private AnnotationFS linkedAnnotationFS;
-  
-  public Entity(int beginIndex, int endIndex, String entityText, Double confidence,
-      boolean isConfirmed, String type) {
+  public PotentialAnnotation(int beginIndex, int endIndex, String entityText,
+      Double confidence, String type) {
     this.beginIndex = beginIndex;
     this.endIndex = endIndex;
     
@@ -47,15 +39,9 @@ public class Entity implements IAdaptabl
     
     this.confidence = confidence;
     
-    this.isConfirmed = isConfirmed;
-    
     this.type = type;
   }
   
-  public Entity(int beginIndex, int endIndex, String entityText, Double confidence, boolean isConfirmed) {
-    this(beginIndex, endIndex, entityText, confidence, isConfirmed, null);
-  }
-  
   public void setBeginIndex(int beginIndex) {
     this.beginIndex = beginIndex;
   }
@@ -92,18 +78,6 @@ public class Entity implements IAdaptabl
     return confidence;
   }
   
-  public void setConfirmed(boolean isConfirmed) {
-    this.isConfirmed = isConfirmed;
-  }
-  
-  public boolean isConfirmed() {
-    return isConfirmed;
-  }
-  
-  public void setLinkedAnnotation(AnnotationFS linkedAnnotationFS) {
-    this.linkedAnnotationFS = linkedAnnotationFS;
-  }
-  
   @Override
   public String toString() {
     return entityText;
@@ -116,8 +90,8 @@ public class Entity implements IAdaptabl
     if (obj == this) {
       return true;
     }
-    else if (obj instanceof Entity) {
-      Entity entity = (Entity) obj;
+    else if (obj instanceof PotentialAnnotation) {
+      PotentialAnnotation entity = (PotentialAnnotation) obj;
       return entity.getBeginIndex() == getBeginIndex() &&
           entity.getEndIndex() == getEndIndex() && 
           entity.getType().equals(type);
@@ -131,14 +105,4 @@ public class Entity implements IAdaptabl
   public int hashCode() {
     return getBeginIndex() + getEndIndex() + type.hashCode();
   }
-  
-  public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-    if (AnnotationFS.class.equals(adapter) || FeatureStructure.class.equals(adapter)) {
-      return linkedAnnotationFS;
-    }
-    else {
-      return null;
-    }
-  }
-  
 }

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

Copied: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.java (from r1209161, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityComperator.java)
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.java?p2=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.java&p1=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityComperator.java&r1=1209161&r2=1209429&rev=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityComperator.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.java Fri Dec  2 11:57:55 2011
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.opennlp.caseditor.namefinder;
+package org.apache.opennlp.caseditor;
 
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
@@ -25,13 +25,13 @@ import org.eclipse.jface.viewers.ViewerC
  * If entities have an identical begin index the one with the higher confidence score
  * is ordered first.
  */
-public class EntityComperator extends ViewerComparator {
+public class PotentialAnnotationComperator extends ViewerComparator {
 
   @Override
   public int compare(Viewer viewer, Object o1, Object o2) {
     
-    Entity e1 = (Entity) o1;
-    Entity e2 = (Entity) o2;
+    PotentialAnnotation e1 = (PotentialAnnotation) o1;
+    PotentialAnnotation e2 = (PotentialAnnotation) o2;
     
     int diff = e1.getBeginIndex() - e2.getBeginIndex();
     

Propchange: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/PotentialAnnotationComperator.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=1209429&r1=1209428&r2=1209429&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 Fri Dec  2 11:57:55 2011
@@ -27,6 +27,7 @@ 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.PotentialAnnotation;
 import org.apache.opennlp.caseditor.util.ContainingConstraint;
 import org.apache.opennlp.caseditor.util.UIMAUtil;
 import org.apache.uima.cas.CAS;
@@ -48,7 +49,6 @@ import org.eclipse.jface.viewers.Structu
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchPart;
 
 // Need its own list (or map), otherwise it is complicated to compute updates ...
 // Maybe we should create again, a "View" map of indexes to its annotations?!
@@ -92,7 +92,7 @@ public class EntityContentProvider imple
         // TODO: Check that type matches ...
         AnnotationFS annotation = (AnnotationFS) fs;
         
-        List<Entity> entityList = searchEntities(EntityContentProvider.this.candidateEntities,
+        List<PotentialAnnotation> entityList = searchEntities(EntityContentProvider.this.candidateEntities,
             annotation.getBegin(), annotation.getEnd());
         
         // Remove all entities from the view and candidate list
@@ -104,12 +104,11 @@ public class EntityContentProvider imple
             getTable().getSelectionIndex();
         
         if (!entityList.isEmpty()) {
-          Entity entity = entityList.get(0);
+          PotentialAnnotation entity = entityList.get(0);
           entity.setBeginIndex(annotation.getBegin());
           entity.setEndIndex(annotation.getEnd());
           entity.setEntityText(annotation.getCoveredText());
-          entity.setConfirmed(true);
-          entity.setLinkedAnnotation(annotation);
+//          entity.setConfirmed(true);
           entity.setConfidence(null);
           
           entityListViewer.remove(entity);
@@ -119,12 +118,10 @@ public class EntityContentProvider imple
 
           // Delete all other entities which match
           for (int i = 1; i < entityList.size(); i++) {
-            Entity removeEntity = entityList.get(i);
+            PotentialAnnotation removeEntity = entityList.get(i);
             
-            if (!removeEntity.isConfirmed()) {
-              entityListViewer.remove(removeEntity);
-              candidateEntities.remove(removeEntity);
-            }
+            entityListViewer.remove(removeEntity);
+            candidateEntities.remove(removeEntity);
           }
           
           if (nameFinderView.isActive()) {
@@ -150,8 +147,8 @@ public class EntityContentProvider imple
           }
         }
         else {
-          Entity newEntity = new Entity(annotation.getBegin(), annotation.getEnd(),
-              annotation.getCoveredText(), null, true, annotation.getType().getName());
+          PotentialAnnotation newEntity = new PotentialAnnotation(annotation.getBegin(), annotation.getEnd(),
+              annotation.getCoveredText(), null, annotation.getType().getName());
           
           EntityContentProvider.this.confirmedEntities.add(newEntity);
         }
@@ -176,7 +173,7 @@ public class EntityContentProvider imple
       if (fs instanceof AnnotationFS && contains(nameTypeNames, fs.getType().getName())) {
         AnnotationFS annotation = (AnnotationFS) fs;
         
-        Entity confirmedEntity = searchEntity(EntityContentProvider.this.confirmedEntities,
+        PotentialAnnotation confirmedEntity = searchEntity(EntityContentProvider.this.confirmedEntities,
             annotation.getBegin(), annotation.getEnd(), annotation.getType().getName());
         
         if (confirmedEntity != null) {
@@ -221,11 +218,11 @@ public class EntityContentProvider imple
           if (status.isOK()) {
             EntityContentProvider.this.nameFinderView.setMessage(null);
             
-            List<Entity> detectedEntities = EntityContentProvider.this.nameFinder.getNames();
+            List<PotentialAnnotation> detectedEntities = EntityContentProvider.this.nameFinder.getNames();
             
             // Remove all detected entities from the last run which are not detected anymore
-            for (Iterator<Entity> it = candidateEntities.iterator(); it.hasNext();) {
-              Entity entity = it.next();
+            for (Iterator<PotentialAnnotation> it = candidateEntities.iterator(); it.hasNext();) {
+              PotentialAnnotation entity = it.next();
               if (searchEntity(detectedEntities, entity.getBeginIndex(),
                   entity.getEndIndex(), entity.getType()) == null)  {
                 
@@ -238,7 +235,7 @@ public class EntityContentProvider imple
             }
             
             // Update if entity already exist, or add it
-            for (Entity detectedEntity : detectedEntities) {
+            for (PotentialAnnotation detectedEntity : detectedEntities) {
               
               // Bug: 
               // There can be multiple entities in this span!
@@ -246,24 +243,17 @@ public class EntityContentProvider imple
               
               // Case: One entity spanning two tokens replaces 
               
-              Entity entity = searchEntity(candidateEntities, detectedEntity.getBeginIndex(),
+              PotentialAnnotation entity = searchEntity(candidateEntities, detectedEntity.getBeginIndex(),
                   detectedEntity.getEndIndex(), detectedEntity.getType());
               
               // A confirmed entity already exists, update its confidence score
               if (entity != null) {
-                if (entity.isConfirmed()) {
-                  entity.setConfidence(detectedEntity.getConfidence());
-                  EntityContentProvider.this.entityListViewer.refresh(entity);
-                  continue;
-                }
-                else {
                   entity.setBeginIndex(detectedEntity.getBeginIndex());
                   entity.setEndIndex(detectedEntity.getEndIndex());
                   entity.setEntityText(detectedEntity.getEntityText());
                   entity.setConfidence(detectedEntity.getConfidence());
                   
                   EntityContentProvider.this.entityListViewer.refresh(entity);
-                }
               }
               else {
                 // Only add if it is not a confirmed entity!
@@ -297,8 +287,8 @@ public class EntityContentProvider imple
   
   // contains all existing entity annotations and is synchronized!
   // needed by name finder to calculate updates ... 
-  private List<Entity> candidateEntities = new ArrayList<Entity>();
-  private List<Entity> confirmedEntities = new ArrayList<Entity>();
+  private List<PotentialAnnotation> candidateEntities = new ArrayList<PotentialAnnotation>();
+  private List<PotentialAnnotation> confirmedEntities = new ArrayList<PotentialAnnotation>();
   
   private String nameTypeNames[];
 
@@ -384,10 +374,9 @@ public class EntityContentProvider imple
         AnnotationFS nameAnnotation = (AnnotationFS) nameIterator.next();
         
         // TODO: Entity must have a type ...
-        Entity entity = new Entity(nameAnnotation.getBegin(),
-            nameAnnotation.getEnd(), nameAnnotation.getCoveredText(), null, true,
+        PotentialAnnotation entity = new PotentialAnnotation(nameAnnotation.getBegin(),
+            nameAnnotation.getEnd(), nameAnnotation.getCoveredText(), null,
             nameAnnotation.getType().getName());
-        entity.setLinkedAnnotation(nameAnnotation);
         confirmedEntities.add(entity); // TODO: This needs to go into a second list!
       }
     }
@@ -549,13 +538,13 @@ public class EntityContentProvider imple
     store.removePropertyChangeListener(preferenceChangeTrigger);
   }
   
-  static List<Entity> searchEntities(List<Entity> entities, int begin, int end) {
+  static List<PotentialAnnotation> searchEntities(List<PotentialAnnotation> entities, int begin, int end) {
     
-    List<Entity> intersectingEntities = new ArrayList<Entity>();
+    List<PotentialAnnotation> intersectingEntities = new ArrayList<PotentialAnnotation>();
     
     Span testSpan = new Span(begin, end);
     
-    for (Entity entity : entities) {
+    for (PotentialAnnotation entity : entities) {
       
       Span entitySpan = new Span(entity.getBeginIndex(),
           entity.getEndIndex());
@@ -569,11 +558,11 @@ public class EntityContentProvider imple
   }
   
   // Could pass null, means any type
-  public static Entity searchEntity(List<Entity> entities, int begin, int end, String type) {
+  public static PotentialAnnotation searchEntity(List<PotentialAnnotation> entities, int begin, int end, String type) {
     
     Span testSpan = new Span(begin, end);
     
-    for (Entity entity : entities) {
+    for (PotentialAnnotation entity : entities) {
       
       Span entitySpan = new Span(entity.getBeginIndex(),
           entity.getEndIndex());

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderJob.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderJob.java?rev=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderJob.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderJob.java Fri Dec  2 11:57:55 2011
@@ -30,6 +30,7 @@ import opennlp.tools.util.Span;
 import opennlp.tools.util.featuregen.StringPattern;
 
 import org.apache.opennlp.caseditor.OpenNLPPlugin;
+import org.apache.opennlp.caseditor.PotentialAnnotation;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -52,7 +53,7 @@ public class NameFinderJob extends Job {
   private Span tokens[];
   private Span verifiedNames[] = new Span[0];
   
-  private List<Entity> nameList;
+  private List<PotentialAnnotation> nameList;
   
   NameFinderJob() {
     super("Name Finder Job");
@@ -103,7 +104,7 @@ public class NameFinderJob extends Job {
     if (nameFinder != null) {
       nameFinder.clearAdaptiveData();
     
-      nameList = new ArrayList<Entity>();
+      nameList = new ArrayList<PotentialAnnotation>();
       
       // TODO: Name tokens, should be for the entire text,
       // not just the prev sentences ...
@@ -182,8 +183,8 @@ public class NameFinderJob extends Job {
           
           String coveredText = text.substring(beginIndex, endIndex);
           
-          nameList.add(new Entity(beginIndex, endIndex, coveredText,
-              names[i].getConfidence(), false, names[i].getType()));
+          nameList.add(new PotentialAnnotation(beginIndex, endIndex, coveredText,
+              names[i].getConfidence(), names[i].getType()));
         }
       }
     }
@@ -194,8 +195,8 @@ public class NameFinderJob extends Job {
     return new Status(IStatus.OK, OpenNLPPlugin.ID, "OK");
   }
 
-  public List<Entity> getNames() {
-    List<Entity> names = new ArrayList<Entity>();
+  public List<PotentialAnnotation> getNames() {
+    List<PotentialAnnotation> names = new ArrayList<PotentialAnnotation>();
     names.addAll(nameList);
     return names;
   }

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java?rev=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderView.java Fri Dec  2 11:57:55 2011
@@ -20,7 +20,6 @@ package org.apache.opennlp.caseditor.nam
 import org.apache.uima.caseditor.editor.CasEditorView;
 import org.apache.uima.caseditor.editor.ICasDocument;
 import org.apache.uima.caseditor.editor.ICasEditor;
-import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.IPageBookViewPage;
 
 public class NameFinderView extends CasEditorView {

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java?rev=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/NameFinderViewPage.java Fri Dec  2 11:57:55 2011
@@ -17,7 +17,10 @@
 
 package org.apache.opennlp.caseditor.namefinder;
 
+import org.apache.opennlp.caseditor.ConfirmAnnotationAction;
 import org.apache.opennlp.caseditor.OpenPreferenceDialog;
+import org.apache.opennlp.caseditor.PotentialAnnotation;
+import org.apache.opennlp.caseditor.PotentialAnnotationComperator;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
@@ -104,11 +107,11 @@ class NameFinderViewPage extends Page im
     typeColumn.setText("Type");
     typeColumn.setWidth(40);
     
-    entityList.setLabelProvider(new EntityLabelProvider());
+    entityList.setLabelProvider(new PotentialEntityAnnotationLabelProvider());
     entityList.setContentProvider(new EntityContentProvider(this, (AnnotationEditor) editor, entityList));
     getSite().setSelectionProvider(entityList);
     
-    entityList.setComparator(new EntityComperator());
+    entityList.setComparator(new PotentialAnnotationComperator());
     
     entityList.setInput(editor.getDocument());
     
@@ -128,14 +131,12 @@ class NameFinderViewPage extends Page im
 			// is highlighted and revealed in the Annotation Editor.
 			
 			if (!selection.isEmpty()) {
-				Entity entity = (Entity) selection.getFirstElement();
+			  PotentialAnnotation entity = (PotentialAnnotation) selection.getFirstElement();
 				
-				if (!entity.isConfirmed()) {
-				  if (editor instanceof AnnotationEditor) {
-				    ((AnnotationEditor) editor).selectAndReveal(entity.getBeginIndex(),
-				        entity.getEndIndex() - entity.getBeginIndex());
-				  }
-				}
+			  if (editor instanceof AnnotationEditor) {
+			    ((AnnotationEditor) editor).selectAndReveal(entity.getBeginIndex(),
+			        entity.getEndIndex() - entity.getBeginIndex());
+			  }
 			}
 		}
 	});
@@ -160,8 +161,8 @@ class NameFinderViewPage extends Page im
           
           // If that annotation exist, then match it.
           // Bug: Need to check the type also ...
-          Entity entity = new Entity(firstAnnotation.getBegin(), firstAnnotation.getEnd(),
-              firstAnnotation.getCoveredText(), null, true, firstAnnotation.getType().getName());
+          PotentialAnnotation entity = new PotentialAnnotation(firstAnnotation.getBegin(), firstAnnotation.getEnd(),
+              firstAnnotation.getCoveredText(), null, firstAnnotation.getType().getName());
           
           ISelection tableSelection = new StructuredSelection(entity);
           entityList.setSelection(tableSelection, true);
@@ -218,6 +219,13 @@ class NameFinderViewPage extends Page im
     
     toolBarManager.add(action);
     
+    // TODO:
+    // How to make an action which changes the selection in the editor? Must be possible to make
+    // it large smaller on both sides, like the actions we already have, but not for an annotation!
+    // Key short cuts
+    // alt + left/right key for right annotation side
+    // ctrl + left/right key for left annotation side
+    
   }
   
   

Copied: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/PotentialEntityAnnotationLabelProvider.java (from r1209115, incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityLabelProvider.java)
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/PotentialEntityAnnotationLabelProvider.java?p2=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/PotentialEntityAnnotationLabelProvider.java&p1=incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityLabelProvider.java&r1=1209115&r2=1209429&rev=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityLabelProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/PotentialEntityAnnotationLabelProvider.java Fri Dec  2 11:57:55 2011
@@ -19,11 +19,12 @@ package org.apache.opennlp.caseditor.nam
 
 import java.text.DecimalFormat;
 
+import org.apache.opennlp.caseditor.PotentialAnnotation;
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.swt.graphics.Image;
 
-public class EntityLabelProvider implements ITableLabelProvider {
+public class PotentialEntityAnnotationLabelProvider implements ITableLabelProvider {
 
   private DecimalFormat df = new DecimalFormat("#.#");
   
@@ -44,7 +45,7 @@ public class EntityLabelProvider impleme
   public String getColumnText(Object element, int columnIndex) {
     String result = null;
     
-    Entity entity = (Entity) element;
+    PotentialAnnotation entity = (PotentialAnnotation) element;
     
     if (columnIndex == 0) {
       if (entity.getConfidence() != null)
@@ -63,10 +64,6 @@ public class EntityLabelProvider impleme
       } else
         result = "";
     }
-    else if (columnIndex == 3) {
-      // TODO: Confirmed entities could be marked by a color, or small image
-      result = Boolean.toString(entity.isConfirmed());
-    }
     
     return result;
   }

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

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=1209429&r1=1209428&r2=1209429&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 Fri Dec  2 11:57:55 2011
@@ -25,7 +25,7 @@ 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.PotentialAnnotation;
 import org.apache.opennlp.caseditor.namefinder.EntityContentProvider;
 import org.apache.opennlp.caseditor.util.UIMAUtil;
 import org.apache.uima.cas.CAS;
@@ -80,7 +80,7 @@ public class SentenceContentProvider imp
               
               SentenceContentProvider.this.sentenceDetectorView.setMessage(null);
               
-              List<Entity> confirmedSentences = new ArrayList<Entity>();
+              List<PotentialAnnotation> confirmedSentences = new ArrayList<PotentialAnnotation>();
               // TODO: Create a list of existing sentence annotations.
               
               // get sentence annotation index ...
@@ -96,12 +96,12 @@ public class SentenceContentProvider imp
               for (Iterator<AnnotationFS> it = cas.getAnnotationIndex(sentenceType).iterator();
                   it.hasNext(); ) {
                 AnnotationFS sentenceAnnotation = it.next();
-                confirmedSentences.add(new Entity(sentenceAnnotation.getBegin(),
-                    sentenceAnnotation.getEnd(), sentenceAnnotation.getCoveredText(), 1d, true, sentenceTypeName));
+                confirmedSentences.add(new PotentialAnnotation(sentenceAnnotation.getBegin(),
+                    sentenceAnnotation.getEnd(), sentenceAnnotation.getCoveredText(), 1d, sentenceTypeName));
               }
              
               
-              Entity sentences[] = SentenceContentProvider.this.
+              PotentialAnnotation sentences[] = SentenceContentProvider.this.
                   sentenceDetector.getDetectedSentences();
               
               // TODO:
@@ -117,7 +117,7 @@ public class SentenceContentProvider imp
               // Add a new potential sentence
               // Only add if it is not a confirmed sentence yet!
               // for each anotation, search confirmed sentence array above ...
-              for (Entity sentence : sentences) {
+              for (PotentialAnnotation sentence : sentences) {
                 if (EntityContentProvider.searchEntity(confirmedSentences,
                     sentence.getBeginIndex(), sentence.getEndIndex(),
                     sentence.getType()) == null) {

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java?rev=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorJob.java Fri Dec  2 11:57:55 2011
@@ -28,7 +28,7 @@ import opennlp.tools.util.Span;
 
 import org.apache.opennlp.caseditor.ModelUtil;
 import org.apache.opennlp.caseditor.OpenNLPPlugin;
-import org.apache.opennlp.caseditor.namefinder.Entity;
+import org.apache.opennlp.caseditor.PotentialAnnotation;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -46,7 +46,7 @@ public class SentenceDetectorJob extends
   
   private List<Span> paragraphs;
   
-  private List<Entity> detectedSentences;
+  private List<PotentialAnnotation> detectedSentences;
   
   public SentenceDetectorJob() {
     super("Sentence Detector Job");
@@ -91,7 +91,7 @@ public class SentenceDetectorJob extends
       }
     }
     
-    detectedSentences = new ArrayList<Entity>();
+    detectedSentences = new ArrayList<PotentialAnnotation>();
     for (Span para : paragraphs) {
     
       Span sentenceSpans[] = sentenceDetector.sentPosDetect(para.getCoveredText(text).toString());
@@ -101,16 +101,16 @@ public class SentenceDetectorJob extends
       for (int i = 0; i < sentenceSpans.length; i++) {
         Span sentenceSpan = sentenceSpans[i];
         String sentenceText = text.substring(para.getStart() + sentenceSpan.getStart(), para.getStart() + sentenceSpan.getEnd());
-        detectedSentences.add(new Entity(para.getStart() + sentenceSpan.getStart(), 
+        detectedSentences.add(new PotentialAnnotation(para.getStart() + sentenceSpan.getStart(), 
             para.getStart() + sentenceSpan.getEnd(), sentenceText,
-            confidence[i], false, sentenceType));
+            confidence[i], sentenceType));
       }
     }
     
     return new Status(IStatus.OK, OpenNLPPlugin.ID, "OK");
   }
 
-  Entity[] getDetectedSentences() {
-    return detectedSentences.toArray(new Entity[detectedSentences.size()]);
+  PotentialAnnotation[] getDetectedSentences() {
+    return detectedSentences.toArray(new PotentialAnnotation[detectedSentences.size()]);
   }
 }

Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java?rev=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceDetectorPreferencePage.java Fri Dec  2 11:57:55 2011
@@ -17,7 +17,6 @@
 
 package org.apache.opennlp.caseditor.sentdetect;
 
-import org.apache.opennlp.caseditor.OpenNLPPlugin;
 import org.apache.opennlp.caseditor.OpenNLPPreferenceConstants;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
 import org.eclipse.jface.preference.StringFieldEditor;

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=1209429&r1=1209428&r2=1209429&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 Fri Dec  2 11:57:55 2011
@@ -17,9 +17,9 @@
 
 package org.apache.opennlp.caseditor.sentdetect;
 
+import org.apache.opennlp.caseditor.ConfirmAnnotationAction;
 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.PotentialAnnotation;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
@@ -111,16 +111,12 @@ public class SentenceDetectorViewPage ex
             .getSelection();
 
         if (!selection.isEmpty()) {
-          Entity entity = (Entity) selection.getFirstElement();
+          PotentialAnnotation entity = (PotentialAnnotation) selection.getFirstElement();
 
-          if (entity.isConfirmed()) {
-            // TODO: Send corresponding annotation selection event ...
-          } else {
-            if (editor instanceof AnnotationEditor) {
-              ((AnnotationEditor) editor).selectAndReveal(
-                  entity.getBeginIndex(),
-                  entity.getEndIndex() - entity.getBeginIndex());
-            }
+          if (editor instanceof AnnotationEditor) {
+            ((AnnotationEditor) editor).selectAndReveal(
+                entity.getBeginIndex(),
+                entity.getEndIndex() - entity.getBeginIndex());
           }
         }
       }

Modified: 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=1209429&r1=1209428&r2=1209429&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/sentdetect/SentenceLabelProvider.java Fri Dec  2 11:57:55 2011
@@ -19,7 +19,7 @@ package org.apache.opennlp.caseditor.sen
 
 import java.text.DecimalFormat;
 
-import org.apache.opennlp.caseditor.namefinder.Entity;
+import org.apache.opennlp.caseditor.PotentialAnnotation;
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.swt.graphics.Image;
@@ -44,7 +44,7 @@ public class SentenceLabelProvider imple
   public String getColumnText(Object element, int columnIndex) {
     String result = null;
     
-    Entity entity = (Entity) element;
+    PotentialAnnotation entity = (PotentialAnnotation) element;
     
     if (columnIndex == 0) {
       if (entity.getConfidence() != null)