Practical Ontology Pattern Instantiation, Discovery, and Maintanence with Reasonable Ontology Templates
top
examples:
/
Table of Contents
Practical Ontology Pattern Instantiation, Discovery, and Maintanence with Reasonable Ontology Templates

Online companion demonstration to ISWC 2018 paper.
1 Introduction
The demo will show how templates and instances are specifies - using different formats, the result of their expansion, and how templates may be analysed for different imperfections.
The source of this demo is available at the open git repository https://gitlab.com/ottr/pub/iswc2018-demo. It contains:
- the OTTR templates and OTTR template instances found on this page
- a script that
- downloads the Java jar executables necessary to run the demo locally
- executes all the executable examples found on this page
- this page
- the org-mode source file for all the above
1.1 OTTR Serialisations
In this demonstration we will show OTTR templates and instances using different serialisations:
- stOTTR
- wOTTR
- tabOTTR
1.1.1 stOTTR
stOTTR is a compact way of representing templates and instances that is also easy to read and write. A BNF specification of the language is available at https://gitlab.com/ottr/language/stOTTR/blob/master/stOTTR-BNF.md
1.1.2 wOTTR
To enable truly practical use of OTTR for OWL ontology engineering, we have developed a special-purpose RDF/OWL vocabulary, called wOTTR, with which OTTR templates can be formulated. This has the benefit that we can leverage the existing stack of W3C languages and tools for developing, publishing, and maintaining templates. The wOTTR format supports writing Triple Template instances as regular RDF triples. This means that a pattern represented by an RDF graph or RDF/OWL ontology can easily be turned into an OTTR template by simply specifying the name of the template and its parameters with the wOTTR vocabulary. Furthermore, this means that we can make use of existing ontology editors and reasoners to construct and verify the soundness of templates. The wOTTR representation has been developed to closely resemble stOTTR. It uses RDF resources to represent parameters and arguments, and RDF lists (which have a convenient formatting in Turtle syntax) for lists of parameters and arguments. The vocabulary is published at http://ns.ottr.xyz/.
1.1.3 tabOTTR
tabOTTR is developed particularly for representing large sets template instances in tabular formats such as spreadsheets, and is intended for domain expert use. A specification of tabOTTR is available at https://gitlab.com/ottr/language/tabOTTR/builds/artifacts/develop/file/tabOTTR.html?job=build-job
1.2 OTTR library and online web application
The "official" OTTR template repository at http://library.ottr.xyz/ contains OTTR templates for expressing common RDF, RDFS and OWL patterns, including other example templates.
These templates are conveniently presented in an online library that is linked to the online web application
The web application displays the template, including visualisations of the pattern, links to dependant templates, and different formats which are generated from the template (some are experimental):
- different expansions
- SPARQL queries (SELECT, CONSTRUCT, UPDATE)
- XSD+SAWSDL format
- XML sample
1.3 Prefixes
In all the example code blocks the following prefixes are used.
### standard @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . ### ottr prefixes: @prefix ottr: <http://ns.ottr.xyz/templates#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix t-owl-rstr: <http://candidate.ottr.xyz/owl/restriction/> . ### examples: @prefix x1: <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . @prefix x2: <http://candidate.ottr.xyz/rdfs/ResourceDescription#> . @prefix ex: <http://example.org#> .
2 Templates and Instances
An OTTR template consists of a head and a body. The body represents a parameterised ontology pattern, and the head specifies the template's name and its parameters.
A template instance consists of a template name and a list of arguments that matches the parameters of the designated template, and represents a replica of the template's body pattern where parameters are replaced by the instance's arguments.
The template body comprises only template instances, i.e., the template pattern is recursively built up from other templates, under the constraint that cyclic template dependencies are not allowed.
There is one special base template, the Triple template, which takes three arguments. This template has no body but represents a single RDF triple in the obvious way.
Expanding an instance is the process of recursively replacing instances with the pattern they represent. This process terminates with an expression containing only Triple template instances, hence representing an RDF graph.
Simple template
The SubClassOf template is a simple representation of the
rdfs:subClassOf
relationship. It has two parameters x1:SubClass
and x1:SuperClass
, the resources representing the parameter
variables may be given as a list. The code snippet below contains only
the head of the template.
t-owl-axiom:SubClassOf a ottr:Template ; ottr:withVariables ( x1:SubClass x1:SuperClass ) .
The body of a template may in the RDF serialisation given as either template instances or as regular RDF triples. Below, on the left, the template is given with a body containing a single instance of a Triple template. On the right, the equivalent representation using regular RDF triples is used.
t-owl-axiom:SubClassOf a ottr:Template ; ottr:withVariables ( x1:SubClass x1:SuperClass ) . [] ottr:templateRef <http://candidate.ottr.xyz/rdf/Triple> ; ottr:withValues ( x1:SubClass rdfs:subClassOf x1:SuperClass ) .
t-owl-axiom:SubClassOf a ottr:Template ; ottr:withVariables ( x1:SubClass x1:SuperClass ) . x1:SubClass rdfs:subClassOf x1:Superclass .
Simple template instances
Instances of templates are given just as in templates bodies.
[] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:withValues ( ex:Pizza ex:Food ) . [] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:withValues ( ex:Burger ex:Food ) . [] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:withValues ( ex:FishSoup ex:Food ) .
3 Lutra
Lutra is our Java implementation of the OTTR template macro expander is available as open source with an LGPL licence at http://gitlab.com/ottr/lutra/lutra. It can read and write templates and instances on the formats represented above and expand them into RDF graphs and OWL ontologies.
The Lutra CLI
This is the command line interface of Lutra.
java -jar lutra.jar
Unexpected exception: Missing required option: [-version Enable version mode., -expand Enable expand mode., -stottr Enable stottr mode., -tabottr Enable tabottr mode.] usage: lutra -version|expand|stottr|tabottr [-in <file|IRI>] [-out <file>] [-lib <path> [-libExt <ext,..>]] [(flags)] -expand Enable expand mode. -in <arg> Path to optional input file or IRI. Defaults to stdin. -lib <arg> Path to optional local template library root, read recursively. -libExt <arg> Comma-separated list of template file extensions to be read from 'lib' (default: owl,rdf,ttl). -noCache Disable caching. -noCheck Disable various validation services, gives faster processing. -noOWLOutput Disable OWL API rendering of output. -out <arg> Path to optional output file. Defaults to stout. -quiet Disable logging. -stottr Enable stottr mode. -tabottr Enable tabottr mode. -version Enable version mode.
Converting to stOTTR serialisation
Lutra can convert templates and template instances serialised as RDF into the stOTTR serialisation.
java -jar lutra.jar -stottr -in tpl/intro/SubClassOf1
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix t-rdf: <http://candidate.ottr.xyz/rdf/> . @prefix x1: <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . t-owl-axiom:SubClassOf( t-owl-axiom:SubClassOf#SubClass : 1 , t-owl-axiom:SubClassOf#SuperClass : 1 ) :: t-rdf:Triple( t-owl-axiom:SubClassOf#SubClass , rdfs:subClassOf , t-owl-axiom:SubClassOf#SuperClass ) .
Expanding simple template instances
Lutra can expand template instances.
java -jar lutra.jar -expand -in inst/intro/SubClassOf1Instances
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:Burger rdfs:subClassOf ex:Food . ex:Pizza rdfs:subClassOf ex:Food . ex:FishSoup rdfs:subClassOf ex:Food .
Expanding Template definition
Note also that templates can be expanded, i.e., expanding the instances in the body, hence resulting in a prototype of the pattern the template represents.
java -jar lutra.jar -expand -in tpl/intro/SubClassOf1
@prefix x1: <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix ottr: <http://ns.ottr.xyz/templates#> . x1:SubClass rdfs:subClassOf x1:SuperClass . t-owl-axiom:SubClassOf a ottr:Template ; ottr:withVariables (x1:SubClass x1:SuperClass) .
4 Parameter Types and Type checking
The type of the parameter specifies the permissible type of its
arguments. The available types are limited to a specified set of
classes and datatypes defined in the XSD, RDF, RDFS, and OWL
specifications, e.g,. xsd:integer
, rdf:Property
, rdfs:Resource
and owl:ObjectProperty
.
The OWL ontology available at http://ns.ottr.xyz/templates-term-types.owl
declares all permissible types and organises them in a hierarchy of
subtypes and incompatible types, e.g.,
owl:ObjectProperty
is a subtype of rdf:Property
and xsd:integer
and rdf:Property
are incompatible. The most general and default
type is rdfs:Resource
.
This information is used to type check template instantiations; a parameter may not be instantiated by an argument with an incompatible type.
Declaring parameter types
Parameter types are specified by using dedicated properties. In order to do so, the parameters of the templates must be explicitly represented (here as blank nodes), and are uniquely order with an index.
t-owl-axiom:SubClassOfTest1 a ottr:Template ; ottr:hasParameter [ ottr:index 1 ; ottr:classVariable x1:SubClass ] , [ ottr:index 2 ; ottr:classVariable x1:SuperClass ] . [] ottr:templateRef <http://candidate.ottr.xyz/rdf/Triple> ; ottr:withValues ( x1:SubClass rdfs:subClassOf x1:SuperClass ) .
This is the stOTTR representation of the template:
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix t-rdf: <http://candidate.ottr.xyz/rdf/> . @prefix x1: <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . t-owl-axiom:SubClassOfTest1( t-owl-axiom:SubClassOf#SubClass : 1 class , t-owl-axiom:SubClassOf#SuperClass : 1 class ) :: t-rdf:Triple( t-owl-axiom:SubClassOf#SubClass , rdfs:subClassOf , t-owl-axiom:SubClassOf#SuperClass ) .
Instances for templates with explicitly typed parameters are given as usual:
[] ottr:templateRef t-owl-axiom:SubClassOfTest1 ; ottr:withValues ( ex:Pizza ex:Food ) .
Expanding the instance. To load the local template defined above, we
use the -lib
option with the folder of the templates to be loaded as
argument. All templates, including subfolders (recursively), are
loaded.
A warning is given when loading the local template since its IRI is different than it location.
java -jar lutra.jar -expand -lib tpl/types -in inst/types/SubClassOf3Instances -out inst/types/SubClassOf3Instances.out
0 [main] WARN xyz.lutra.parser.TemplateLoader - Template filename: 'tpl/types/SubClassOf3.ttl' is different from template name: 'http://candidate.ottr.xyz/owl/axiom/SubClassOfTest1"
This is the result of the expansion:
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:Pizza rdfs:subClassOf ex:Food .
An instance of the template with arguments that are incompatible with the type of the parameters will generate an error. In the following template instance the first argument is a literal, which cannot represent an OWL class.
[] ottr:templateRef t-owl-axiom:SubClassOfTest1 ; ottr:withValues ( "PizzaLiteral" ex:Food ) .
Expanding this instance gives the following exception:
Type error, expecting non literal for class variable, but found literal: PizzaLiteral
java -jar lutra.jar -expand -lib tpl/types -in inst/types/SubClassOf3Instances2
0 [main] WARN xyz.lutra.parser.TemplateLoader - Template filename: 'tpl/types/SubClassOf3.ttl' is different from template name: 'http://candidate.ottr.xyz/owl/axiom/SubClassOfTest1" 4369 [main] ERROR xyz.lutra.parser.ParserUtils - Type error, expecting non literal for class variable, but found literal: PizzaLiteral Exception in thread "main" xyz.lutra.model.IllegalSubstitutionException: The substitution induced by template instance 5189294c:163da53fa2d:-7ff9 of template http://candidate.ottr.xyz/owl/axiom/SubClassOfTest1 is illegal. Error building substitution with parameters [1: 5189294c:163da53fa2d:-7fff, 2: 5189294c:163da53fa2d:-7ffe] and arguments ["PizzaLiteral"^^xsd:string, ex:Food]. Error for parameter 1: 5189294c:163da53fa2d:-7fff and argument "PizzaLiteral"^^xsd:string. Type error, expecting non literal for class variable, but found literal: PizzaLiteral at xyz.lutra.model.TemplateInstance.buildSubstitutions(TemplateInstance.java:57) at xyz.lutra.model.TemplateInstance.<init>(TemplateInstance.java:32) at xyz.lutra.parser.TemplateInstanceParser.parseTemplateInstance(TemplateInstanceParser.java:123) at xyz.lutra.parser.TemplateInstanceParser.parseTemplateInstances(TemplateInstanceParser.java:59) at xyz.lutra.parser.TemplateInstanceParser.parse(TemplateInstanceParser.java:46) at xyz.lutra.parser.TemplateInstanceParser.getTemplateInstances(TemplateInstanceParser.java:41) at xyz.lutra.Expander.expand(Expander.java:96) at xyz.lutra.Expander.expand(Expander.java:61) at xyz.lutra.Expander.expand(Expander.java:50) at xyz.lutra.cli.CLI.main(CLI.java:112)
5 Cardinalities
The cardinality of a parameter specifies the number of required arguments to the parameter. There are four cardinalities:
- mandatory
- optional
- multiple
- optional multiple, which is shorthand for mandatory and optional combined.
Mandatory is the default cardinality. Mandatory parameters require an argument, otherwise the instance is illegal.
Optional parameters permit a missing value; ottr:none
designates
this value. If ottr:none
is an argument to a mandatory parameter of
an instance, the instance is ignored and will not be included in the
expansion.
A parameter with cardinality multiple requires a list as argument.
Parameters with cardinality optional multiple also accept ottr:none as a value and behave like optional arguments.
Optional parameters
The following template is handy for expressing RDFS annotations on resources. All parameters, except the mandatory resource
parameter are optional.
<http://candidate.ottr.xyz/rdfs/ResourceDescription> a ottr:Template ; ottr:hasParameter [ ottr:index 1; ottr:nonLiteralVariable x2:resource ] , [ ottr:index 2; ottr:literalVariable "label"; ottr:optional true ] , [ ottr:index 3; ottr:literalVariable "comment"; ottr:optional true ] , [ ottr:index 4; ottr:variable x2:seeOther; ottr:optional true ] , [ ottr:index 5; ottr:variable x2:defOther; ottr:optional true ] . x2:resource rdfs:label "label" ; rdfs:comment "comment" ; rdfs:seeAlso x2:seeOther ; rdfs:isDefinedBy x2:defOther .
Example instances:
[] ottr:templateRef <http://candidate.ottr.xyz/rdfs/ResourceDescription> ; ottr:withValues ( ex:thing1 "label1" "comment1" ottr:none ottr:none ) . [] ottr:templateRef <http://candidate.ottr.xyz/rdfs/ResourceDescription> ; ottr:withValues ( ex:thing2 "label2" ottr:none ex:seeOther2 ex:defOther2 ) . [] ottr:templateRef <http://candidate.ottr.xyz/rdfs/ResourceDescription> ; ottr:withValues ( ex:thing3 ottr:none ottr:none ottr:none ottr:none ) .
This is the result of expanding these instances. ex:thing3
does not
occur in the output since all triples are removed.
java -jar lutra.jar -expand -in inst/card/ResourceDescriptionInstances
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:thing2 rdfs:isDefinedBy ex:defOther2 ; rdfs:label "label2" ; rdfs:seeAlso ex:seeOther2 . ex:thing1 rdfs:comment "comment1" ; rdfs:label "label1" .
Parameters with cardinality multiple
The multiple cardinality is useful for expression that naturally
should accept multiple values. The EquivObjectUnionOf
template expresses that a class
is equivalent to a union of classes as according to the OWL specification.
The template directly depends on, i.e,. its body contains instances of, other templates which are available at their IRI address. Lutra fetches these template definitions on expansion.
t-owl-axiom:EquivObjectUnionOf a ottr:Template ; ottr:hasParameter :pRestriction, :pList . :pRestriction ottr:index 1; ottr:classVariable :xRestriction . :pList ottr:index 2; ottr:listVariable ( :item1 :item2 ) . [] ottr:templateRef t-owl-axiom:EquivalentClass ; ottr:withValues ( :xRestriction _:restriction ) . [] ottr:templateRef t-owl-rstr:ObjectUnionOf ; ottr:withValues ( _:restriction ( :item1 :item2 ) ) .
An example instance:
[] ottr:templateRef t-owl-axiom:EquivObjectUnionOf ; ottr:withValues ( ex:MyFood ( ex:Pizza ex:Burger ex:FishSoup) ) .
This expands to:
java -jar lutra.jar -expand -in inst/card/EquivObjectUnionOfInstances
@prefix ex: <http://example.org#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . ex:MyFood a owl:Class ; owl:equivalentClass [ a owl:Class ; owl:unionOf (ex:Pizza ex:Burger ex:FishSoup) ] .
6 Expansion Modes
Instances of templates that accept list arguments may be used together with an expansion mode. The mode indicates that the list arguments will in the expansion be used to generate multiple instances of the template.
The instances to be generated are calculated by temporarily considering all arguments to the instance as lists, where single value arguments become singular lists. Currently only one mode, cross mode, is implemented, but others are possible. In cross mode, one instance per element in the cross product of the temporary lists is generated
List arguments used without an expansion mode behave just like regular arguments.
Expansion mode
To illustrate the effect of using expansion mode, we introduce three
different variants of the SubClassOf
template and show the results
of an example instance.
SubClassOfTest1
accepts a list of superclasses:
t-owl-axiom:SubClassOfTest1 a ottr:Template ; ottr:hasParameter [ ottr:index 1 ; ottr:classVariable x1:SubClass ] , [ ottr:index 2 ; ottr:listVariable ( x1:SuperClasses ) ] . [] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:hasArgument [ ottr:index 1; ottr:value x1:SubClass ] , [ ottr:index 2; ottr:eachValue ( x1:SuperClasses ) ] .
Example instance:
[] ottr:templateRef t-owl-axiom:SubClassOfTest1 ; ottr:withValues ( ex:MyFood ( ex:Pizza ex:Burger ex:FishSoup) ) .
Expansion:
java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf1Instances
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:MyFood rdfs:subClassOf ex:Burger , ex:Pizza , ex:FishSoup .
SubClassOfTest2
accepts a list of subclasses:
t-owl-axiom:SubClassOfTest2 a ottr:Template ; ottr:hasParameter [ ottr:index 1 ; ottr:listVariable ( x1:SubClasses ) ] , [ ottr:index 2 ; ottr:classVariable x1:SuperClass ] . [] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:hasArgument [ ottr:index 1; ottr:eachValue ( x1:SubClasses ) ] , [ ottr:index 2; ottr:value x1:SuperClass ] .
Example instance:
[] ottr:templateRef t-owl-axiom:SubClassOfTest2 ; ottr:withValues ( ( ex:Tropical ex:Pepperoni ex:Grandiosa ) ex:Pizza ) .
Expansion:
java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf2Instances
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:Grandiosa rdfs:subClassOf ex:Pizza . ex:Pepperoni rdfs:subClassOf ex:Pizza . ex:Tropical rdfs:subClassOf ex:Pizza .
SubClassOfTest3
accepts a list of subclasses and a a list of superclasses
t-owl-axiom:SubClassOfTest3 a ottr:Template ; ottr:hasParameter [ ottr:index 1 ; ottr:listVariable ( x1:SubClasses ) ] , [ ottr:index 2 ; ottr:listVariable ( x1:SuperClasses ) ] . [] ottr:templateRef t-owl-axiom:SubClassOf ; ottr:hasArgument [ ottr:index 1; ottr:eachValue ( x1:SubClasses ) ] , [ ottr:index 2; ottr:eachValue ( x1:SuperClasses ) ] .
Example instance:
[] ottr:templateRef t-owl-axiom:SubClassOfTest3 ; ottr:withValues ( ( ex:A1 ex:A2 ex:A3) ( ex:B1 ex:B2 ex:B3 ) ) .
Expansion:
java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf3Instances
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix ex: <http://example.org#> . ex:A3 rdfs:subClassOf ex:B3 , ex:B2 , ex:B1 . ex:A2 rdfs:subClassOf ex:B3 , ex:B2 , ex:B1 . ex:A1 rdfs:subClassOf ex:B3 , ex:B2 , ex:B1 .
7 Combining features: NamedPizza
This section illustrates the example used in the demo paper, the
NamedPizza
template
It is available at its IRI: http://draft.ottr.xyz/pizza/NamedPizza. This page displays the template in different serialisations, lists its dependencies, visualises its prototypical pattern, and provides links to other available formats that can be generated from an OTTR template.
NamedPizza
This is the wOTTR serialisation of the NamedPizza
template.
<http://draft.ottr.xyz/pizza/NamedPizza> a ottr:Template ; ottr:hasParameter [ ottr:index 1 ; ottr:classVariable :pizza ] , [ ottr:index 2 ; ottr:individualVariable :country; ottr:optional true ] , [ ottr:index 3 ; ottr:listVariable (:toppings) ] . [] ottr:templateRef <http://candidate.ottr.xyz/owl/axiom/SubClassOf> ; ottr:withValues ( :pizza p:NamedPizza ) . [] ottr:templateRef <http://candidate.ottr.xyz/owl/axiom/SubObjectSomeValuesFrom> ; ottr:hasArgument [ ottr:index 1; ottr:value :pizza ] , [ ottr:index 2; ottr:value p:hasTopping ] , [ ottr:index 3; ottr:eachValue (:toppings) ] . [] ottr:templateRef <http://candidate.ottr.xyz/owl/axiom/SubObjectHasValue> ; ottr:withValues ( :pizza p:hasCountryOfOrigin :country ) . [] ottr:templateRef <http://candidate.ottr.xyz/owl/axiom/SubObjectAllValuesFrom> ; ottr:withValues ( :pizza p:hasTopping _:alltoppings ) . [] ottr:templateRef <http://candidate.ottr.xyz/owl/restriction/ObjectUnionOf> ; ottr:withValues ( _:alltoppings (:toppings) ) .
Its stOTTR serialisation; note that we are reading the template definition from its IRI, where the template is published.
java -jar lutra.jar -stottr -in http://draft.ottr.xyz/pizza/NamedPizza
@prefix : <http://draft.ottr.xyz/pizza/NamedPizza#> . @prefix p: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix t-owl-rstr: <http://candidate.ottr.xyz/owl/restriction/> . http://draft.ottr.xyz/pizza/NamedPizza( :pizza : 1 class , :country : ? individual , <:toppings> : + list ) :: t-owl-axiom:SubClassOf( :pizza , p:NamedPizza ) t-owl-axiom:SubObjectAllValuesFrom( :pizza , p:hasTopping , _:b1 ) t-owl-axiom:SubObjectHasValue( :pizza , p:hasCountryOfOrigin , :country ) X | t-owl-axiom:SubObjectSomeValuesFrom( :pizza , p:hasTopping , <:toppings> ) t-owl-rstr:ObjectUnionOf( _:b1 , <:toppings> ) .
Example instance containing three pizzas. Note that the file specifies that it is an OWL ontology.
[] a owl:Ontology . [] ottr:templateRef <http://draft.ottr.xyz/pizza/NamedPizza> ; ottr:withValues ( ex:Grandiosa ottr:none ( ex:Tomato ex:Jarlsberg ex:Ham ex:SweetPepper ) ) . [] ottr:templateRef <http://draft.ottr.xyz/pizza/NamedPizza> ; ottr:withValues ( ex:Margherita ex:Italy ( ex:Tomato ex:Mozzarella ) ) . [] ottr:templateRef <http://draft.ottr.xyz/pizza/NamedPizza> ; ottr:withValues ( ex:Tropical ex:Hawaii ( ex:Tomato ex:Cheese ex:Pineapple ex:Ham ) ) .
The result of the expansion. The occurrence of the [] a
owl:Ontology
triple in the input, causes Lutra to render the output
using the OWLAPI; this can be disabled with the -noOWLOutput
flag.
java -jar lutra.jar -expand -in tpl/pizza/NamedPizzaInstances
@prefix p: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> . @prefix ex: <http://example.org#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix xml: <http://www.w3.org/XML/1998/namespace> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @base <http://www.w3.org/2002/07/owl#> . [ rdf:type owl:Ontology ] . ################################################################# # Object Properties ################################################################# ### http://www.co-ode.org/ontologies/pizza/pizza.owl#hasCountryOfOrigin p:hasCountryOfOrigin rdf:type owl:ObjectProperty . ### http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping p:hasTopping rdf:type owl:ObjectProperty . ################################################################# # Classes ################################################################# ### http://example.org#Cheese ex:Cheese rdf:type owl:Class . ### http://example.org#Grandiosa ex:Grandiosa rdf:type owl:Class ; rdfs:subClassOf p:NamedPizza , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Ham ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Jarlsberg ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:SweetPepper ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Tomato ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:allValuesFrom [ rdf:type owl:Class ; owl:unionOf ( ex:Ham ex:Jarlsberg ex:SweetPepper ex:Tomato ) ] ] . ### http://example.org#Ham ex:Ham rdf:type owl:Class . ### http://example.org#Jarlsberg ex:Jarlsberg rdf:type owl:Class . ### http://example.org#Margherita ex:Margherita rdf:type owl:Class ; rdfs:subClassOf p:NamedPizza , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Mozzarella ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Tomato ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:allValuesFrom [ rdf:type owl:Class ; owl:unionOf ( ex:Mozzarella ex:Tomato ) ] ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasCountryOfOrigin ; owl:hasValue ex:Italy ] . ### http://example.org#Mozzarella ex:Mozzarella rdf:type owl:Class . ### http://example.org#Pineapple ex:Pineapple rdf:type owl:Class . ### http://example.org#SweetPepper ex:SweetPepper rdf:type owl:Class . ### http://example.org#Tomato ex:Tomato rdf:type owl:Class . ### http://example.org#Tropical ex:Tropical rdf:type owl:Class ; rdfs:subClassOf p:NamedPizza , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Cheese ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Ham ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Pineapple ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom ex:Tomato ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasTopping ; owl:allValuesFrom [ rdf:type owl:Class ; owl:unionOf ( ex:Cheese ex:Ham ex:Pineapple ex:Tomato ) ] ] , [ rdf:type owl:Restriction ; owl:onProperty p:hasCountryOfOrigin ; owl:hasValue ex:Hawaii ] . ### http://www.co-ode.org/ontologies/pizza/pizza.owl#NamedPizza p:NamedPizza rdf:type owl:Class . ################################################################# # Individuals ################################################################# ### http://example.org#Hawaii ex:Hawaii rdf:type owl:NamedIndividual . ### http://example.org#Italy ex:Italy rdf:type owl:NamedIndividual . ### Generated by the OWL API (version 0.1.6) https://github.com/owlcs/owlapi/
7.1 tabOTTR
The tabOTTR format is useful for compactly giving multiple instances of templates, and makes OTTR available to users who prefer working with tabular formats such as spreadsheets.
NamedPizza tabular input
The code block below is copy of one of the sheets in the Excel
spreadsheet at tab/NamedPizza-instances.xlsx
(available in the git
repo: https://gitlab.com/ottr/pub/iswc2018-demo).
#OTTR prefix owl http://www.w3.org/2002/07/owl# rdf http://www.w3.org/1999/02/22-rdf-syntax-ns# xsd http://www.w3.org/2001/XMLSchema# rdfs http://www.w3.org/2000/01/rdf-schema# ottr http://ns.ottr.xyz/templates# http://example.com# #OTTR end #OTTR template http://draft.ottr.xyz/pizza/NamedPizza Pizza Country Toppings 1 2 3 iri iri iri+ :Margherita :Italy :Tomato|:Mozzarella :Grandiosa :Norway :Tomato|:Jarlsberg|:Ham|:SweetPepper :Hawaii :Tomato|:Cheese|:Ham|:PineApple :BigOne :Tomato|:Cheese|:Ham #OTTR end
Lutra can expand the instances represented in tabOTTR format in the Excel file:
java -jar lutra.jar -tabottr -in tab/NamedPizza-instances.xlsx
@prefix : <http://example.com#> . @prefix p: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . :Cheese a owl:Class . :Pear a owl:Class . :PineApple a owl:Class . :Margherita rdfs:subClassOf p:NamedPizza ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Tomato ] ; rdfs:subClassOf [ a owl:Restriction ; owl:allValuesFrom [ a owl:Class ; owl:unionOf (:Tomato :Mozzarella) ] ; owl:onProperty p:hasTopping ] ; rdfs:subClassOf [ a owl:Restriction ; owl:hasValue :Italy ; owl:onProperty p:hasCountryOfOrigin ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Mozzarella ] . p:hasTopping a owl:ObjectProperty . :Hawaii rdfs:subClassOf p:NamedPizza ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Tomato ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Cheese ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :PineApple ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Ham ] ; rdfs:subClassOf [ a owl:Restriction ; owl:allValuesFrom [ a owl:Class ; owl:unionOf (:Tomato :Cheese :Ham :PineApple) ] ; owl:onProperty p:hasTopping ] . :Grandiosa rdfs:subClassOf p:NamedPizza ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Tomato ] ; rdfs:subClassOf [ a owl:Restriction ; owl:allValuesFrom [ a owl:Class ; owl:unionOf (:Tomato :Jarlsberg :Ham :SweetPepper) ] ; owl:onProperty p:hasTopping ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Ham ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Jarlsberg ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :SweetPepper ] ; rdfs:subClassOf [ a owl:Restriction ; owl:hasValue :Norway ; owl:onProperty p:hasCountryOfOrigin ] . :Apple a owl:Class . :Jarlsberg a owl:Class . :TuttiFrutti rdfs:subClassOf p:NamedPizza ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Tomato ] ; rdfs:subClassOf [ a owl:Restriction ; owl:allValuesFrom [ a owl:Class ; owl:unionOf (:Tomato :Apple :Pear) ] ; owl:onProperty p:hasTopping ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Apple ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Pear ] . :BigOne rdfs:subClassOf p:NamedPizza ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Cheese ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Ham ] ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty p:hasTopping ; owl:someValuesFrom :Tomato ] ; rdfs:subClassOf [ a owl:Restriction ; owl:allValuesFrom [ a owl:Class ; owl:unionOf (:Tomato :Cheese :Ham) ] ; owl:onProperty p:hasTopping ] . p:hasCountryOfOrigin a owl:ObjectProperty . :Tomato a owl:Class . :SweetPepper a owl:Class . :Ham a owl:Class . :Mozzarella a owl:Class .
7.2 Generated formats from OTTR templates
Other formats from templates
This example illustrates some of the formats that may be generated
from the NamedPizza
template.
SPARQL SELECT query of pattern
SELECT * WHERE { _:b0 owl:allValuesFrom _:b3 ; owl:onProperty p:hasTopping ; rdf:type owl:Restriction . _:b1 owl:hasValue ?param2 ; owl:onProperty p:hasCountryOfOrigin ; rdf:type owl:Restriction . _:b2 owl:onProperty p:hasTopping ; owl:someValuesFrom ?param3item ; rdf:type owl:Restriction . _:b3 owl:unionOf ?param3 ; rdf:type owl:Class . ?param1 rdfs:subClassOf _:b0 ; rdfs:subClassOf _:b1 ; rdfs:subClassOf _:b2 ; rdfs:subClassOf p:NamedPizza . ?param3item rdf:type owl:Class . p:hasCountryOfOrigin rdf:type owl:ObjectProperty . p:hasTopping rdf:type owl:ObjectProperty . ?param3 (rdf:rest)*/rdf:first ?param3item }
Also available at http://osl.ottr.xyz/lifting/select/?tpl=http://draft.ottr.xyz/pizza/NamedPizza
XSD+SAWSDL description of template head:
Available at http://osl.ottr.xyz/format/head/xml/?tpl=http://draft.ottr.xyz/pizza/NamedPizza
XML sample of template head:
Available at http://osl.ottr.xyz/sample/head/xml/?tpl=http://draft.ottr.xyz/pizza/NamedPizza
8 Finding Redundancies
We here present redundancies in template libraries
and our method of finding and fixing them.
We here work with two types of redundancy: a lack of reuse of existing
templates and recurring patterns not captured by templates
within the library. If the body of a template T
is a subset
of another template R
's body, assuming an appropriate substitution of the
variables of T
, then R
has a lack of reuse of T
.
On the other hand, a pattern of template instances might occur
across multiple templates without there being any template having this
pattern as a body. This type of redundancy is called an uncaptured pattern.
A lack of reuse can be fixed by simply substituting the offending instances
in R
by an appropriate instance of T
. To fix a redundancy
resulting from an uncaptured pattern, we first have to introduce a new template
that has the recurring pattern as its body and then refactor out the redundancy.
A naive method for finding the two types of redundancy based on direct unification
of subsets of the template's bodies is infeasible for large template libraries.
We have therefore developed an efficient method for finding lack of reuse and uncaptured patterns,
which over-approximates the results of unification
based on the notion of a dependency pair, which intuitively captures repeated
use of templates without considering parameters.
A dependency pair is a pair of a multiset of templates I
and a set of templates T
,
such that all templates in T
have at least as many occurences of each
template in I
as they occur in I
in its body.
The idea is that I
then describes a pattern that is used in the templates T
.
In order to also detect patterns containing different Triple
instances, we
treat a Triple
instance (s, p, o)
as an instance of the form p(s,o)
and thus p
as a template.
For each template t
in T
in each dependency pair (I, T)
we can construct a suggestion of a new template s
by extracting the instances in t
's body corresponding to the instances in I
,
making all parameters
and constants (except blank nodes only occuring in the pattern) in this set of instances a parameter.
For each such template s
we have one of three cases:
(1) the body of this template does not represent a repeated pattern in the other templates of T
;
(2) s
is equal to an already existing template, in which case we have found
an instance of lack of reuse in all the other template of T
which
shares the pattern;
(3) we have found an uncaptured pattern represented which is remedied by the introduction of s
.
The following examples demonstrates the method for finding
redundancies in a template library. The template library used in the
example is found in the folder redundancy-templates/
.
The analysis program is not available as open source and is therefore packaged in a separate jar file.
Analysis of example patterns
In the following example, only the patterns from the above mentioned paper is presented.
The program first outputs the template definitions loaded into the library. Then it prints each dependency pair found from the loaded templates; here is an example:
Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza
This dependency pair shows that both the templates pz:NamedPizza
and ex:Burger
contain
one instance (denoted by the trailing integer :1
) of each of the
templates t-owl-axiom:SubClassOf
, t-owl-axiom:SubObjectSomeValuesFrom
,
t-owl-axiom:SubObjectAllValuesFrom
and t-owl-rstr:ObjectUnionOf
.
The dependency pair is followed by the template suggestions constructed from that dependency pair. Here it removes duplicate suggestions via unification of templates. The suggested template from this dependency pair is:
[name68_0](:subject, :hasCondiment, <:condiments>, ex:Burger) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) t-owl-rstr:ObjectUnionOf(25134aae:163da50f911:-7f93, <:condiments>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, 25134aae:163da50f911:-7f93)
Finally, if there are any lack of reuse captured by this dependency pair, these are reported:
http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/NamedPizza
Below is the complete output from analysing the templates:
java -jar findPatterns.jar -p redundancy-templates/
====================================== ==========~Templates~================= ====================================== @prefix : <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . @prefix t-rdf: <http://candidate.ottr.xyz/rdf/> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix t-owl-rstr: <http://candidate.ottr.xyz/owl/restriction/> . @prefix t-owl-ax: <http://candidate.ottr.xyz/owl/axiom/> . @prefix p: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> . @prefix ex: <http://example.org/#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix ottr: <http://ns.ottr.xyz/templates#> . @prefix t-owl-atom: <http://candidate.ottr.xyz/owl/atom/> . t-owl-axiom:SubObjectAllValuesFrom(:xClass, :xProperty, :xRange) :: t-owl-rstr:ObjectAllValuesFrom(-17351486:163da54f4a0:-7f7b, :xProperty, :xRange) t-owl-axiom:SubClassOf(:xClass, -17351486:163da54f4a0:-7f7b) t-owl-rstr:ObjectUnionOf(:xRestriction, <:item1,:item2>) :: t-owl-atom:TypedListRelation(:xRestriction, owl:Class, owl:unionOf, <:item1,:item2>) http://example.org/BurgerMeal(:subject, <:sides>) :: t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasSide, -17351486:163da54f4a0:-7fa8) t-owl-rstr:ObjectUnionOf(-17351486:163da54f4a0:-7fa8, <:sides>) t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasMain, ex:Burger) http://example.org/Burger(:subject, <:condiments>, <label>, prefLabel : ?, definition : ?) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-rdf:Triple(:subject, skos:definition, definition) t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-owl-rstr:ObjectUnionOf(-17351486:163da54f4a0:-7f93, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -17351486:163da54f4a0:-7f93) t-owl-axiom:SubObjectSomeValuesFrom(:xClass, :xProperty, :xRange) :: t-owl-rstr:ObjectSomeValuesFrom(-17351486:163da54f4a0:-7fef, :xProperty, :xRange) t-owl-axiom:SubClassOf(:xClass, -17351486:163da54f4a0:-7fef) t-owl-axiom:SubClassOf(:xSubClass, :xSuperClass) :: t-rdf:Triple(:xSubClass, rdf:type, owl:Class) t-rdf:Triple(:xSuperClass, rdf:type, owl:Class) t-rdf:Triple(:xSubClass, rdfs:subClassOf, :xSuperClass) http://draft.ottr.xyz/pizza/NamedPizza(:pizza, <:toppings>) :: t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) t-owl-axiom:SubObjectAllValuesFrom(:pizza, p:hasTopping, -17351486:163da54f4a0:-7fd6) t-owl-rstr:ObjectUnionOf(-17351486:163da54f4a0:-7fd6, <:toppings>) x | t-owl-axiom:SubObjectSomeValuesFrom(:pizza, p:hasTopping, <:toppings>) http://draft.ottr.xyz/pizza/Annotation(:subject, <label>, prefLabel, definition) :: t-rdf:Triple(:subject, skos:definition, definition) t-rdf:Triple(:subject, skos:prefLabel, prefLabel) x | t-rdf:Triple(:subject, rdfs:label, <label>) http://draft.ottr.xyz/pizza/AnnotatedPizza(:subject, <label>, prefLabel : ?, definition : ?) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-rdf:Triple(:subject, skos:definition, definition) t-owl-axiom:SubClassOf(:subject, p:Pizza) x | t-rdf:Triple(:subject, rdfs:label, <label>) Checking for redundancy... Done Following redundancies found: ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name68_0](:subject, :hasCondiment, <:condiments>, ex:Burger) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-rstr:ObjectUnionOf(-17351486:163da54f4a0:-7f93, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -17351486:163da54f4a0:-7f93) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/NamedPizza ====================================== ==========~Dependency Pair~=========== ====================================== Pattern skos:definition:1 rdfs:label:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name63_1](<label>, :subject, prefLabel, definition) :: t-rdf:Triple(:subject, skos:definition, definition) t-rdf:Triple(:subject, skos:prefLabel, prefLabel) x | t-rdf:Triple(:subject, rdfs:label, <label>) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza has a lack of reuse of http://draft.ottr.xyz/pizza/Annotation
Analysis of all patterns
In this example we present all redundancies in the entire library.
java -jar findPatterns.jar -a redundancy-templates/
====================================== ==========~Templates~================= ====================================== @prefix : <http://candidate.ottr.xyz/owl/axiom/SubClassOf#> . @prefix t-rdf: <http://candidate.ottr.xyz/rdf/> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix t-owl-rstr: <http://candidate.ottr.xyz/owl/restriction/> . @prefix t-owl-ax: <http://candidate.ottr.xyz/owl/axiom/> . @prefix p: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> . @prefix ex: <http://example.org/#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix t-owl-axiom: <http://candidate.ottr.xyz/owl/axiom/> . @prefix ottr: <http://ns.ottr.xyz/templates#> . @prefix t-owl-atom: <http://candidate.ottr.xyz/owl/atom/> . t-owl-axiom:SubObjectAllValuesFrom(:xClass, :xProperty, :xRange) :: t-owl-rstr:ObjectAllValuesFrom(-48c2c56f:163da54fa86:-7f7b, :xProperty, :xRange) t-owl-axiom:SubClassOf(:xClass, -48c2c56f:163da54fa86:-7f7b) t-owl-rstr:ObjectUnionOf(:xRestriction, <:item1,:item2>) :: t-owl-atom:TypedListRelation(:xRestriction, owl:Class, owl:unionOf, <:item1,:item2>) http://example.org/BurgerMeal(:subject, <:sides>) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fa8, <:sides>) t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasMain, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasSide, -48c2c56f:163da54fa86:-7fa8) http://example.org/Burger(:subject, <:condiments>, <label>, prefLabel : ?, definition : ?) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-rdf:Triple(:subject, skos:definition, definition) t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7f93, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -48c2c56f:163da54fa86:-7f93) t-owl-axiom:SubObjectSomeValuesFrom(:xClass, :xProperty, :xRange) :: t-owl-axiom:SubClassOf(:xClass, -48c2c56f:163da54fa86:-7fef) t-owl-rstr:ObjectSomeValuesFrom(-48c2c56f:163da54fa86:-7fef, :xProperty, :xRange) t-owl-axiom:SubClassOf(:xSubClass, :xSuperClass) :: t-rdf:Triple(:xSubClass, rdf:type, owl:Class) t-rdf:Triple(:xSuperClass, rdf:type, owl:Class) t-rdf:Triple(:xSubClass, rdfs:subClassOf, :xSuperClass) http://draft.ottr.xyz/pizza/NamedPizza(:pizza, <:toppings>) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fd6, <:toppings>) t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) t-owl-axiom:SubObjectAllValuesFrom(:pizza, p:hasTopping, -48c2c56f:163da54fa86:-7fd6) x | t-owl-axiom:SubObjectSomeValuesFrom(:pizza, p:hasTopping, <:toppings>) http://draft.ottr.xyz/pizza/Annotation(:subject, <label>, prefLabel, definition) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-rdf:Triple(:subject, skos:definition, definition) http://draft.ottr.xyz/pizza/AnnotatedPizza(:subject, <label>, prefLabel : ?, definition : ?) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-rdf:Triple(:subject, skos:definition, definition) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-owl-axiom:SubClassOf(:subject, p:Pizza) Checking for redundancy... Done Following redundancies found: ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza http://example.org/BurgerMeal ===~Suggested templates~=== [name36_0](:subject, :hasCondiment, <:condiments>) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7f93, <:condiments>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -48c2c56f:163da54fa86:-7f93) [name36_2](:subject, <:sides>, :hasSide, :hasMain, ex:Burger) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fa8, <:sides>) t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasMain, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasSide, -48c2c56f:163da54fa86:-7fa8) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://example.org/BurgerMeal http://draft.ottr.xyz/pizza/NamedPizza has a lack of reuse of http://example.org/BurgerMeal ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name68_0](:subject, :hasCondiment, <:condiments>, ex:Burger) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7f93, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -48c2c56f:163da54fa86:-7f93) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/NamedPizza ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name41_0](:subject, :hasCondiment, ex:Burger, <:condiments>, -48c2c56f:163da54fa86:-7f93) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -48c2c56f:163da54fa86:-7f93) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectAllValuesFrom:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name10_1](p:hasTopping, p:NamedPizza, -48c2c56f:163da54fa86:-7fd6, :pizza) :: t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) t-owl-axiom:SubObjectAllValuesFrom(:pizza, p:hasTopping, -48c2c56f:163da54fa86:-7fd6) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name42_1](p:hasTopping, p:NamedPizza, :pizza, <:toppings>) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fd6, <:toppings>) t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) t-owl-axiom:SubObjectAllValuesFrom(:pizza, p:hasTopping, -48c2c56f:163da54fa86:-7fd6) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name11_1](p:hasTopping, <:toppings>, p:NamedPizza, :pizza) :: t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) x | t-owl-axiom:SubObjectSomeValuesFrom(:pizza, p:hasTopping, <:toppings>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 skos:definition:1 rdfs:label:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name75_0](:subject, prefLabel : ?, definition : ?, <label>, ex:Burger) :: t-rdf:Triple(:subject, skos:definition, definition) t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-owl-axiom:SubClassOf(:subject, ex:Burger) x | t-rdf:Triple(:subject, rdfs:label, <label>) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/AnnotatedPizza ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name12_0](:subject, <:condiments>, ex:Burger, -48c2c56f:163da54fa86:-7f93) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7f93, <:condiments>) t-owl-axiom:SubClassOf(:subject, ex:Burger) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 rdfs:label:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name13_0](:subject, ex:Burger, <label>) :: t-owl-axiom:SubClassOf(:subject, ex:Burger) x | t-rdf:Triple(:subject, rdfs:label, <label>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza ===~Suggested templates~=== [name45_1](p:hasTopping, <:toppings>, p:NamedPizza, -48c2c56f:163da54fa86:-7fd6, :pizza) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fd6, <:toppings>) t-owl-axiom:SubClassOf(:pizza, p:NamedPizza) x | t-owl-axiom:SubObjectSomeValuesFrom(:pizza, p:hasTopping, <:toppings>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 skos:definition:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name14_1](p:Pizza, :subject, definition : ?) :: t-rdf:Triple(:subject, skos:definition, definition) t-owl-axiom:SubClassOf(:subject, p:Pizza) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name15_0](:subject, prefLabel : ?, ex:Burger) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-owl-axiom:SubClassOf(:subject, ex:Burger) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-axiom:SubObjectAllValuesFrom:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza http://example.org/BurgerMeal ===~Suggested templates~=== [name18_0](:subject, :hasCondiment, <:condiments>, -48c2c56f:163da54fa86:-7f93) :: x | t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasCondiment, <:condiments>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasCondiment, -48c2c56f:163da54fa86:-7f93) [name18_2](:subject, :hasSide, :hasMain, -48c2c56f:163da54fa86:-7fa8, ex:Burger) :: t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasMain, ex:Burger) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasSide, -48c2c56f:163da54fa86:-7fa8) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 skos:definition:1 rdfs:label:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name50_1](p:Pizza, :subject, definition : ?, <label>) :: t-rdf:Triple(:subject, skos:definition, definition) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-owl-axiom:SubClassOf(:subject, p:Pizza) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubObjectAllValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza http://example.org/BurgerMeal ===~Suggested templates~=== [name19_2](:subject, :hasSide, <:sides>) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fa8, <:sides>) t-owl-axiom:SubObjectAllValuesFrom(:subject, :hasSide, -48c2c56f:163da54fa86:-7fa8) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 rdfs:label:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name51_0](:subject, prefLabel : ?, <label>, ex:Burger) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-owl-axiom:SubClassOf(:subject, ex:Burger) x | t-rdf:Triple(:subject, rdfs:label, <label>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubObjectSomeValuesFrom:1 t-owl-rstr:ObjectUnionOf:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/NamedPizza http://example.org/BurgerMeal ===~Suggested templates~=== [name22_2](:subject, <:sides>, :hasMain, -48c2c56f:163da54fa86:-7fa8, ex:Burger) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fa8, <:sides>) t-owl-axiom:SubObjectSomeValuesFrom(:subject, :hasMain, ex:Burger) [name22_1](p:hasTopping, -48c2c56f:163da54fa86:-7fd6, :pizza, <:toppings>) :: t-owl-rstr:ObjectUnionOf(-48c2c56f:163da54fa86:-7fd6, <:toppings>) x | t-owl-axiom:SubObjectSomeValuesFrom(:pizza, p:hasTopping, <:toppings>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern t-owl-axiom:SubClassOf:1 skos:definition:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name54_1](p:Pizza, prefLabel : ?, :subject, definition : ?) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-rdf:Triple(:subject, skos:definition, definition) t-owl-axiom:SubClassOf(:subject, p:Pizza) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern skos:definition:1 rdfs:label:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name27_2](:subject, definition : ?, <label>) :: t-rdf:Triple(:subject, skos:definition, definition) x | t-rdf:Triple(:subject, rdfs:label, <label>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern rdfs:label:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name28_2](prefLabel : ?, <label>, :subject) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) x | t-rdf:Triple(:subject, rdfs:label, <label>) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern skos:definition:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name31_2](prefLabel : ?, :subject, definition : ?) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) t-rdf:Triple(:subject, skos:definition, definition) ====================================== ==========~Dependency Pair~=========== ====================================== Pattern skos:definition:1 rdfs:label:1 skos:prefLabel:1 occurs in http://example.org/Burger http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza ===~Suggested templates~=== [name63_1](:subject, prefLabel, definition, <label>) :: t-rdf:Triple(:subject, skos:prefLabel, prefLabel) x | t-rdf:Triple(:subject, rdfs:label, <label>) t-rdf:Triple(:subject, skos:definition, definition) ===~Lack of reuse~=== http://example.org/Burger has a lack of reuse of http://draft.ottr.xyz/pizza/Annotation http://draft.ottr.xyz/pizza/AnnotatedPizza has a lack of reuse of http://draft.ottr.xyz/pizza/Annotation
9 Script
All the executable examples may be run with the script run.sh
, this is its contents:
## write commands too set -x printf "\n\n\n" ## download jar files if [ ! -f ./lutra.jar ]; then wget https://gitlab.com/ottr/lutra/lutra/builds/artifacts/v0.1.6/raw/lutra.jar?job=build_tags -O lutra.jar fi if [ ! -f ./findPatterns.jar ]; then wget http://folk.uio.no/martige/what/20180601/findPatterns.jar -O findPatterns.jar fi printf "\n\n\n" ## display CLI java -jar lutra.jar printf "\n\n\n" ## convert to stOTTR serialisation java -jar lutra.jar -stottr -in tpl/intro/SubClassOf1 printf "\n\n\n" ## expand instances java -jar lutra.jar -expand -in inst/intro/SubClassOf1Instances printf "\n\n\n" ## expand template definition java -jar lutra.jar -expand -in tpl/intro/SubClassOf1 printf "\n\n\n" ## types: stOTTR serialisation java -jar lutra.jar -stottr -in tpl/types/SubClassOf3.ttl -out tpl/types/SubClassOf3.ttl.stottr cat tpl/types/SubClassOf3.ttl.stottr printf "\n\n\n" ## type check java -jar lutra.jar -expand -lib tpl/types -in inst/types/SubClassOf3Instances -out inst/types/SubClassOf3Instances.out printf "\n\n\n" ## type expansion cat inst/types/SubClassOf3Instances.out printf "\n\n\n" ## type error java -jar lutra.jar -expand -lib tpl/types -in inst/types/SubClassOf3Instances2 printf "\n\n\n" ## cardinality: optional java -jar lutra.jar -expand -in inst/card/ResourceDescriptionInstances printf "\n\n\n" ## cardinality: multiple java -jar lutra.jar -expand -in inst/card/EquivObjectUnionOfInstances printf "\n\n\n" ## mode test1 java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf1Instances printf "\n\n\n" ## mode test2 java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf2Instances printf "\n\n\n" ## mode test3 java -jar lutra.jar -quiet -expand -lib tpl/mode -in tpl/mode/SubClassOf3Instances printf "\n\n\n" ## pizza stottr java -jar lutra.jar -stottr -in http://draft.ottr.xyz/pizza/NamedPizza printf "\n\n\n" ## pizza instances java -jar lutra.jar -expand -in tpl/pizza/NamedPizzaInstances printf "\n\n\n" ## pizza tabOTTR java -jar lutra.jar -tabottr -in tab/NamedPizza-instances.xlsx printf "\n\n\n" ## find redundancies, restricted to demo-paper patterns java -jar findPatterns.jar -p redundancy-templates/ printf "\n\n\n" ## find redundancies, all java -jar findPatterns.jar -p redundancy-templates/ printf "\n\n\n"