1
Tree tree = sentence.get(TreeAnnotation.class);

我想将解析树的 XML 表示形式转换为字符串。我该怎么做?

4

1 回答 1

1

字符串 s 包含解析树的 XML 输出"

import java.io.StringWriter;
import java.io.PrintWriter;

StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
tree.indentedXMLPrint( writer, false);
String s = stringWriter.toString()
于 2013-03-18T07:06:45.377 回答