Skip to main content

Simple dependency visualizer

Project description

Current PyPI packages

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.render(doc,2)
I     PRON  <     nsubj
saw   VERB ─┴─┐ ROOT
three NUM   <   nummod
ships NOUN ─┘ < dobj

deplacy.render(doc,BoxDrawingWidth=1,file=None) renders doc on a terminal. For old terminals, whose Box Drawing characters are "fullwidth", BoxDrawingWidth=2 nicely works.

Usage with UniDic2UD

>>> import unidic2ud
>>> nlp=unidic2ud.load(None,"english-ewt")
>>> doc=nlp("I saw three ships",raw=True)
>>> import deplacy
>>> deplacy.render(doc)

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)

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)

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

deplacy-0.3.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page