Revision: 19249
          http://sourceforge.net/p/gate/code/19249
Author:   markagreenwood
Date:     2016-04-20 10:03:32 +0000 (Wed, 20 Apr 2016)
Log Message:
-----------
some debugging output and changes from trunk merged in

Modified Paths:
--------------
    gate/branches/sawdust2/build/build.properties
    gate/branches/sawdust2/build/build.txt
    gate/branches/sawdust2/build/deploy/plugins/gate-8.1.xml
    
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationJobBuilder.java
    
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/rest/CrowdFlowerClient.java
    gate/branches/sawdust2/plugins/Format_CSV/gcp/csv4gcp.jar
    
gate/branches/sawdust2/plugins/Format_CSV/gcp/src/gate/cloud/io/csv/CSVStreamingOutputHandler.java
    gate/branches/sawdust2/src/main/gate/Plugin.java
    gate/branches/sawdust2/src/main/gate/creole/CreoleAnnotationHandler.java
    gate/branches/sawdust2/src/main/gate/gui/SerialControllerEditor.java

Property Changed:
----------------
    gate/branches/sawdust2/
    gate/branches/sawdust2/build/
    gate/branches/sawdust2/build/deploy/
    gate/branches/sawdust2/plugins/
    gate/branches/sawdust2/src/

Index: gate/branches/sawdust2
===================================================================
--- gate/branches/sawdust2      2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2      2016-04-20 10:03:32 UTC (rev 19249)

Property changes on: gate/branches/sawdust2
___________________________________________________________________
Modified: svn:mergeinfo
## -4,4 +4,4 ##
 /gate/branches/release-8.1:18736-18747
 /gate/branches/sawdust:17055-17079
 /gate/tags/release-7.0:15399-15407
-/gate/trunk:19181
+/gate/trunk:19180-19248
\ No newline at end of property
Index: gate/branches/sawdust2/build
===================================================================
--- gate/branches/sawdust2/build        2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/build        2016-04-20 10:03:32 UTC (rev 19249)

Property changes on: gate/branches/sawdust2/build
___________________________________________________________________
Modified: svn:mergeinfo
## -4,4 +4,4 ##
 /gate/branches/release-8.1/build:18736-18747
 /gate/branches/sawdust/build:17055-17079
 /gate/tags/release-7.0/build:15399-15407
-/gate/trunk/build:3-7
+/gate/trunk/build:3-7,19180-19248
\ No newline at end of property
Modified: gate/branches/sawdust2/build/build.properties
===================================================================
--- gate/branches/sawdust2/build/build.properties       2016-04-20 09:46:44 UTC 
(rev 19248)
+++ gate/branches/sawdust2/build/build.properties       2016-04-20 10:03:32 UTC 
(rev 19249)
@@ -1,4 +1,4 @@
 #Build Number for ANT. Do not edit!
-#Sat Apr 02 02:08:02 BST 2016
+#Wed Apr 20 02:08:12 BST 2016
 cvs.version=$Id\: build.properties 7542 2006-07-17 14\:26\:51Z ian_roberts $
-build.number=5431
+build.number=5449

Modified: gate/branches/sawdust2/build/build.txt
===================================================================
--- gate/branches/sawdust2/build/build.txt      2016-04-20 09:46:44 UTC (rev 
19248)
+++ gate/branches/sawdust2/build/build.txt      2016-04-20 10:03:32 UTC (rev 
19249)
@@ -1 +1 @@
-5430
\ No newline at end of file
+5448
\ No newline at end of file

Index: gate/branches/sawdust2/build/deploy
===================================================================
--- gate/branches/sawdust2/build/deploy 2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/build/deploy 2016-04-20 10:03:32 UTC (rev 19249)

Property changes on: gate/branches/sawdust2/build/deploy
___________________________________________________________________
Modified: svn:mergeinfo
## -6,3 +6,4 ##
 /gate/branches/release-8.1/build/deploy:18736-18747
 /gate/branches/sawdust/build/deploy:17055-17079
 /gate/tags/release-7.0/build/deploy:15399-15407
+/gate/trunk/build/deploy:19180-19248
\ No newline at end of property
Modified: gate/branches/sawdust2/build/deploy/plugins/gate-8.1.xml
===================================================================
--- gate/branches/sawdust2/build/deploy/plugins/gate-8.1.xml    2016-04-20 
09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/build/deploy/plugins/gate-8.1.xml    2016-04-20 
10:03:32 UTC (rev 19249)
@@ -20,8 +20,8 @@
   
downloadURL="https://github.com/johann-petrak/gateplugin-VirtualCorpus/releases/download/V0.16/VirtualCorpus-0.16.zip";
 />
 <CreolePlugin
-  
url="https://raw.githubusercontent.com/GateNLP/gateplugin-LearningFramework/V2_0/";
-  
downloadURL="https://github.com/GateNLP/gateplugin-LearningFramework/releases/download/V2_0/gateplugin-LearningFramework-2.0.zip";
+  
url="https://raw.githubusercontent.com/GateNLP/gateplugin-LearningFramework/V2_1/";
+  
downloadURL="https://github.com/GateNLP/gateplugin-LearningFramework/releases/download/V2_1/gateplugin-LearningFramework-2.1.zip";
 />
 <CreolePlugin
   
url="https://raw.githubusercontent.com/GenevieveGorrell/gateplugin-LearningFramework/version_1_0/";

Index: gate/branches/sawdust2/plugins
===================================================================
--- gate/branches/sawdust2/plugins      2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/plugins      2016-04-20 10:03:32 UTC (rev 19249)

Property changes on: gate/branches/sawdust2/plugins
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,4 ##
 /gate/branches/release-8.1/plugins:18736-18747
 /gate/branches/sawdust/plugins:17055-17079
 /gate/tags/release-7.0/plugins:15399-15407
-/gate/trunk/plugins:3-390,19181
+/gate/trunk/plugins:3-390,19180-19248
\ No newline at end of property
Modified: 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationJobBuilder.java
===================================================================
--- 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationJobBuilder.java
       2016-04-20 09:46:44 UTC (rev 19248)
+++ 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/classification/EntityClassificationJobBuilder.java
       2016-04-20 10:03:32 UTC (rev 19249)
@@ -180,21 +180,27 @@
 
         AnnotationSet thisEntityContext =
                 Utils.getCoveringAnnotations(contextAnnotations, entity);
-        if(thisEntityContext.isEmpty()) {
-          log.warn(entityAnnotationType + " with ID " + entity.getId()
-                  + " at offsets (" + Utils.start(entity) + ":"
-                  + Utils.end(entity) + ") in document "
-                  + getDocument().getName() + " has no surrounding "
-                  + contextAnnotationType + " - ignored");
+
+        if (contextASName != null) {
+          if(thisEntityContext.isEmpty()) {
+            log.warn(entityAnnotationType + " with ID " + entity.getId()
+                    + " at offsets (" + Utils.start(entity) + ":"
+                    + Utils.end(entity) + ") in document "
+                    + getDocument().getName() + " has no surrounding "
+                    + contextAnnotationType + " - ignored");
+          } else {
+            // get the "closest" context, i.e. the shortest annotation in
+            // the covering set.
+            // usually we'd expect this set to contain just one annotation
+            Annotation context =
+                    Collections.min(thisEntityContext,
+                            ANNOTATION_LENGTH_COMPARATOR);
+            crowdFlowerClient.createClassificationUnit(jobId, getDocument(),
+                    entityASName, context, entity);
+          }         
         } else {
-          // get the "closest" context, i.e. the shortest annotation in
-          // the covering set.
-          // usually we'd expect this set to contain just one annotation
-          Annotation context =
-                  Collections.min(thisEntityContext,
-                          ANNOTATION_LENGTH_COMPARATOR);
           crowdFlowerClient.createClassificationUnit(jobId, getDocument(),
-                  entityASName, context, entity);
+                  entityASName, entity, entity);
         }
       }
       fireProcessFinished();

Modified: 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/rest/CrowdFlowerClient.java
===================================================================
--- 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/rest/CrowdFlowerClient.java
      2016-04-20 09:46:44 UTC (rev 19248)
+++ 
gate/branches/sawdust2/plugins/Crowd_Sourcing/src/gate/crowdsource/rest/CrowdFlowerClient.java
      2016-04-20 10:03:32 UTC (rev 19249)
@@ -15,10 +15,7 @@
 
 import static gate.crowdsource.CrowdFlowerConstants.*;
 
-import gate.Annotation;
-import gate.AnnotationSet;
-import gate.Document;
-import gate.Utils;
+import gate.*;
 import gate.util.GateRuntimeException;
 
 import java.io.ByteArrayOutputStream;
@@ -149,6 +146,60 @@
 
   /**
    * <p>
+   *     Generates the text required to display the context for a 
classification,
+   *     either based on the document content, or on features present in the 
annotation.
+   *
+   *     If any of leftContext, rightContext, or entity are set as features on 
the annotation,
+   *     the text will be generated using those.
+   *
+   *     If none of these are present, the contents of the context and target 
feature will be
+   *     combined to give the document text used.
+   * </p>
+   * @param doc The document containing text that will be used if needed
+   * @param context The context annotation in which the entity will be couched
+   * @param target The target entity to display.
+   * @return
+   */
+  private String createClassificationUnitText(Document doc, Annotation context,
+                                              Annotation target) {
+    FeatureMap targetFeatures = target.getFeatures();
+
+    try {
+      // Fill in each part of the text individually, starting with the entity 
itself.
+      String entity; // No initialiser needed as we're guaranteed to overwrite 
it.
+
+      if (targetFeatures.containsKey("entity")) {
+        entity = (String) targetFeatures.get("entity");
+      } else {
+        entity = Utils.stringFor(doc, target);
+      }
+
+      // Look for the left context.
+      String leftContext = "";
+
+      if (targetFeatures.containsKey("leftContext")) {
+        leftContext = (String) targetFeatures.get("leftContext");
+      } else if (context != null) {
+        leftContext = Utils.stringFor(doc, Utils.start(context), 
Utils.start(target));
+      }
+
+      // Look for the right context.
+      String rightContext = "";
+
+      if (targetFeatures.containsKey("rightContext")) {
+        rightContext = (String) targetFeatures.get("rightContext");
+      } else if (context != null) {
+        rightContext = Utils.stringFor(doc, Utils.end(target), 
Utils.end(context));
+      }
+
+      return leftContext + "<span class=\"gate-entity\">" + entity + "</span>" 
+ rightContext;
+    } catch (ClassCastException e) {
+      throw new ClassCastException("Features entity, leftContext and 
rightContext must be String, if provided.");
+    }
+
+  }
+  /**
+   * <p>
    * Create a single unit in a classification job for the given
    * annotation. If the unit is created successfully, its ID will be
    * stored as a {@link Long} valued feature named <code>cf_unit</code>
@@ -176,6 +227,13 @@
    * created - typically things like "none" (none of the available
    * options is correct) or "nae" (the target is not an entity).
    * </p>
+   *
+   * <p>
+   * If the target annotation has a feature named "leftContext", "rightContext"
+   * or "entity", these will be used to generate the entity text for display.
+   * Otherwise, the text will be taken from the document, as covered by the
+   * context and target annotations.
+   * </p>
    * 
    * @param jobId the CrowdFlower job ID
    * @param doc the document containing the annotation
@@ -191,17 +249,23 @@
    */
   public long createClassificationUnit(long jobId, Document doc, String asName,
           Annotation context, Annotation target) {
-    String text = Utils.stringFor(doc, context);
-    String entity = Utils.stringFor(doc, target);
+
+    String entity; // No initialiser needed as we're guaranteed to overwrite 
it.
+
+    if (target.getFeatures().containsKey("entity")) {
+      entity = (String) target.getFeatures().get("entity");
+      if (entity == null) {
+        throw new NullPointerException("Given entity feature was null");
+      }
+    } else {
+      entity = Utils.stringFor(doc, target);
+    }
+
+    String text = createClassificationUnitText(doc, context, target);
+
     String documentId = String.valueOf(doc.getLRPersistenceId());
     int formDataSize = 10; // text + entity + docId + asName + annId
 
-    // insert highlight span into text
-    int entityStart = (int)(Utils.start(target) - Utils.start(context));
-    int entityEnd = entityStart + entity.length();
-    text =
-            text.substring(0, entityStart) + "<span class=\"gate-entity\">"
-                    + entity + "</span>" + text.substring(entityEnd);
 
     Object options = target.getFeatures().get("options");
     if(options != null) {
@@ -387,7 +451,7 @@
             + "  <cml:checkbox name=\"noentities\" label=\"");
     StringEscapeUtils.escapeXml(cml, noEntitiesCaption);
     cml.append("\" value=\"1\"\n"
-            + "      only-if=\"!answer:required\" validates=\"required\"/>\n"
+            + "      only-if=\"!answer\" validates=\"required\"/>\n"
             + "</div>\n");
     if(commentCaption != null) {
       cml.append("<cml:text name=\"comment\" label=\"");

Modified: gate/branches/sawdust2/plugins/Format_CSV/gcp/csv4gcp.jar
===================================================================
(Binary files differ)

Modified: 
gate/branches/sawdust2/plugins/Format_CSV/gcp/src/gate/cloud/io/csv/CSVStreamingOutputHandler.java
===================================================================
--- 
gate/branches/sawdust2/plugins/Format_CSV/gcp/src/gate/cloud/io/csv/CSVStreamingOutputHandler.java
  2016-04-20 09:46:44 UTC (rev 19248)
+++ 
gate/branches/sawdust2/plugins/Format_CSV/gcp/src/gate/cloud/io/csv/CSVStreamingOutputHandler.java
  2016-04-20 10:03:32 UTC (rev 19249)
@@ -45,6 +45,8 @@
   public static final String PARAM_ANNOTATION_SET_NAME = "annotationSetName";
 
   public static final String PARAM_ANNOTATION_TYPE = "annotationType";
+  
+  public static final String PARAM_CONTAINED_ONLY = "containedOnly";
 
   private static final Logger logger = Logger
       .getLogger(CSVStreamingOutputHandler.class);
@@ -58,6 +60,8 @@
   protected String annotationSetName, annotationType;
 
   protected String[] columns;
+  
+  protected boolean containedOnly;
 
   @Override
   protected void configImpl(Map<String, String> configData) throws IOException,
@@ -99,6 +103,12 @@
     // at the document level as if the param was missing
     if(annotationType != null && annotationType.trim().equals(""))
       annotationType = null;
+    
+    // should we only look at annotations contained within the annotationType 
or
+    // do we allow overlapping ones as well?
+    containedOnly =
+        configData.containsKey(PARAM_CONTAINED_ONLY) ? Boolean
+            .parseBoolean(configData.get(PARAM_CONTAINED_ONLY)) : true;
   }
 
   @Override
@@ -191,8 +201,16 @@
 
       if(within != null) {
         // if we have been provided with an annotation to limit the search then
-        // get just those contained within it
-        annots = Utils.getContainedAnnotations(annots, within);
+        // get just those either....
+        
+        if (containedOnly) {
+          // contained within the annotation
+          annots = Utils.getContainedAnnotations(annots, within);
+        }
+        else {
+          // or partially overlapping with it
+          annots = Utils.getOverlappingAnnotations(annots, within);
+        }
       }
 
       // if there are no annotations then we can quit

Index: gate/branches/sawdust2/src
===================================================================
--- gate/branches/sawdust2/src  2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/src  2016-04-20 10:03:32 UTC (rev 19249)

Property changes on: gate/branches/sawdust2/src
___________________________________________________________________
Modified: svn:mergeinfo
## -4,4 +4,4 ##
 /gate/branches/release-8.1/src:18736-18747
 /gate/branches/sawdust/src:17055-17079
 /gate/tags/release-7.0/src:15399-15407
-/gate/trunk/src:3-7
+/gate/trunk/src:3-7,19180-19248
\ No newline at end of property
Modified: gate/branches/sawdust2/src/main/gate/Plugin.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/Plugin.java    2016-04-20 09:46:44 UTC 
(rev 19248)
+++ gate/branches/sawdust2/src/main/gate/Plugin.java    2016-04-20 10:03:32 UTC 
(rev 19249)
@@ -139,7 +139,7 @@
       org.jdom.Document creoleDoc = getCreoleXML();
       
       XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
-      log.debug(xmlOut.outputString(creoleDoc));
+      System.out.println(xmlOut.outputString(creoleDoc));
       
       final Map<String, ResourceInfo> resInfos = new LinkedHashMap<String, 
ResourceInfo>();
       List<Element> jobsList = new ArrayList<Element>();

Modified: 
gate/branches/sawdust2/src/main/gate/creole/CreoleAnnotationHandler.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/creole/CreoleAnnotationHandler.java    
2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/src/main/gate/creole/CreoleAnnotationHandler.java    
2016-04-20 10:03:32 UTC (rev 19249)
@@ -196,6 +196,7 @@
       throws MalformedURLException {
     if("JAR".equals(jdomElt.getName())) {
       URL url = new URL(plugin.getBaseURL(), jdomElt.getTextTrim());
+      System.out.println("adding: "+url);
       try {
         java.io.InputStream s = url.openStream();
         s.close();

Modified: gate/branches/sawdust2/src/main/gate/gui/SerialControllerEditor.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/gui/SerialControllerEditor.java        
2016-04-20 09:46:44 UTC (rev 19248)
+++ gate/branches/sawdust2/src/main/gate/gui/SerialControllerEditor.java        
2016-04-20 10:03:32 UTC (rev 19249)
@@ -542,8 +542,20 @@
           for(int row : rows) {
             if(row > 0) {
               //move it up
+              List<RunningStrategy> strategies = null;
+              if(conditionalMode) {
+                strategies = new 
ArrayList<RunningStrategy>(((ConditionalController)controller)
+                        .getRunningStrategies());
+                RunningStrategy straegy = strategies.remove(row);
+                strategies.add(row-1, straegy); 
+              }
+              
               ProcessingResource value = controller.remove(row);
               controller.add(row - 1, value);
+              
+              if(conditionalMode) {
+                
((ConditionalController)controller).setRunningStrategies(strategies);;
+              }
             }
           }
 //          memberPRsTableModel.fireTableDataChanged();
@@ -577,9 +589,22 @@
           for(int i = rows.length - 1; i >= 0; i--){
             int row = rows[i];
             if(row < controller.getPRs().size() -1){
+              
+              List<RunningStrategy> strategies = null;
+              if(conditionalMode) {
+                strategies = new 
ArrayList<RunningStrategy>(((ConditionalController)controller)
+                        .getRunningStrategies());
+                RunningStrategy straegy = strategies.remove(row);
+                strategies.add(row+1, straegy); 
+              }
+              
               //move it down
               ProcessingResource value = controller.remove(row);
               controller.add(row + 1, value);
+              
+              if(conditionalMode) {
+                
((ConditionalController)controller).setRunningStrategies(strategies);;
+              }
             }
           }
 //          memberPRsTableModel.fireTableDataChanged();

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to