{ "info": { "author": "Kyle Rawlins", "author_email": "kgr@jhu.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Jupyter", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Topic :: Multimedia :: Graphics", "Topic :: Scientific/Engineering :: Visualization", "Topic :: Text Processing :: Linguistic", "Topic :: Text Processing :: Markup", "Topic :: Utilities" ], "description": "# `svgling`: syntax trees in python + svg\n\n**Author**: Kyle Rawlins, [kgr@jhu.edu](kgr@jhu.edu)\n\n**Dependencies**: [`svgwrite`](https://pypi.org/project/svgwrite/), python 3\n\n**Repository**: [https://github.com/rawlins/svgling/](https://github.com/rawlins/svgling/)\n\n**Installation**: download and use setuptools, or `pip install svgling`\n\n**License**: MIT License\n\n## Overview\n\nThe `svgling` package is a pure python package for doing single-pass rendering\nof linguistics-style constituent trees into SVG. It is primarily intended for\nintegrating with Jupyter notebooks, but could be used to generate SVG diagrams\nfor all sorts of other purposes. It involves no javascript and so will work\nin Jupyter without any plugins.\n\nThe basic interface is pretty simple: pass a tree-describing object to\n`svgling.draw_tree` (e.g. a tuple consisting of a lable and a sequence of\ndaughter nodes, which mey themselves be trees).\n\n import svgling\n svgling.draw_tree((\"S\", (\"NP\", (\"D\", \"the\"), (\"N\", \"elephant\")), (\"VP\", (\"V\", \"saw\"), (\"NP\", (\"D\", \"the\"), (\"N\", \"rhinoceros\")))))\n\nThis produces an SVG image like the following:\n\n![example sentence](https://raw.githubusercontent.com/rawlins/svgling/master/demotree.svg?sanitize=true)\n\nThe tree drawing code accepts two main tree formats: lisp-style trees made from\nlists of lists (or tuples of tuples), with node labels as strings, or trees from\nthe [`nltk`](https://www.nltk.org/) package, i.e. objects instantiating the\n[`nltk.tree.Tree`](https://www.nltk.org/_modules/nltk/tree.html) API. The\nfollowing nltk code, as long as `svgling` has been imported, produces an\nidentical tree diagram to the above example, though by a very different route:\n\n import svgling\n nltk.Tree.fromstring(\"(S (NP (D the) (N elephant)) (VP (V saw) (NP (D the) (N rhinoceros))))\")\n\n(That is, `svgling` monkey-patches NLTK to use SVG-based tree drawing code. You\nmay also want to call `svgling.disable_nltk_png()` to fully disable the\ndefault NLTK png renderer, especially if you're on a mac or windows 64, or are\nrunning NLTK on a headless device; see nltk issue\n[#1887](https://github.com/nltk/nltk/issues/1887) for use-cases).)\n\nBeyond basic tree-drawing, the package supports a number of flourishes like\nmovement arrows. For documentation and examples, see the three .ipynb files in\nthe root of this repository: (links below to nbviewer static rendered versions):\n\n* [Overview.ipynb](https://nbviewer.jupyter.org/github/rawlins/svgling/blob/master/Overview.ipynb)\n* [svgling Gallery.ipynb](https://nbviewer.jupyter.org/github/rawlins/svgling/blob/master/svgling%20Gallery.ipynb)\n* [svgling Manual.ipynb](https://nbviewer.jupyter.org/github/rawlins/svgling/blob/master/svgling%20Manual.ipynb)\n\n## Core design principles and goals\n\n1. Be well suited for *programmatic* generation of tree diagrams (not just\nhand-customized diagrams).\n2. Be equally suited for theoretical linguistics and computational\nlinguistics/NLP, at least for cases where the latter is targeting constituent\ntrees. (This package is not aimed at dependency trees/graphs.)\n3. Do as much as possible with pure python (as opposed to python+javascript, or\npython+tk, or python+dot, or...).\n\n## Strengths and limitations\n\nThe `svgling` package does its rendering in one pass -- it takes a tree\nstructure as input, produces an svg output, and that's it. Because of this, it\nis extremely simple to use in Jupyter, and no messing with plugins or Jupyter\nsettings should be necessary. Because it is SVG-based, scaling and embedding in\nany web context should work smoothly. It also has minimal dependencies, just\none package that provides an abstraction layer over generating svg. (If you're\ninterested in programmatic diagramming in svg for Jupyter, I do recommend\n[`svgwrite`](https://github.com/mozman/svgwrite), it's under active development\nand has a very pleasant API + good documentation.)\n\nSingle-pass rendering also places limitations on what can be done. One of the\nchallenges is that it mostly uses absolute position, and the exact position and\nwidth of text elements can't be determined without actually rendering to some\ndevice and seeing what happens. In addition, the exact details of rendering are\nin various ways at the mercy of the rendering device. This all means that\n`svgling` uses a bunch of tricks to estimate node size and width, and won't\nalways be perfect on all devices. This situation also places some hard\nlimitations on how far `svgling` can be extended without adding javascript or\nother multi-pass rendering techniques. For example, I would eventually like to\nallow mathjax in nodes, and allow nodes with complex / multi-line shapes, but at\nthe moment this does not seem possible in pure SVG without javascript on the\nclient side. The package does provide basic support for hybrid HTML/SVG tree\ndiagrams that allow complex nodes, including MathJax, but with substantial\nlimitations.\n\nThere are many things that it might be nice to add to this package; if you find\n`svgling` useful, have any requests, or find any bugs, please let me know.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rawlins/svgling", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "svgling", "package_url": "https://pypi.org/project/svgling/", "platform": "", "project_url": "https://pypi.org/project/svgling/", "project_urls": { "Homepage": "https://github.com/rawlins/svgling" }, "release_url": "https://pypi.org/project/svgling/0.3.0/", "requires_dist": [ "svgwrite" ], "requires_python": ">=3", "summary": "SVG+Python based rendering of linguistics-style (constituent) trees", "version": "0.3.0" }, "last_serial": 4581674, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "704dc9ca9cced56ceec540ba7eb22d00", "sha256": "5d50a9b848ddce0b9d294652f8163c0015edd9666d49db07b6e911b5f19449a5" }, "downloads": -1, "filename": "svgling-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "704dc9ca9cced56ceec540ba7eb22d00", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 7158, "upload_time": "2018-11-07T19:29:18", "url": "https://files.pythonhosted.org/packages/c2/2c/a955f88dc5eea79720daea44167287d8b140fbbe63aadcd6cc65d3ee73ba/svgling-0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02917d53591216d5edc8918ca385fb80", "sha256": "1a3ff784d2bde8f1779be73bb4407d6dfb09ddd29f47ca2262fca73980f5768f" }, "downloads": -1, "filename": "svgling-0.1.tar.gz", "has_sig": false, "md5_digest": "02917d53591216d5edc8918ca385fb80", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 6159, "upload_time": "2018-11-07T19:29:20", "url": "https://files.pythonhosted.org/packages/01/b6/5a8d66c94af2404ccd0bfd2bf7741d87645ece2c1bdf4496f4510c2cf878/svgling-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d30d19f0af57864696f8bef0bc392cfe", "sha256": "27d4901ffb4700e34053784ba93f878e202a4111b4c868b61da894c821c5ca5e" }, "downloads": -1, "filename": "svgling-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d30d19f0af57864696f8bef0bc392cfe", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 7216, "upload_time": "2018-11-07T19:35:53", "url": "https://files.pythonhosted.org/packages/6a/93/fc01355d7da0dc2e5d5af83be24b243621d690b78fe5d65f34b1179621f3/svgling-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "16e36e2ce6ee514e806984a0d399ae5b", "sha256": "0ec2ae1241634dc32d2641cdc2939e67a1af097a75941ecfab79328516abe3c8" }, "downloads": -1, "filename": "svgling-0.1.1.tar.gz", "has_sig": false, "md5_digest": "16e36e2ce6ee514e806984a0d399ae5b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 6200, "upload_time": "2018-11-07T19:35:54", "url": "https://files.pythonhosted.org/packages/1b/f2/9b62c58ff821430eb0ebe42847a7b21a8396f7c84bda8965f19658fc1037/svgling-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "56f385ce83d0d2b9dc3a70d84e7258bb", "sha256": "dad768ea98aa8dd2e1d2ba775de2fcbe678a2339687987c467c16821f0afe284" }, "downloads": -1, "filename": "svgling-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "56f385ce83d0d2b9dc3a70d84e7258bb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 7270, "upload_time": "2018-11-07T21:02:19", "url": "https://files.pythonhosted.org/packages/66/25/6182520b58e4b3e142f40e83a948c8fcdd558505d5298fd76267feae8bc6/svgling-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd17f52262f5b9a0d7d48b66d496026c", "sha256": "0a55548dc94ddeb1cdae15b5c1b1ff5fb2b666fad54e4d9aede24834d7c154a2" }, "downloads": -1, "filename": "svgling-0.1.2.tar.gz", "has_sig": false, "md5_digest": "fd17f52262f5b9a0d7d48b66d496026c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 6262, "upload_time": "2018-11-07T21:02:20", "url": "https://files.pythonhosted.org/packages/b7/80/d9eedd8327d5d771d8cc01b3f81fd5169588fd1ca5bccfbce692b7501b51/svgling-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "2eb61b6749ea1aeb7a2c4645b2489965", "sha256": "746d44e35501f7217d35771b400732c2921837cdb8c2410594f059b7506dffaf" }, "downloads": -1, "filename": "svgling-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2eb61b6749ea1aeb7a2c4645b2489965", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 7764, "upload_time": "2018-11-08T20:19:32", "url": "https://files.pythonhosted.org/packages/c5/83/db9ea74c0e7efaf0032f8e8abc70f4267cb8f31f2c1542b0dc5cd1bc4c21/svgling-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dba25d0c1299733cec19a6c0d2573464", "sha256": "868a6798beb8e557f00cc04e846319503b9c0da2e9b15a2d815a81ecb91dfb0f" }, "downloads": -1, "filename": "svgling-0.1.3.tar.gz", "has_sig": false, "md5_digest": "dba25d0c1299733cec19a6c0d2573464", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 6769, "upload_time": "2018-11-08T20:19:33", "url": "https://files.pythonhosted.org/packages/47/39/562cbf86402f212bf17807b5d087a7875fa5dbc8a9b5100833f0d60df198/svgling-0.1.3.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "4edbf3a14a4fbdef3b3165f1da918e61", "sha256": "ee2a5d1da1b304fa0a5804b8213c2b1cf9e21aa219561ca6b98cd6b0e64ec10b" }, "downloads": -1, "filename": "svgling-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "4edbf3a14a4fbdef3b3165f1da918e61", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 16798, "upload_time": "2018-11-26T22:16:31", "url": "https://files.pythonhosted.org/packages/c5/39/3bc9a53f776c9f8eb8a73898fd3d94ef1c8b319adfb9e5ade34f6f0ad4de/svgling-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "907f3485a63f9b79643d0da9e8bb7937", "sha256": "d08d38c10de394ec196aee23d15992aebd7e7ee3ae714835c649fccc55a655f6" }, "downloads": -1, "filename": "svgling-0.2.0.tar.gz", "has_sig": false, "md5_digest": "907f3485a63f9b79643d0da9e8bb7937", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 17031, "upload_time": "2018-11-26T22:16:32", "url": "https://files.pythonhosted.org/packages/c2/bb/47781223bc362d86204bcaf545378fce207309e775d007c16caf5c5e796e/svgling-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "ff75ace13d5ee0efbf1e616bc51d6e9a", "sha256": "1e9a578c957fbebf4b221cb3d0dfc89c033098152d57592388c9df696369196e" }, "downloads": -1, "filename": "svgling-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ff75ace13d5ee0efbf1e616bc51d6e9a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 21305, "upload_time": "2018-12-10T17:06:12", "url": "https://files.pythonhosted.org/packages/19/d2/fe75c4143627391d055420cc25f3e278123b4df0cbaee61da72332cc38b0/svgling-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "41f6668bd9461e737ddc0f07225889d0", "sha256": "91414e413ecc981d8c69c49a03f47a81760a8770a2c130cbf79d7e27b93f4803" }, "downloads": -1, "filename": "svgling-0.3.0.tar.gz", "has_sig": false, "md5_digest": "41f6668bd9461e737ddc0f07225889d0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 21117, "upload_time": "2018-12-10T17:06:14", "url": "https://files.pythonhosted.org/packages/a7/38/2bb392d2b2546744bd0339b70a43afdbb75cb500d368fdfd33bb6f719565/svgling-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ff75ace13d5ee0efbf1e616bc51d6e9a", "sha256": "1e9a578c957fbebf4b221cb3d0dfc89c033098152d57592388c9df696369196e" }, "downloads": -1, "filename": "svgling-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ff75ace13d5ee0efbf1e616bc51d6e9a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3", "size": 21305, "upload_time": "2018-12-10T17:06:12", "url": "https://files.pythonhosted.org/packages/19/d2/fe75c4143627391d055420cc25f3e278123b4df0cbaee61da72332cc38b0/svgling-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "41f6668bd9461e737ddc0f07225889d0", "sha256": "91414e413ecc981d8c69c49a03f47a81760a8770a2c130cbf79d7e27b93f4803" }, "downloads": -1, "filename": "svgling-0.3.0.tar.gz", "has_sig": false, "md5_digest": "41f6668bd9461e737ddc0f07225889d0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 21117, "upload_time": "2018-12-10T17:06:14", "url": "https://files.pythonhosted.org/packages/a7/38/2bb392d2b2546744bd0339b70a43afdbb75cb500d368fdfd33bb6f719565/svgling-0.3.0.tar.gz" } ] }