computeCost(parentNode, edge, modelCost, models);
}
//### get hyp string recursively
StringBuffer res = new StringBuffer();
Rule rl = edge.getRule();
if (null == rl) { // hyperedges under "goal item" does not have rule
if (useTreeFormat) {
//res.append("(ROOT ");
res.append('(');
res.append(rootID);
if (includeAlign) {
// append "{i-j}"
res.append('{');
res.append(parentNode.i);
res.append('-');
res.append(parentNode.j);
res.append('}');
}
res.append(' ');
}
for (int id = 0; id < edge.getAntNodes().size(); id++) {
res.append( getChildDerivationState(kbestExtator, edge, id).getHypothesis(symbolTbl,kbestExtator, useTreeFormat, modelCost, models, numNodesAndEdges) );
if (id < edge.getAntNodes().size()-1) res.append(' ');
}
if (useTreeFormat)
res.append(')');
} else {
if (useTreeFormat) {
res.append('(');
res.append(rl.getLHS());
if (includeAlign) {
// append "{i-j}"
res.append('{');
res.append(parentNode.i);
res.append('-');
res.append(parentNode.j);
res.append('}');
}
res.append(' ');
}
if (!isMonolingual) { // bilingual
int[] english = rl.getEnglish();
for (int c = 0; c < english.length; c++) {
if (symbolTbl.isNonterminal(english[c])) {
int id = symbolTbl.getTargetNonterminalIndex(english[c]);
res.append( getChildDerivationState(kbestExtator, edge, id).getHypothesis(symbolTbl, kbestExtator, useTreeFormat, modelCost, models, numNodesAndEdges));
} else {
res.append(english[c]);
}
if (c < english.length-1) res.append(' ');
}
} else { // monolingual
int[] french = rl.getFrench();
int nonTerminalID = 0;//the position of the non-terminal in the rule
for (int c = 0; c < french.length; c++) {
if (symbolTbl.isNonterminal(french[c])) {
res.append( getChildDerivationState(kbestExtator, edge, nonTerminalID).getHypothesis(symbolTbl,kbestExtator, useTreeFormat, modelCost, models, numNodesAndEdges));
nonTerminalID++;