logger.info("Failed to decode input sequence " + i + ", answer " + a);
error = true;
}
}
if (!error) {
ConstrainedForwardBackwardConfidenceEstimator cfb = new ConstrainedForwardBackwardConfidenceEstimator(crf);
SumLatticeDefault lattice = new SumLatticeDefault (cfb.getTransducer(), input);
double conf = 0;
for (int j = 0; j < input.size(); j++) {
StringBuffer buf = new StringBuffer();
for (int a = 0; a < k; a++) {
String tag = outputs[a].get(j).toString();
//Lets's get the confidence if this is an entity
if(tag.startsWith("B-")) {
int endTagIdx = j+1;
while(endTagIdx < input.size() && outputs[a].get(endTagIdx).toString().startsWith("I-")) {
endTagIdx++;
}
endTagIdx -= 1;
Segment s = new Segment(input, outputs[a], outputs[a], j, endTagIdx, tag, outputs[a].get(endTagIdx));
conf = cfb.estimateConfidenceFor(s, lattice);
}
if(!tag.equals("O")) {
tag = tag + ":" + Double.toString(conf);
}