// get one-best string under item
public static String extractViterbiString(SymbolTable symbolTable, HGNode node) {
StringBuffer res = new StringBuffer();
HyperEdge edge = node.bestHyperedge;
Rule rl = edge.getRule();
if (null == rl) { // deductions under "goal item" does not have rule
if (edge.getAntNodes().size() != 1) {
throw new RuntimeException("deduction under goal item have not equal one item");
}
return extractViterbiString(symbolTable, edge.getAntNodes().get(0));
}
int[] english = rl.getEnglish();
for (int c = 0; c < english.length; c++) {
if (symbolTable.isNonterminal(english[c])) {
int id = symbolTable.getTargetNonterminalIndex(english[c]);
HGNode child = (HGNode)edge.getAntNodes().get(id);
res.append(extractViterbiString(symbolTable, child));