if (trainer instanceof HMM && model1g != null) {
((HMM)trainer).setModel1Posteriors(model1g);
}
Alignment a = trainer.viterbiAlign(value, pr);
ReferenceAlignment ref = (ReferenceAlignment)value.getAlignment();
AlignmentPosteriorGrid ghmm = null;
AlignmentPosteriorGrid gmodel1 = null;
if (generatePosteriors) {
if (value.hasAlignmentPosteriors())
model1g = value.getAlignmentPosteriorGrid();
if (trainer instanceof HMM)
((HMM)trainer).setModel1Posteriors(model1g);
AlignmentPosteriorGrid g = trainer.computeAlignmentPosteriors(value);
if (value.hasAlignmentPosteriors()) {
//System.err.println(key + ": already has posteriors!");
model1g = value.getAlignmentPosteriorGrid();
//model1g.penalizeGarbageCollectors(2, 0.27f, 0.20f);
Alignment model1a = model1g.alignPosteriorThreshold(0.5f);
//System.out.println("MODEL1 MAP ALIGNMENT:\n"+model1a.toStringVisual());
//ystem.out.println("HMM VITERBI ALIGNMENT:\n"+a.toStringVisual());
//model1g.diff(g);
ghmm = g;
gmodel1 = model1g;
Alignment da = model1g.alignPosteriorThreshold((float)Math.exp(-1.50f));
Alignment ints = Alignment.intersect(da, model1a);
//Alignment df = Alignment.subtract(ints, a);
//System.out.println("DIFF (HMM - (Model1 \\intersect DIFF)): " + key + "\n" +df.toStringVisual() + "\n"+model1g);
//a = Alignment.union(a, df);
}
value.setAlignmentPosteriorGrid(g);
}
if (ref != null) {
a = trainer.computeAlignmentPosteriors(value).alignPosteriorThreshold(0.5f);
reporter.incrCounter(AlignmentEvalEnum.SURE_HITS, ref.countSureHits(a));
reporter.incrCounter(AlignmentEvalEnum.PROBABLE_HITS, ref.countProbableHits(a));
reporter.incrCounter(AlignmentEvalEnum.HYPOTHESIZED_ALIGNMENT_POINTS, a.countAlignmentPoints());
reporter.incrCounter(AlignmentEvalEnum.REF_ALIGNMENT_POINTS, ref.countSureAlignmentPoints());
if (gmodel1!=null) {
StringBuffer sb=new StringBuffer();
for (int i =0; i<ref.getELength(); i++)
for (int j=0; j<ref.getFLength(); j++) {
if (ref.isProbableAligned(j, i) || ref.isSureAligned(j, i))
sb.append("Y");
else
sb.append("N");
sb.append(" 1:").append(gmodel1.getAlignmentPointPosterior(j, i+1));
sb.append(" 3:").append(ghmm.getAlignmentPointPosterior(j, i+1));