use of com.joliciel.talismane.parser.ParseTreeNode in project talismane by joliciel-informatique.
the class NonProjectiveStatisticsWriter method onNextParseConfiguration.
@Override
public void onNextParseConfiguration(ParseConfiguration parseConfiguration) throws IOException {
ParseTree parseTree = new ParseTree(parseConfiguration, false);
if (!parseTree.isProjective()) {
writer.write(CSV.format(parseConfiguration.getSentence().getText().toString()));
writer.write(CSV.format(parseTree.getGapDegree().getRight()));
writer.write(CSV.format(parseTree.getGapDegree().getLeft().toString()));
int gapDegree = parseTree.getGapDegree().getRight();
if (gapDegree > 9)
gapDegree = 9;
gapDegreeCounts[gapDegree]++;
writer.write(CSV.format(parseTree.getEdgeDegree().getRight()));
writer.write(CSV.format(parseTree.getEdgeDegree().getLeft().toString()));
int edgeDegree = parseTree.getEdgeDegree().getRight();
if (edgeDegree > 9)
edgeDegree = 9;
edgeDegreeCounts[edgeDegree]++;
writer.write(CSV.format(parseTree.isWellNested()));
for (Pair<ParseTreeNode, ParseTreeNode> illNestedNodes : parseTree.getIllNestedNodes()) {
writer.write(CSV.format(illNestedNodes.getLeft().toString()));
writer.write(CSV.format(illNestedNodes.getRight().toString()));
}
if (!parseTree.isWellNested())
illNestedCount++;
writer.write("\n");
writer.flush();
nonProjectiveCount++;
for (ParseTreeNode nonProjNode : parseTree.getNonProjectiveNodes()) {
writer2.write(CSV.format(parseConfiguration.getSentence().getText().toString()));
writer2.write(CSV.format(nonProjNode.getPosTaggedToken().toString()));
writer2.write(CSV.format(nonProjNode.toString()));
writer2.write(CSV.format(nonProjNode.getGapCount()));
writer2.write(CSV.format(nonProjNode.getEdgeCount()));
for (DependencyArc arc : nonProjNode.getGapHeads()) {
writer2.write(CSV.format(arc.toString()));
}
writer2.write("\n");
writer2.flush();
nonProjectiveNodeCount++;
}
for (DependencyArc arc : parseTree.getNonProjectiveEdges()) {
writer3.write(CSV.format(parseConfiguration.getSentence().getText().toString()));
writer3.write(CSV.format(arc.toString()));
writer3.write("\n");
writer3.flush();
nonProjectiveEdgeCount++;
}
} else {
gapDegreeCounts[0]++;
edgeDegreeCounts[0]++;
}
totalNodeCount += parseConfiguration.getPosTagSequence().size() - 1;
totalCount++;
}
Aggregations