jaclearn.nlp.graph.dependency_visualizer.render#
This file is adapted from the spaCy project: explosion/spaCy. The spaCy project is under MIT lisence:
The MIT License (MIT)
Copyright (C) 2016-2019 ExplosionAI GmbH, 2016 spaCy GmbH, 2015 Matthew Honnibal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classes
Render dependency parses as SVGs. |
Functions
|
|
|
Class DependencyVisualizer
- class DependencyVisualizer[source]#
Bases:
object
Render dependency parses as SVGs.
- __init__(options={})[source]#
Initialise dependency renderer. options (dict): Visualiser-specific options (compact, word_spacing,
arrow_spacing, arrow_width, arrow_stroke, distance, offset_x, color, bg, font)
- __new__(**kwargs)#
- get_levels(arcs)[source]#
Calculate available arc height “levels”. Used to calculate arrow heights dynamically and without wasting space.
- render_word(text, tag, i)[source]#
Render individual word.
- Parameters:
text (unicode) – Word text.
tag (unicode) – Part-of-speech tag.
i (int) – Unique ID, typically word index.
- Returns:
Rendered SVG markup.
- Return type:
(unicode)
- style = 'dep'#
Functions