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/09/27 19:11:56 UTC

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

Author: joern
Date: Tue Sep 27 17:11:55 2011
New Revision: 1176473

URL: http://svn.apache.org/viewvc?rev=1176473&view=rev
Log:
OPENNLP-235 It is now possible to create annotations depending on the entity type.

Modified:
    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/EntityLabelProvider.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/SentenceDetectorViewPage.java

Modified: 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/namefinder/ConfirmAnnotationAction.java?rev=1176473&r1=1176472&r2=1176473&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/namefinder/ConfirmAnnotationAction.java Tue Sep 27 17:11:55 2011
@@ -28,17 +28,14 @@ public class ConfirmAnnotationAction ext
   private TableViewer entityList;
   private ICasDocument document;
   
-  private String entityTypeName;
-  
-  public ConfirmAnnotationAction(TableViewer entityList, ICasDocument document, String entityTypeName) {
+  public ConfirmAnnotationAction(TableViewer entityList, ICasDocument document) {
     super("Confirm");
     
-    if (entityList == null || document == null || entityTypeName == null)
+    if (entityList == null || document == null)
       throw new IllegalArgumentException("null values are not allowed!");
     
     this.entityList = entityList;
     this.document = document;
-    this.entityTypeName = entityTypeName;
   }
   
   @Override
@@ -71,7 +68,7 @@ public class ConfirmAnnotationAction ext
       if (!selectedEntity.isConfirmed()) {
         
         FeatureStructure nameAnnotation = document.getCAS().createAnnotation(
-            document.getCAS().getTypeSystem().getType(entityTypeName),
+            document.getCAS().getTypeSystem().getType(selectedEntity.getType()),
             selectedEntity.getBeginIndex(), selectedEntity.getEndIndex());
 //        document.getCAS().addFsToIndexes(nameAnnotation);
         document.addFeatureStructure(nameAnnotation);

Modified: 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/EntityLabelProvider.java?rev=1176473&r1=1176472&r2=1176473&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/EntityLabelProvider.java Tue Sep 27 17:11:55 2011
@@ -56,6 +56,14 @@ public class EntityLabelProvider impleme
       result = entity.getEntityText();
     }
     else if (columnIndex == 2) {
+      // TODO: Improve this ...
+      if (entity.getType() != null && entity.getType() != null) {
+        String parts[] = entity.getType().split("\\.");
+        result = parts[parts.length - 1];
+      } else
+        result = "";
+    }
+    else if (columnIndex == 3) {
       // TODO: Confirmed entities could be marked by a color, or small image
       result = Boolean.toString(entity.isConfirmed());
     }

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=1176473&r1=1176472&r2=1176473&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 Tue Sep 27 17:11:55 2011
@@ -59,13 +59,8 @@ class NameFinderViewPage extends Page im
 
   private TableViewer entityList;
 
-  private String nameTypeName;
-  
   NameFinderViewPage(ICasEditor editor, ICasDocument document) {
     this.editor = editor;
-    
-    IPreferenceStore store = OpenNLPPlugin.getDefault().getPreferenceStore();
-    nameTypeName = store.getString(OpenNLPPreferenceConstants.NAME_TYPE);
   }
 
   public void createControl(Composite parent) {
@@ -88,6 +83,11 @@ class NameFinderViewPage extends Page im
     entityColumn.setText("Entity");
     entityColumn.setWidth(135);
     
+    TableViewerColumn typeViewerColumn = new TableViewerColumn(entityList, SWT.NONE);
+    TableColumn typeColumn = typeViewerColumn.getColumn();
+    typeColumn.setText("Type");
+    typeColumn.setWidth(40);
+    
     TableViewerColumn confirmedViewerColumn = new TableViewerColumn(entityList, SWT.NONE);
     TableColumn confirmedColumn = confirmedViewerColumn.getColumn();
     confirmedColumn.setText("Confirmed");
@@ -170,7 +170,7 @@ class NameFinderViewPage extends Page im
     
     IToolBarManager toolBarManager = actionBars.getToolBarManager();
     
-    BaseSelectionListenerAction confirmAction = new ConfirmAnnotationAction(entityList, editor.getDocument(), nameTypeName);
+    BaseSelectionListenerAction confirmAction = new ConfirmAnnotationAction(entityList, editor.getDocument());
     confirmAction.setActionDefinitionId(QUICK_ANNOTATE_ACTION_ID);
     actionBars.setGlobalActionHandler(QUICK_ANNOTATE_ACTION_ID, confirmAction);
     getSite().getSelectionProvider().addSelectionChangedListener(confirmAction); // need also to unregister!!!!

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=1176473&r1=1176472&r2=1176473&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 Tue Sep 27 17:11:55 2011
@@ -120,6 +120,8 @@ public class SentenceContentProvider imp
     
     sentenceDetector.setParagraphs(paragraphSpans);
     sentenceDetector.setText(document.getCAS().getDocumentText());
+    sentenceDetector.setSentenceType(store.getString(OpenNLPPreferenceConstants.SENTENCE_TYPE));
+    
     sentenceDetector.schedule();
   }
   

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=1176473&r1=1176472&r2=1176473&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 Tue Sep 27 17:11:55 2011
@@ -42,6 +42,8 @@ public class SentenceDetectorJob extends
   
   private String text;
   
+  private String sentenceType;
+  
   private List<Span> paragraphs;
   
   private List<Entity> detectedSentences;
@@ -58,6 +60,10 @@ public class SentenceDetectorJob extends
     this.text = text;
   }
   
+  synchronized void setSentenceType(String sentenceType) {
+    this.sentenceType = sentenceType;
+  }
+  
   public void setParagraphs(List<Span> paragraphs) {
     this.paragraphs =  paragraphs;
   }
@@ -96,7 +102,7 @@ public class SentenceDetectorJob extends
         String sentenceText = text.substring(para.getStart() + sentenceSpan.getStart(), para.getStart() + sentenceSpan.getEnd());
         detectedSentences.add(new Entity(para.getStart() + sentenceSpan.getStart(), 
             para.getStart() + sentenceSpan.getEnd(), sentenceText,
-            confidence[i], false));
+            confidence[i], false, sentenceType));
       }
     }
     

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=1176473&r1=1176472&r2=1176473&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 Tue Sep 27 17:11:55 2011
@@ -145,7 +145,7 @@ public class SentenceDetectorViewPage ex
     toolBarManager.add(detectAction);
     
     BaseSelectionListenerAction confirmAction =
-        new ConfirmAnnotationAction(sentenceList, editor.getDocument(), sentenceTypeName);
+        new ConfirmAnnotationAction(sentenceList, editor.getDocument());
     confirmAction.setActionDefinitionId(QUICK_ANNOTATE_ACTION_ID);
     actionBars.setGlobalActionHandler(QUICK_ANNOTATE_ACTION_ID, confirmAction);
     getSite().getSelectionProvider().addSelectionChangedListener(confirmAction); // need also to unregister!!!!