jaclearn.nlp.graph.dependency_visualizer package¶
Submodules¶
jaclearn.nlp.graph.dependency_visualizer.render module¶
This file is adapted from the spaCy project: https://github.com/explosion/spaCy/blob/master/spacy/displacy/render.py. 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.
-
class
jaclearn.nlp.graph.dependency_visualizer.render.DependencyVisualizer(options={})[source]¶ Bases:
objectRender dependency parses as SVGs.
-
get_arc(x_start, y, y_curve, x_end)[source]¶ Render individual arc.
Parameters: Returns: Definition of the arc path (‘d’ attribute).
Return type: (unicode)
-
get_arrowhead(direction, x, y, end)[source]¶ Render individual arrow head.
Parameters: Returns: Definition of the arrow head path (‘d’ attribute).
Return type: (unicode)
-
get_levels(arcs)[source]¶ Calculate available arc height “levels”. Used to calculate arrow heights dynamically and without wasting space.
Parameters: arcs (list) – Individual arcs and their start, end, direction and label. Returns: Arc levels sorted from lowest to highest. Return type: (list)
-
render(parsed, page=False, minify=False)[source]¶ Render complete markup.
Parameters: Returns: Rendered SVG or HTML markup.
Return type: (unicode)
-
render_arrow(label, start, end, direction, i)[source]¶ Render individual arrow.
Parameters: Returns: Rendered SVG markup.
Return type: (unicode)
-
render_svg(render_id, words, arcs)[source]¶ Render SVG.
Parameters: Returns: Rendered SVG markup.
Return type: (unicode)
-
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'¶
-