Your interactive ontology visualizing and SPARQL query formulation tool xPPU Scenario Version
[[TOC]]
SPARQL Query Viz is a python based interactive ontology visualizing tool, that supports you to compose SPARQL queries interactively.
The interactive graph gives an overview over the structure of the ontology at hand. The visualization can be adjusted to your needs by tweaking the visualization option, by coloring and sizing of the graph elements and by turning on/ off the ABox visualization.
SPARQL Query Viz provides an interactive query formulation panel, that enables you to compose and evaluate queries. Templates and interactive composition techniques support particularly lay users in query formulation.
This codebase of the SPARQL Query Viz is an adaptation of the original version with special adaptations for the xPPU Ontology.
- Clone the repo from GitLab
- Set up a virtual environment, by using
python -m venv myenv
and activate the env:- (Windows)
.\\myvenv\\Scripts\\activate.bat
- (Linux & MacOS)
source myvenv/bin/activate
- (Windows)
- Install all relevent dependencies by running
pip install -r requirements.txt
To visualize the xPPU Ontology, the file SPARQLQueryViz_run_use_case.py
has to be executed.
To do this run python SPARQLQueryViz_run_use_case.py
in the directory where the corresponding file is located.
Alternatively the following two lines of code also do the job:
from sparql_query_viz import SQV
sqv = SQV(iri="http://example.org/onto-ex.owl", path="sparql_query_viz/datasets/ontologies/xPPU_onto.owl", abox=True)
sqv.plot(host="127.0.0.1", port=8050, directed=True, vis_opts="small")
- The main visualization class
SQV
is imported. SQV
is initialised by passing the following optional arguments to the constructor:iri
: The Internationalized Resource Identifier of the ontologypath
: The path to the ontology fileabox
: The option to turn on or off the visualization of the ABoxes in the ontology
- The
plot
method ofSQV
is called with the following optional arguments_host
: The host of theDash
-appport
: The port of theDash
-appdirected
: The option to visualize the edges with arrowheadsvis_opts
: The option to pass additional visualization options to thevisdcc
-graph
Note, that all the arguments are optional. The default values for these arguments are the same as passed to the functions in the example above. Except for the argument vis_opts
in the plot
method: The default value here is vis_opts = None
. Passing the keyword "small"
adjusts the visualization options for small ontologies.
After running the plot, the console will prompt the default localhost address (127.0.0.1:8050
) where SPARQL-Query-Viz is running. Access it to see the following dashboard:
Currently, the dashboard consist of following components:
-
GUI panel: here the ontology data can be explored, it further contain following sections:
- Search: can be used to find a node in graph
- Selected Edge: shows the meaning of an edge that is selected
- A-Box Data-Properties: shows the instantiated data properties of an instance that is selected (This section is invisble when no ABoxes are visualized)
- Select Scenario: selection of a xPPU scenario and terminology. A corresponding query gets generated dynamically
- SPARQL Templates: provides templates for common SPARQL queries
- SPARQL Library: provides inconsistency checking queries for the use-case ontology
- SPARQL Query: provides options to interactively compose SPARQL queries and shows the currently formulated query
- SPARQL Result: shows the result of evaluated queries and provides a slider to adjust the context of the result visualization
- SPARQL History: shows an adjustable number of successfully evaluated queries
- Color: provides options to color node and edges (is activated per default) and optionally shows the color legend
- Size: provides options to size node and edges (is activated per default)
-
Graph: the ontology visualization or the query result visualization (if query was evaluated)
By default, the ABoxes of an ontology are displayed in the graph. To disable the ABox visualization, abox = False
has to be passed to the SQV
constructor:
# turn of abox visu
from sparql_query_viz import SQV
jl = SQV(iri = "http://example.org/onto-ex.owl", path = "sparql_query_viz/datasets/ontologies/pizza", abox = False)
By default, SQV
plots directed edges for the ontology visualization. This setting can be changed by,
from sparql_query_viz import SQV
SQV().plot(directed = False)
The visualization options of the vis.js
related visualization settings, can be tweaked to your needs.
The default is vis_opts = None
. Thereby SPARQL-Query-Viz takes the predefined settings for visualising large ontologies.
For small ontologies it is useful to use the predefined visualization options for small ontologies, by passing vis_opts = "small"
:
from sparql_query_viz import SQV
SQV().plot(vis_opts="small")
To adjust the visualization settings further, additional options can be passed like shown in the example below:
from sparql_query_viz import SQV
SQV().plot(vis_opts={'height': '600px', # change height
'interaction':{'hover': False}, # turn off the hover
'physics':{'stabilization':{'iterations': 100}}}) # define the convergence iteration of network
For a complete list of settings, visit vis.js website.
If you are facing port related issues, try the following way to run SPARQL-Query-Viz:
from sparql_query_viz import SQV
port=8050
while True:
try:
SQV().plot(port=port)
except:
port+=1
SPARQL Query Viz requires the following python packages,
- Dash
- dash_core_components
- dash_html_components
- dash_bootstrap_components
- dash_daq
- visdcc
- ontor
- pandas
SPARQL-Query-Viz is licensed under the terms of the MIT License (see the file LICENSE).