我使用“prettyprint”方法获得了一个文件,我将加载它而不是使用“annotate”方法。但我找不到使用的方法。 我使用 stanford-corenlp-3.9.0 和 api。 谢谢。
最佳答案
如果您想在文件上运行一次管道,然后保存结果并稍后从文件中加载它们,则需要使用我们提供的 protobuf 序列化功能。我们没有任何方法可以加载 json
或 text
并从中构建注释。
ProtobufAnnotationSerializer serializer = new ProtobufAnnotationSerializer();
File inputFile = ...;
Annotation ann = serializer.readUndelimited(inputFile);
如果运行管道,则可以使用 -outputFormat serialized
和 -serializer edu.stanford.nlp.pipeline.ProtobufAnnotationSerializer
输出序列化文件
它处理的每个文件都将是一个代表该文件注释的 Protocol Buffer 。
关于java - 斯坦福 CoreNLP - 加载带注释的文件而不是注释方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49799065/