private double[] getSegmentConfidence(Sequence input, Sequence output) {

    // initialize confidence estimator and get lattice
    ConstrainedForwardBackwardConfidenceEstimator constrFBEstimator = new ConstrainedForwardBackwardConfidenceEstimator(model);
    Transducer.Lattice lattice = ((Transducer) model).forwardBackward(input);

    // make empty confidence list
    double[] confidenceList = new double[output.size()];
    for (int i = 0; i < confidenceList.length; i++) {
      confidenceList[i] = -1;
    }
    
    // get segments (only for IO case currently)
    ArrayList<String> labels = new ArrayList<String>();
    for (int i = 0; i < output.size(); i++) {
      labels.add((String) output.get(i));
    }
    HashMap entities = IOEvaluation.getChunksIO(labels);
    
    // loop over segments and estimate confidence
    for (Iterator iter = entities.keySet().iterator(); iter.hasNext();) {
      String[] offset = ((String) iter.next()).split(",");
      int start = (new Integer(offset[0])).intValue();
      int stop = (new Integer(offset[1])).intValue();
      Segment seg = new Segment(input, output, output, start, stop , "entity", "entity");
      double constrFBConf = constrFBEstimator.estimateConfidenceFor(seg, lattice);
      
      //System.out.println(start + " - " + stop + " constr fb confidence: " + constrFBConf);

      // add confidence to list
      for (int i = start; i <= stop; i++) {
        confidenceList[i] = constrFBConf; 
      }
      
    }
    return confidenceList;
  }