斯坦福corenlp protobufs的python绑定
corenlp-protobuf的Python项目详细描述
这个包包含Stanford CoreNLP的protobuf的python绑定 规范,由protoc生成。这些绑定可用于 分析由生成的二进制数据,例如Stanford CoreNLP server。
用法:
fromcorenlp_protobufimportDocument,parseFromDelimitedString# document.dat contains a serialized Document.withopen('document.dat','r')asf:buf=f.read()doc=Document()parseFromDelimitedString(doc,buf)# You can access the sentences from doc.sentence.sentence=doc.sentence[0]# You can access any property within a sentence.print(sentence.text)# Likewise for tokenstoken=sentence.token[0]print(token.lemma)
有关更多示例,请参见test\u read.py。