SDPV is Python library designed to visualize Spacy DependencyMatcher Pattern and thus ease your pattern design.
git clone https://github.com/Jacobe2169/spacy-depmatcher-pattern-visualiser.git
cd spacy-depmatcher-pattern-visualiser
python setup.py install
In addition to the modules listed in requirements.txt
, GraphViz must be installed!
from sdpv import draw_pattern
pattern = [
# anchor token: founded
{
"RIGHT_ID": "founded",
"RIGHT_ATTRS": {"ORTH": "founded"}
},
# founded -> subject
{
"LEFT_ID": "founded",
"REL_OP": ">",
"RIGHT_ID": "subject",
"RIGHT_ATTRS": {"DEP": "nsubj"}
},
# "founded" follows "initially"
{
"LEFT_ID": "founded",
"REL_OP": ";",
"RIGHT_ID": "initially",
"RIGHT_ATTRS": {"ORTH": "initially"}
}
]
Matplotlib is set by default, so just run:
draw_pattern(pattern)
You can customize the node color, the label font color and the size of the generated figure.
draw_pattern(pattern, node_color="grey",node_size=20,figsize=(10,5))
draw_pattern(pattern,mode="graphviz")
Compared to Matplotlib, you need to set the parameter show
to ipynb
draw_pattern(pattern,mode="graphviz",show="ipynb")
draw_pattern(pattern,mode="notebook")
Use the filename
parameter
draw_pattern(pattern,mode="graphviz",filename="graphviz.png")
Attention As of today, the export of vis.js plot is only available in PNG.
If you wish to use SDPV in a better fashion, you can use the webapp
cd webapp
python server.py
This library was programmed by Jacques Fize.