Revision: 18461
http://sourceforge.net/p/gate/code/18461
Author: ian_roberts
Date: 2014-11-17 17:51:09 +0000 (Mon, 17 Nov 2014)
Log Message:
-----------
Fixed a bug where result importer was annotating each token separately rather
than creating spanning annotations over runs of tokens, but kept the previously
buggy behaviour as an option as it is actually quite useful in some situations.
Modified Paths:
--------------
gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/ne/EntityAnnotationResultsImporter.java
Modified:
gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/ne/EntityAnnotationResultsImporter.java
===================================================================
---
gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/ne/EntityAnnotationResultsImporter.java
2014-11-17 02:22:46 UTC (rev 18460)
+++
gate/trunk/plugins/Crowd_Sourcing/src/gate/crowdsource/ne/EntityAnnotationResultsImporter.java
2014-11-17 17:51:09 UTC (rev 18461)
@@ -68,6 +68,8 @@
private String tokenASName;
+ private Boolean annotateSpans;
+
protected CrowdFlowerClient crowdFlowerClient;
public String getApiKey() {
@@ -155,6 +157,18 @@
this.tokenASName = tokenASName;
}
+ public Boolean getAnnotateSpans() {
+ return annotateSpans;
+ }
+
+ @RunTime
+ @CreoleParameter(comment = "If true (the default), create one annotation for
" +
+ "each contiguous run of marked tokens, if false, annotate each
token " +
+ "separately.", defaultValue = "true")
+ public void setAnnotateSpans(Boolean annotateSpans) {
+ this.annotateSpans = annotateSpans;
+ }
+
@Override
public Resource init() throws ResourceInstantiationException {
if(apiKey == null || "".equals(apiKey)) {
@@ -224,11 +238,12 @@
int startTok = 0;
int curTok = startTok;
while(curTok < answer.size()) {
- // we've reached the end of a consecutive sequence if either
- // (a) we're on the last element of answer or
- // (b) the next element is not this+1
- if(curTok == answer.size() - 1
- || answer.get(curTok).getAsInt() !=
answer.get(curTok + 1).getAsInt()) {
+ // we've reached the end of an annotation if either
+ // (a) we want to annotate each token individually anyway or
+ // (b) we're on the last element of answer or
+ // (c) the next element is not this+1
+ if(!annotateSpans || curTok == answer.size() - 1
+ || (answer.get(curTok).getAsInt() + 1) !=
answer.get(curTok + 1).getAsInt()) {
Long startOffset =
snippetTokens.get(answer.get(startTok).getAsInt()).getStartNode().getOffset();
Long endOffset =
snippetTokens.get(answer.get(curTok).getAsInt()).getEndNode().getOffset();
startTok = curTok + 1;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs