startTime = System.currentTimeMillis();
}
if (logger.isLoggable(Level.FINE))
logger.fine("now translating\n" + segment.sentence());
Chart chart; {
//TODO: we should not use "(((" to decide whether it is a lattice input
final boolean looksLikeLattice = segment.sentence().startsWith("(((");
Lattice<Integer> inputLattice = null;
Pattern sentence = null;
if (looksLikeLattice) {
inputLattice = Lattice.createFromString(segment.sentence(),
this.symbolTable);
sentence = null; // TODO SA needs to accept lattices!
} else {
int[] intSentence = this.symbolTable.getIDs(segment.sentence());
if (logger.isLoggable(Level.FINEST))
logger.finest("Converted \"" + segment.sentence() + "\" into " + Arrays.toString(intSentence));
inputLattice = Lattice.createLattice(intSentence);
sentence = new Pattern(this.symbolTable, intSentence);
}
if (logger.isLoggable(Level.FINEST))
logger.finest("Translating input lattice:\n" + inputLattice.toString());
Grammar[] grammars = new Grammar[grammarFactories.size()];
int i = 0;
for (GrammarFactory factory : this.grammarFactories) {
grammars[i] = factory.getGrammarForSentence(sentence);
// For batch grammar, we do not want to sort it every time
if (! grammars[i].isSorted()) {
System.out.println("!!!!!!!!!!!! called again");
// TODO Check to see if this is ever called here. It probably is not
grammars[i].sortGrammar(this.featureFunctions);
}
i++;
}
/* Seeding: the chart only sees the grammars, not the factories */
chart = new Chart(
inputLattice,
this.featureFunctions,
this.stateComputers,
this.symbolTable,
Integer.parseInt(segment.id()),
grammars,
this.hasLanguageModel,
JoshuaConfiguration.goal_symbol,
segment.constraints());
if (logger.isLoggable(Level.FINER))
logger.finer("after seed, time: "
+ ((double)(System.currentTimeMillis() - startTime) / 1000.0)
+ " seconds");
}
/* Parsing */
HyperGraph hypergraph = chart.expand();
if (JoshuaConfiguration.visualize_hypergraph) {
HyperGraphViewer.visualizeHypergraphInFrame(hypergraph, symbolTable);
}