https://github.com/stanfordnlp/python-corenlp-protobuf
Python bindings for Stanford CoreNLP's protobufs.
https://github.com/stanfordnlp/python-corenlp-protobuf
corenlp
Last synced: 4 months ago
JSON representation
Python bindings for Stanford CoreNLP's protobufs.
- Host: GitHub
- URL: https://github.com/stanfordnlp/python-corenlp-protobuf
- Owner: stanfordnlp
- License: mit
- Created: 2017-04-28T00:55:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-23T23:19:57.000Z (over 7 years ago)
- Last Synced: 2025-07-19T18:53:46.614Z (5 months ago)
- Topics: corenlp
- Language: Python
- Size: 37.1 KB
- Stars: 20
- Watchers: 11
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Stanford CoreNLP Python Bindings
================================
.. image:: https://travis-ci.org/stanfordnlp/python-corenlp-protobuf.svg?branch=master
:target: https://travis-ci.org/stanfordnlp/python-corenlp-protobuf
This package contains python bindings for `Stanford
CoreNLP `_'s protobuf
specifications, as generated by `protoc`. These bindings can used to
parse binary data produced by, e.g., the `Stanford CoreNLP
server `_.
----
Usage:
.. code-block:: python
from corenlp_protobuf import Document, parseFromDelimitedString
# document.dat contains a serialized Document.
with open('document.dat', 'r') as f:
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 tokens
token = sentence.token[0]
print(token.lemma)
See `test_read.py` for more examples.