Simple dependency visualizer
Project description
deplacy
Simple dependency visualizer for spaCy, UniDic2UD, Stanza, and NLP-Cube.
Usage with spaCy
>>> import spacy
>>> nlp=spacy.load("en_core_web_sm")
>>> doc=nlp("I saw three ships")
>>> import deplacy
>>> deplacy.render(doc)
I PRON <┐ nsubj
saw VERB ─┴─┐ ROOT
three NUM <┐ │ nummod
ships NOUN ─┘<┘ dobj
>>> deplacy.serve(doc)
http://127.0.0.1:5000 HTTP deplacy
deplacy.render(doc,BoxDrawingWidth=1,EnableCR=False,file=None) renders doc on a terminal. For old terminals, whose Box Drawing characters are "fullwidth", BoxDrawingWidth=2 nicely works. For several languages with "proportional" characters, EnableCR=True may work well.
deplacy.serve(doc,port=5000) invokes a simple web-server to visualize doc with SVG. Try to connect http://127.0.0.1:5000 with your local browser.
Usage with UniDic2UD
>>> import unidic2ud
>>> nlp=unidic2ud.load(None,"english-ewt")
>>> doc=nlp("I saw three ships")
>>> d=str(doc)
>>> import deplacy
>>> deplacy.render(d)
>>> deplacy.serve(d)
Usage with Stanza
>>> import stanza
>>> nlp=stanza.Pipeline("en")
>>> doc=nlp("I saw three ships")
>>> from stanza.utils.conll import CoNLL
>>> d=CoNLL.conll_as_string(CoNLL.convert_dict(doc.to_dict()))
>>> import deplacy
>>> deplacy.render(d)
>>> deplacy.serve(d)
Usage with NLP-Cube
>>> from cube.api import Cube
>>> nlp=Cube()
>>> nlp.load("en")
>>> doc=nlp("I saw three ships")
>>> d="".join("".join(str(t)+"\n" for t in s) for s in doc)
>>> import deplacy
>>> deplacy.render(d)
>>> deplacy.serve(d)
Installation
pip install deplacy
You need to install spaCy, UniDic2UD, Stanza, or NLP-Cube separately.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deplacy-0.6.2-py3-none-any.whl.
File metadata
- Download URL: deplacy-0.6.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.44.0 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7f7d82313c4e56593320d63233a42ab094dcdaf9fb5a0732e2644fbd9235673
|
|
| MD5 |
dfbcea61214fff26417c1329a4494f1e
|
|
| BLAKE2b-256 |
0df45eb75ca503a841f5dd465307300a461d9c1ea8ea631eea29ee5aab33adf8
|