List<Derivation> firstDerivs = first.getPredDerivations();
LogInfo.logs("STAT %s", first.getEvaluation().summary());
for (int j = 0; j < firstDerivs.size(); j++) {
Derivation firstDeriv = firstDerivs.get(j);
LogInfo.begin_track("Ex %d, derivation %d", i, j);
if (firstDeriv.getCompatibility() == 1.0d)
LogInfo.log("DERIV CORRECT");
else
LogInfo.log("DERIV WRONG");
LogInfo.logs("DERIV %s", firstDeriv);
// TODO no executor stats being written/loaded at present.
//firstDeriv.getExecutorStats().logStats(""+j);
List<Pair<String, Double>> topFeatures;
List<Pair<String, Double>> botFeatures;
if (row.size() >= 2) {
Integer derivIndex = rowDerivIndices.get(1).get(firstDeriv);
Derivation secondDeriv = (derivIndex == null)
? null
: row.get(1).getPredDerivations().get(derivIndex);
topFeatures = getTopFeatures(
topN,
params.get(0),
params.get(1),
firstDeriv,
secondDeriv,
false);
botFeatures = getTopFeatures(
topN,
params.get(0),
params.get(1),
firstDeriv,
secondDeriv,
true);
} else {
topFeatures = getTopFeatures(
topN,
params.get(0),
null,
firstDeriv,
null,
false);
botFeatures = getTopFeatures(
topN,
params.get(0),
null,
firstDeriv,
null,
true);
}
String[] positions = new String[row.size()];
String[][] chart = new String[topFeatures.size() + botFeatures.size()][row.size()];
String[][] totals = new String[4][row.size()];
for (int k = 0; k < row.size(); k++) {
Integer derivIndex = rowDerivIndices.get(k).get(firstDeriv);
// Positions
positions[k] = String.format("%12s", (derivIndex == null) ? "~" : ("" + derivIndex));
// Features
// Walk down topFeatures and up botFeatures at the same time.
int n = Math.max(topFeatures.size(), botFeatures.size());
for (int f = 0; f < n; f++) {
if (f < topFeatures.size()) {
String featureName = topFeatures.get(f).getFirst();
double val = params.get(k).getWeight(featureName);
chart[f][k] = String.format("%12.4f", val);
}
if (f < botFeatures.size()) {
String featureName = botFeatures.get(f).getFirst();
double val = params.get(k).getWeight(featureName);
chart[chart.length - 1 - f][k] = String.format("%12.4f", val);
}
}
// Totals
if (derivIndex == null) {
totals[0][k] = totals[1][k] = totals[2][k] = totals[3][k] = String.format("%12s", "~");
} else {
Derivation deriv = row.get(k).getPredDerivations().get(derivIndex);
totals[0][k] = String.format("%12.4f", deriv.getScore());
totals[1][k] = String.format("%12.4f", deriv.getProb());
totals[2][k] = String.format("%12.4f", deriv.getCompatibility());
totals[3][k] = String.format("%12d", deriv.getMaxBeamPosition());
}
}
LogInfo.log("");
LogInfo.logs("%-40s\t%12s%s", "POS", "", Joiner.on(' ').join(positions));