Skip to main content

Simple dependency visualizer

Project description

Current PyPI packages

deplacy

Simple dependency visualizer for spaCy, UniDic2UD, Stanza, NLP-Cube, etc.

Usage with spaCy

>>> import spacy
>>> nlp=spacy.load("en_core_web_sm")
>>> doc=nlp("The programmer was pleased by the nicely formatted parse tree.")
>>> import deplacy
>>> deplacy.render(doc)
The        DET   <               det
programmer NOUN  ═╝<══════════╗   nsubjpass
was        AUX   <══════════╗    auxpass
pleased    VERB  ═════════╗═╝═╝═╗ ROOT
by         ADP   ═══════╗<      agent
the        DET   <════╗         det
nicely     ADV   <            advmod
formatted  VERB  ═╝<          amod
parse      NOUN  <           compound
tree       NOUN  ═╝═╝═╝<        pobj
.          PUNCT <══════════════╝ punct
>>> deplacy.serve(doc)

deplacy.render(doc,BoxDrawingWidth=1,EnableCR=False,CatenaAnalysis=True,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. CatenaAnalysis=False disables Immediate Catena Analysis.

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("The programmer was pleased by the nicely formatted parse tree.")
>>> d=str(doc)
>>> import deplacy
>>> deplacy.render(d)
The        DET   <               det
programmer NOUN  ═╝<══════════╗   nsubj
was        AUX   <══════════╗    cop
pleased    ADJ   ═════════╗═╝═╝═╗ root
by         ADP   <══════╗       case
the        DET   <════╗        det
nicely     ADV   <           advmod
formatted  VERB  ═╝<         amod
parse      NOUN  <          compound
tree       NOUN  ═╝═╝═╝═╝<      obl
.          PUNCT <══════════════╝ punct
>>> deplacy.serve(d)

Other Usages

Installation

pip install deplacy

You need to install spaCy, UniDic2UD, Stanza, or NLP-Cube separately.

Author

Koichi Yasuoka (安岡孝一)

Reference

Project details


Release history Release notifications | RSS feed

This version

0.9.3

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

If you're not sure about the file name format, learn more about wheel file names.

deplacy-0.9.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file deplacy-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: deplacy-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 14.1 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

Hashes for deplacy-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef3279938a63124e0186317b1956b45e786373984d976441e305b06b27c789f0
MD5 d6f3a9cd1549dd4d102d17bccdca7c18
BLAKE2b-256 5346f955dfb7a2025518d79bcd192622dc7cd7880bb67aad564eaceed34b673b

See more details on using hashes here.

Supported by

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