private void writeTerminals(PhraseStructure phraseStructure) throws MaltChainedException {
try {
for (int index : phraseStructure.getTokenIndices()) {
final PhraseStructureNode terminal = phraseStructure.getTokenNode(index);
final Iterator<ColumnDescription> columns = dataFormatInstance.iterator();
ColumnDescription column = null;
int ti = 1;
while (columns.hasNext()) {
column = columns.next();
if (column.getCategory() == ColumnDescription.INPUT) {
writer.write(terminal.getLabelSymbol(column.getSymbolTable()));
int nTabs = 1;
if (ti == 1 || ti == 2) {
nTabs = 3 - (terminal.getLabelSymbol(column.getSymbolTable()).length() / 8);
} else if (ti == 3) {
nTabs = 1;
} else if (ti == 4) {
nTabs = 2 - (terminal.getLabelSymbol(column.getSymbolTable()).length() / 8);
}
if (nTabs < 1) {
nTabs = 1;
}
for (int j = 0; j < nTabs; j++) {
writer.write('\t');
}
ti++;
} else if (column.getCategory() == ColumnDescription.PHRASE_STRUCTURE_EDGE_LABEL) {
if (terminal.getParent() != null && terminal.hasParentEdgeLabel(column.getSymbolTable())) {
writer.write(terminal.getParentEdgeLabelSymbol(column.getSymbolTable()));
writer.write('\t');
} else {
writer.write("--\t");
}
} else if (column.getCategory() == ColumnDescription.PHRASE_STRUCTURE_NODE_LABEL) {
if (terminal.getParent() == null || terminal.getParent() == phraseStructure.getPhraseStructureRoot()) {
writer.write('0');
} else {
writer.write(Integer.toString(nonTerminalIndexMap.get(terminal.getParent().getIndex())));
// writer.write(Integer.toString(terminal.getParent().getIndex()+START_ID_OF_NONTERMINALS-1));
}
}
}
for (Edge e : terminal.getIncomingSecondaryEdges()) {
if (e.hasLabel(column.getSymbolTable())) {
writer.write('\t');
writer.write(e.getLabelSymbol(column.getSymbolTable()));
writer.write('\t');
if (e.getSource() instanceof NonTerminalNode) {
writer.write(Integer.toString(nonTerminalIndexMap.get(e.getSource().getIndex())));
// writer.write(Integer.toString(e.getSource().getIndex()+START_ID_OF_NONTERMINALS-1));
} else {