Hi Stergos,
it looks to me like you're setting either the start or
the end position to a negative value somewhere. You
won't notice this in a normal application because nobody
accesses those values, hence no exceptions. The service,
on the other hand, explicitly accesses those values and
will barf if it finds negative ones.
You can inspect your offsets by running your app in CVD
or DocumentAnalyzer, or by printing out the results
manually. If you have a JCas, you can do this:
FSIterator it = aJCas.getAnnotationIndex(Annotation.type).iterator();
while (it.hasNext()) {
Annotation annot = (Annotation) it.next();
System.out.println(annot.getType() + ":" + annot.getBegin() + ":" +
annot.getEnd());
}
I didn't test this, but something like this should work.
Hope this helps.
--Thilo
Stergos D. Afantenos wrote:
Dear Thilo,
we'll need more information to be able to help,
the stack trace of the exception for one.
Here is the stack trace :
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
java.lang.String.substring(String.java:1932)
org.apache.uima.jcas.tcas.Annotation.getCoveredText(Annotation.java:119)
org.apache.uima.simpleserver.ResultExtractor.makeOutputs(ResultExtractor.java:176)
org.apache.uima.simpleserver.ResultExtractor.outputAll(ResultExtractor.java:158)
org.apache.uima.simpleserver.ResultExtractor.processTypes(ResultExtractor.java:111)
org.apache.uima.simpleserver.ResultExtractor.getResult(ResultExtractor.java:105)
org.apache.uima.simpleserver.Service.process(Service.java:262)
org.apache.uima.simpleserver.servlet.SimpleServerServlet.analyze(SimpleServerServlet.java:204)
org.apache.uima.simpleserver.servlet.SimpleServerServlet.doPost(SimpleServerServlet.java:183)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Also,
I do not understand what you mean when you say
"I am trying to set the spans for a jCas".
Of course. I realized my error once I had already sent the email, so
it was rather late to change it. What I meant to say is that I am
trying to set the spans of *an annotation* that is found inside a
JCas. So here is the piece code which causes me headaches:
String docText = aJCas.getDocumentText();
String[] splittedLine = line.split(":");
int start = Integer.parseInt(splittedLine[0]) - 1;
if (start >= docText.length()) start = docText.length() - 1;
int end = Integer.parseInt(splittedLine[1]) - 1;
if (end >= docText.length()) end = docText.length() - 1;
NemesisNE annotationNemesis = new NemesisNE(aJCas);
annotationNemesis.setBegin(start);
annotationNemesis.setEnd(end);
// adition of other attributes to annotationNemesis
annotationNemesis.addToIndexes();
where the variable line is a ":" separated String whose first element
is the span start of the annotation that I am currently treating and
second element is the span end of the annotation that I am currently
treating. In addition NemesisNE is a class that I have defined in the
Type System.
The above piece of code works fine if run, for example, via the
cpeGui, but throws the aforementioned exception if deployed as a WS.
If I run the following code :
String docText = aJCas.getDocumentText();
String[] splittedLine = line.split(":");
//int start = Integer.parseInt(splittedLine[0]) - 1;
//if (start >= docText.length()) start = docText.length() - 1;
//int end = Integer.parseInt(splittedLine[1]) - 1;
//if (end >= docText.length()) end = docText.length() - 1;
NemesisNE annotationNemesis = new NemesisNE(aJCas);
//annotationNemesis.setBegin(start);
//annotationNemesis.setEnd(end);
// adition of other attributes to annotationNemesis
annotationNemesis.addToIndexes();
then everything runs just fine as both a WS and a normal application.
The problem is that in this case the spans are both 0.
If there is any other kind of information that I could provide either
to you Thilo or somebody else I would be happy to do it.
Again, thanks ( in advance :) )
Stergos.