"The parsed offset MUST NOT be a negative number (offset="+offset+")");
}
this.offset = offset;
Span[] tokenSpans = getTokenizer().tokenizePos(sentence);
POSTaggerME tagger = getPosTagger();
ChunkerME chunker = getChunker();
PosTypeChunker posTypeChunker = getPosTypeChunker();
String[] tokens = new String[tokenSpans.length];
for(int ti = 0; ti<tokenSpans.length;ti++) {
tokens[ti] = tokenSpans[ti].getCoveredText(sentence).toString();
}
String[][] posTags;
double[][] posProbs;
Span[] chunkSpans;
double[] chunkProps;
if(tagger != null){
posTags = new String[tokens.length][];
posProbs = new double[tokens.length][];
//get the topK POS tags and props and copy it over to the 2dim Arrays
Sequence[] posSequences = tagger.topKSequences(tokens);
//extract the POS tags and props for the current token from the
//posSequences.
//NOTE: Sequence includes always POS tags for all Tokens. If
// less then posSequences.length are available it adds the
// best match for all followings.
// We do not want such copies.
String[] actPos = new String[posSequences.length];
double[] actProp = new double[posSequences.length];
for(int i=0;i<tokenSpans.length;i++){
boolean done = false;
int j = 0;
while( j < posSequences.length && !done){
String p = posSequences[j].getOutcomes().get(i);
done = j > 0 && p.equals(actPos[0]);
if(!done){
actPos[j] = p;
actProp[j] = posSequences[j].getProbs()[i];
j++;
}
}
posTags[i] = new String[j];
System.arraycopy(actPos, 0, posTags[i], 0, j);
posProbs[i] = new double[j];
System.arraycopy(actProp, 0, posProbs[i], 0, j);
}
//posProbs = tagger.probs();
if(chunker != null){
//we still need the Array of the best ranked POS tags for the chunker
String[] pos = posSequences[0].getOutcomes().toArray(new String[tokens.length]);
chunkSpans = chunker.chunkAsSpans(tokens, pos);
chunkProps = chunker.probs();
} else if(posTypeChunker != null){
chunkSpans = posTypeChunker.chunkAsSpans(tokens, posTags, posProbs);
chunkProps = new double[chunkSpans.length];
Arrays.fill(chunkProps, 1.0);
} else {