GenDifS Formal Semantics: Overview#
Files#
source mindmap:
../mm/GenDifS_semantics.mm
generated turtle file:
../ttl/GenDifS_semantics_mm.ttl
Generate Ontology Code#
import sys
sys.path.append('../py/')
from gd06 import GenDifS_Map
mindmap = "GenDifS_semantics" # filename without .mm extension
o = GenDifS_Map(f"../mm/{mindmap}.mm",
sheet = None,
# restrict code generation to OWL, i.e. no SKOS, no example instances etc.
pattern = [ "owl", "docu" ],
# use_rdflib = False, # default: true
# remove_attributes= False, # default: true
verbose = 1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 3
1 mindmap = "GenDifS_semantics" # filename without .mm extension
----> 3 o = GenDifS_Map(f"../mm/{mindmap}.mm",
4 sheet = None,
5
6 # restrict code generation to OWL, i.e. no SKOS, no example instances etc.
7 pattern = [ "owl", "docu" ],
8
9 # use_rdflib = False, # default: true
10 # remove_attributes= False, # default: true
11 verbose = 1)
TypeError: GenDifS_Map.__init__() got an unexpected keyword argument 'sheet'
o.compile()
Lexer: found #1 start nodes: TAXONOMY
codegen: generated 51 entries in `t_and_a_box_records`
Collected 25 code lines, pattern: ['owl', 'docu', 'ALL']
rdflib: 28 triples.
print(o.ttl_code)
# __init__
# ALL:
@prefix ex: <http://example.net/namespace/ex#> .
@prefix cpt: <http://example.net/namespace/cpt#> .
@prefix sheet: <http://example.net/namespace/sheet#> .
@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 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#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix gendifs: <http://jbusse.de/gendifs#> .
# __init__
# ALL:
[ rdf:type owl:Ontology ] .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Class-A
# SUBTAXON.TAXONOMY.a
# owl: declare class *Class-A* being a subclass of topConcept
:Class-A
a owl:Class ;
rdfs:subClassOf :topConcept .
# BY.0
# docu: --------------------
# Class-A
# BY property-a-b SOME Class-P
# BY.a
# owl: declare *property-a-b* as a object property.
:property-a-b
rdf:type owl:ObjectProperty .
# BY.b
# owl: declare *Class-P* as a owl:Class .
:Class-P
a owl:Class .
# SUBTAXON.BY.a.03 ----
# docu:
# Class-A
# BY ... SOME ...
# Class-B
# SUBTAXON.BY.a
# owl: declare class *Class-B* being a subclass of Class-A
:Class-B
a owl:Class ;
rdfs:subClassOf :Class-A .
# SOME.0 ----
# docu:
# Class-A
# BY property-a-b SOME Class-P
# Class-B
# SOME Class-Q
# SOME.b
# owl: declare *Class-Q* as a owl:Class
:Class-Q
a owl:Class ;
rdfs:subClassOf :Class-P .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Subclass_CD
# SUBTAXON.TAXONOMY.a
# owl: declare class *Subclass_CD* being a subclass of topConcept
:Subclass_CD
a owl:Class ;
rdfs:subClassOf :topConcept .
# SUP.a
# owl: *INTERSECTION_1969000247*: intersection of superiors, i.e. *intersect(Superclass_C, Superclass_D)*
:INTERSECTION_1969000247
a owl:Class ;
rdfs:label "intersect(Superclass_C, Superclass_D)" ;
owl:equivalentClass [ a owl:Class ;
owl:intersectionOf (
:Superclass_C :Superclass_D ) ] .
# SUP.b
# owl: *INTERSECTION_1969000247* is a subclass of *Subclass_CD*
:INTERSECTION_1969000247
rdfs:subClassOf :Subclass_CD .
# SUPERTAXON.SUP.a.0 ----
# docu:
# Subclass_CD
# SUP
# Superclass_C
# SUPERTAXON.SUP.a
# owl: declare class *Subclass_CD* being a subclass of Superclass_C
:Subclass_CD
a owl:Class ;
rdfs:subClassOf :Superclass_C .
# SUPERTAXON.SUP.a.0 ----
# docu:
# Subclass_CD
# SUP
# Superclass_D
# SUPERTAXON.SUP.a
# owl: declare class *Subclass_CD* being a subclass of Superclass_D
:Subclass_CD
a owl:Class ;
rdfs:subClassOf :Superclass_D .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Subject_R
# SUBTAXON.TAXONOMY.a
# owl: declare class *Subject_R* being a subclass of topConcept
:Subject_R
a owl:Class ;
rdfs:subClassOf :topConcept .
# OP.0 ----
# docu:
# Subject_R
# OP object-property-r-s
# OP.a
# owl: declare *object-property-r-s* as a object property.
:object-property-r-s
rdf:type owl:ObjectProperty ;
rdf:label "object-property-r-s" .
# SUBTAXON.OP.a.0 ----
# docu:
# Subject_R
# OP object-property-r-s
# Object_S
# SUBTAXON.OP.a
# owl: declare class *Object_S*
:Object_S
a owl:Class .
# write ttl
o.mindmap.write(f"../mm/{mindmap}.mm", pretty_print=True)
# write back prettyfied mindmap
# with open(f"../ttl/{mindmap}_mm.ttl", "w") as file:
# file.write(o.ttl_code)
SKOS#
GenDifS also exports a SKOS terminology. Instances of the class skos:Concept
are prefixed with cpt
. (Do not prefix them i.e. with skos
).
o_skos = GenDifS_Map(f"../mm/{mindmap}.mm",
sheet = None,
pattern = [ "skos", "docu" ],
# use_rdflib = False,
# remove_attributes= False, # default: true
verbose = 1)
GenDifS 0.63 (2023-06-06)
cwd into input_dir: /home/dsci/a/l/LA_2023_ss/gendifs/mm
reading /home/dsci/a/l/LA_2023_ss/gendifs/mm/GenDifS_semantics.mm: 13 nodes
o_skos.compile()
Lexer: found #1 start nodes: TAXONOMY
codegen: generated 51 entries in `t_and_a_box_records`
Collected 22 code lines, pattern: ['skos', 'docu', 'ALL']
rdflib: 20 triples.
print(o_skos.ttl_code)
# __init__
# ALL:
@prefix ex: <http://example.net/namespace/ex#> .
@prefix cpt: <http://example.net/namespace/cpt#> .
@prefix sheet: <http://example.net/namespace/sheet#> .
@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 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#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix gendifs: <http://jbusse.de/gendifs#> .
# __init__
# ALL:
[ rdf:type owl:Ontology ] .
# __init__
# skos:
[ owl:imports <http://www.w3.org/2004/02/skos/core> ] .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Class-A
# SUBTAXON.TAXONOMY.c
# skos:
cpt:Class-A
a skos:Concept ;
skos:broader cpt:topConcept .
# BY.0
# docu: --------------------
# Class-A
# BY property-a-b SOME Class-P
# BY.d
# skos: define a skos:Collection
cpt:Class-A_BY_property-a-b_SOME_Class-P
skos:prefLabel "Class-A by property-a-b some Class-P" ;
a skos:Collection .
# SUBTAXON.BY.a.03 ----
# docu:
# Class-A
# BY ... SOME ...
# Class-B
# SUBTAXON.BY.d
# skos:
cpt:Class-A_BY_property-a-b_SOME_Class-P
skos:member cpt:Class-B .
# SUBTAXON.BY.c
# skos:
cpt:Class-B
a skos:Concept ;
skos:broader cpt:Class-A .
# SOME.0 ----
# docu:
# Class-A
# BY property-a-b SOME Class-P
# Class-B
# SOME Class-Q
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Subclass_CD
# SUBTAXON.TAXONOMY.c
# skos:
cpt:Subclass_CD
a skos:Concept ;
skos:broader cpt:topConcept .
# SUPERTAXON.SUP.a.0 ----
# docu:
# Subclass_CD
# SUP
# Superclass_C
# SUPERTAXON.SUP.c
# skos:
cpt:Superclass_C
a skos:Concept .
cpt:Subclass_CD
a skos:Concept ;
skos:broader cpt:Superclass_C .
# SUPERTAXON.SUP.a.0 ----
# docu:
# Subclass_CD
# SUP
# Superclass_D
# SUPERTAXON.SUP.c
# skos:
cpt:Superclass_D
a skos:Concept .
cpt:Subclass_CD
a skos:Concept ;
skos:broader cpt:Superclass_D .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Subject_R
# SUBTAXON.TAXONOMY.c
# skos:
cpt:Subject_R
a skos:Concept ;
skos:broader cpt:topConcept .
# OP.0 ----
# docu:
# Subject_R
# OP object-property-r-s
# SUBTAXON.OP.a.0 ----
# docu:
# Subject_R
# OP object-property-r-s
# Object_S
# SUBTAXON.OP.c
# skos:
cpt:Subject_R
a skos:Concept .
cpt:Object_S
a skos:Concept .
cpt:object-property-r-s
rdfs:subPropertyOf skos:related .
cpt:Subject_R
cpt:object-property-r-s cpt:Object_S .