GenDifS Hello World#
GenDifS is a language for generating one or more taxonomies from a single mind map. The taxonomies are exported into various knowlede models, in particular a lightweight OWL T-Box and SKOS A-Box. We present a minimal example here.
We can read the following from this mind map.
There is a taxonomy with the name hello.
We have six (!) categories.
On the one hand, we have first-order classes that we want to describe. These are printed in bold in the mindmap, but they don’t have to be: Greting, Hello and Приве́т!!
In addition, we have some second-order classes. They help us to classify the first-order classes: Language, en and ru.
The tree of the mind map rightly suggests a subclass relationship: Hello and Приве́т! are subcategories of Greeting.
In addition there is a second subclass relationship somehow “woven in”: en and ru are subcategories of Language.
The property has_language can accept values from the Language category, among others. (And no, interpreting this information as a rdfs:range would be wrong. It is correct to construct an OWL restriction here. )
The question arises as to how this information can be formalized in the various semantic web language like RDFS, SKOS or OWL.
There are at least three possibilities here.
Firstly, we create a pure RDFS class tree. As a result, we get classes and subclasses.
Secondly, we create a SKOS thesaurus. As a result we get a network of instances of the class
skos:Concept
. (2024-09-25: The SKOS export is a laborious task and is not yet fully implemented.)Thirdly, we create a lighweight OWL ontology. As a result, we can enrich the RDFS class tree with so called restrictions.
GenDifS generates all three dialects. The namespaces are chosen so that we can use all three dialects at the same time. In particular, setting up the OWL restrictions manually is time-consuming and error-prone. One of the strengths of GenDifS is its ability to construct complex OWL axioms from a simple notation.
from gd07 import GenDifS
m = GenDifS("../mm/hello-world.mm")
m.compile()
m.taxonomies_by_name["hello"].describe()
ID_319523876 TAXONOMY hello: #7 GenDifS nodes;
self.languages={'RDFStest', 'RDFS', 'OWLtest', 'DE', 'SKOS', 'OWL'};
self.rdf_graphs.keys()=dict_keys(['RDFStest', 'RDFS', 'OWLtest', 'DE', 'SKOS', 'OWL'])
print(m.taxonomies_by_name["hello"].rdf_graphs_ttl["RDFS"])
@prefix : <http://example.net/namespace/default#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Hello a owl:Class ;
rdfs:subClassOf :Greeting .
:en rdfs:subClassOf :Language .
:ru rdfs:subClassOf :Language .
:Приве_т_ a owl:Class ;
rdfs:subClassOf :Greeting .
:Greeting a owl:Class .
print(m.taxonomies_by_name["hello"].rdf_graphs_ttl["SKOS"])
@prefix cpt: <http://example.net/namespace/cpt#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
cpt:BY_ID_1952656871_intersection a skos:Collection ;
rdfs:label "cpt:Greeting BY cpt:has_language FROM cpt:Language" ;
skos:member cpt:Hello,
cpt:Приве_т_ .
cpt:en a skos:Concept ;
skos:broader cpt:Language .
cpt:has_language a rdfs:Property ;
rdfs:subPropertyOf skos:related .
cpt:ru a skos:Concept ;
skos:broader cpt:Language .
cpt:Hello a skos:Concept ;
skos:broader cpt:Greeting .
cpt:hello a skos:ConceptScheme .
cpt:Приве_т_ a skos:Concept ;
skos:broader cpt:Greeting .
cpt:Greeting a skos:Concept ;
skos:inScheme cpt:hello .
cpt:Language a skos:Concept .
[] owl:imports <http://www.w3.org/TR/skos-reference/skos-owl1-dl.rdf> .
print(m.taxonomies_by_name["hello"].rdf_graphs_ttl["OWL"])
@prefix : <http://example.net/namespace/default#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:BY_ID_1952656871_intersection a owl:class ;
rdfs:label "BY_ex:has_language_FROM_ex:Language_INTERSECT_ex:Greeting" ;
rdfs:subClassOf :Greeting ;
owl:intersectionOf ( :BY_ID_1952656871_restriction :Greeting ) .
:BY_SOME_ID_1543072838_intersection a owl:class ;
rdfs:label "(BY_ex:has_language_FROM_ex:Language_SOME_ex:ru)_INTERSECT_ex:Greeting" ;
rdfs:subClassOf :Приве_т_ ;
owl:intersectionOf ( :BY_SOME_ID_1543072838_restriction :Greeting ) .
:BY_SOME_ID_988527468_intersection a owl:class ;
rdfs:label "(BY_ex:has_language_FROM_ex:Language_SOME_ex:en)_INTERSECT_ex:Greeting" ;
rdfs:subClassOf :Hello ;
owl:intersectionOf ( :BY_SOME_ID_988527468_restriction :Greeting ) .
:BY_ID_1952656871_restriction a owl:Restriction,
owl:class ;
rdfs:label "BY_ex:has_language_FROM_ex:Language" ;
owl:onProperty :has_language ;
owl:someValuesFrom :Language .
:BY_SOME_ID_1543072838_restriction a owl:Restriction,
owl:class ;
rdfs:label "BY_ex:has_language_FROM_ex:Language_SOME_ex:ru" ;
owl:onProperty :has_language ;
owl:someValuesFrom :ru .
:BY_SOME_ID_988527468_restriction a owl:Restriction,
owl:class ;
rdfs:label "BY_ex:has_language_FROM_ex:Language_SOME_ex:en" ;
owl:onProperty :has_language ;
owl:someValuesFrom :en .
:has_language a owl:ObjectProperty .