Revision: 18579
http://sourceforge.net/p/gate/code/18579
Author: johann_p
Date: 2015-02-17 18:49:14 +0000 (Tue, 17 Feb 2015)
Log Message:
-----------
Give a bit more information if an invalid offset exception occurs: which input
file
and what was the PreAnnotation and text when that happened?
Modified Paths:
--------------
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
2015-02-17 02:21:03 UTC (rev 18578)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/Population.java
2015-02-17 18:49:14 UTC (rev 18579)
@@ -21,6 +21,7 @@
import gate.creole.metadata.CreoleResource;
import gate.gui.NameBearerHandle;
import gate.gui.ResourceHelper;
+import gate.util.GateRuntimeException;
import gate.util.InvalidOffsetException;
import java.awt.event.ActionEvent;
import java.io.IOException;
@@ -163,7 +164,13 @@
DocumentContent contentImpl = new
DocumentContentImpl(content.toString());
document.setContent(contentImpl);
for (PreAnnotation preAnn : annotandaOffsets.keySet()) {
- preAnn.toAnnotation(document, annotandaOffsets.get(preAnn));
+ try {
+ preAnn.toAnnotation(document, annotandaOffsets.get(preAnn));
+ } catch (InvalidOffsetException ex) {
+ // show the content in the error message, so it becomes more easy to
find the
+ // cause of an InvalidOffsetException in a large file that has many
json entries.
+ throw new GateRuntimeException("Attempt to add annotation "+preAnn+"
for text="+contentImpl,ex);
+ }
}
corpus.add(document);
@@ -200,14 +207,13 @@
new Thread(Thread.currentThread().getThreadGroup(),
"Twitter JSON Corpus Populator") {
public void run() {
- try {
- for (URL fileUrl : fileUrls) {
+ for (URL fileUrl : fileUrls) {
+ try {
populateCorpus((Corpus) handle.getTarget(), fileUrl,
dialog.getConfig());
- }
+ } catch(ResourceInstantiationException e) {
+ logger.warn("Error in Twitter Population, url="+fileUrl,
e);
+ }
}
- catch(ResourceInstantiationException e) {
- logger.warn("Error in Twitter Population", e);
- }
}
};
thread.setPriority(Thread.MIN_PRIORITY);
Modified: gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java
===================================================================
--- gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java
2015-02-17 02:21:03 UTC (rev 18578)
+++ gate/trunk/plugins/Twitter/src/gate/corpora/twitter/PreAnnotation.java
2015-02-17 18:49:14 UTC (rev 18579)
@@ -104,6 +104,11 @@
public long getEnd() {
return this.end;
}
+
+ // just needed to show the details of an instance in the error message for
an exception.
+ public String toString() {
+ return "PreAnnotation:
from="+getStart()+",to="+getEnd()+",type="+getType();
+ }
}
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=190641631&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs