Skip to main content

CUI-based Tree Visualizer for Universal Dependencies and Immediate Catena Analysis

Project description

Current PyPI packages

deplacy

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

Usage with spaCy

>>> import spacy
>>> nlp=spacy.load("en_core_web_sm")
>>> doc=nlp("I saw a horse yesterday which had no name.")
>>> import deplacy
>>> deplacy.render(doc)
I         PRON  <══════════════╗   nsubj
saw       VERB  ═══════════╗═╗═╝═╗ ROOT
a         DET   <════════╗      det
horse     NOUN  ═══════╗═╝<     dobj
yesterday NOUN  <══════║═════╝    npadvmod
which     DET   <════╗           nsubj
had       AUX   ═══╗═╝<          relcl
no        DET   <               det
name      NOUN  ═╝<              dobj
.         PUNCT <════════════════╝ punct

deplacy.render(doc,BoxDrawingWidth=1,EnableCR=False,WordRight=False,CatenaAnalysis=True,file=None,Japanese=False) 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 or WordRight=True may work well. CatenaAnalysis=False disables Immediate Catena Analysis.

deplacy.serve(doc,port=5000,RtoL=False) invokes a simple web-server to visualize doc with SVG. Try to connect http://127.0.0.1:5000 with your local browser. For Google Colaboratory, port=None visualizes doc directly on the notebook.

deplacy.dot(doc,RtoL=False) returns raw DOT string for graphviz.Source.

Other usages

Visualization examples

deplacy.render()

deplacy.render()

deplacy.serve()

deplacy.serve()

deplacy.dot()

deplacy.dot()

Installation

pip install deplacy

You need to install spaCy, UniDic2UD, Stanza, NLP-Cube, or Trankit separately. For Google Colaboratories, please follow (and edit) the templates shown below.

Templates for Google Colaboratory

Author

Koichi Yasuoka (安岡孝一)

Reference

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

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

deplacy-2.1.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: deplacy-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for deplacy-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23908175371a978768cd63581caf1a16c8eb55bacdfa653908ba1f9587c37c76
MD5 92ac64b0b70c7b037f2c6b76c65780ad
BLAKE2b-256 751ada5a1037c0dcca4fba356ae1ea5f9119aa0189e251aedb5b4c693116b151

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