NetworkX graph from benepar constituency parse
Project description
benepar_nx
NetworkX graph from Berkeley neural parser constituency parse
Getting started , or see demo.ipynb
FIXME: get benepar
pip install benepar && \
python -c "import benepar; benepar.download('benepar_en3')"
and maybe spaCy model
python -m spacy download en_core_web_md
Add benepar to the pipeline
import spacy
md_benepar = spacy.load('en_core_web_md')
import benepar # for add_pipe('benepar'...
md_benepar.add_pipe('benepar', config={'model': 'benepar_en3'})
parse sentences:
doc = md_benepar('In the fourth quarter, we closed on the transformative acquisitions of Larry H. Miller and Total Care Auto, powered by Landcar, Kahlo Chrysler Jeep Dodge, Arapahoe Hyundai-Genesis and the Stevinson Automotive Group, representing approximately $6.6 billion in annualized revenue.')
and create graph for the sentence:
from benepar_nx.constituency_parse import create_constituency_parse_graph
s = list(doc.sents)[0]
G = create_constituency_parse_graph(s)
Draw constituency parse graph
Get graphviz , GNU sed and pydot
brew install graphviz gnu-sed && \
pip install pydot
then
from networkx.drawing.nx_pydot import write_dot
write_dot(G, 'G.dot')
that will write graph like this G.dot and
gsed -e 's/label=,/label=","/g' G.dot | dot -Tpng > output.png
Hacking
pip install --editable .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
benepar_nx-0.0.1.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file benepar_nx-0.0.1.tar.gz
.
File metadata
- Download URL: benepar_nx-0.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a57510a54822818bd85cbe7e3951129877e3d3ac073d40acb63f45b1f400108 |
|
MD5 | fac899a731183d56c8ea0b29ac684f97 |
|
BLAKE2b-256 | d742f64cc1ae602c7d131d6dc7dbf9e67abfa616be85ad4d02590ed83c443930 |
File details
Details for the file benepar_nx-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: benepar_nx-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d35d5afd547dcb639321a98fa9d3db677623210f6820525ead4baf909ce4995 |
|
MD5 | 36c4b5705c769a1c6e479242ddf8edd9 |
|
BLAKE2b-256 | 6bdcdacca391109363c91a0e85e95b35be788367470bc70455925f58bdc2a437 |