Semantics: ISA
Contents
Semantics: ISA#
import sys
sys.path.append('../py/')
from gd06 import GenDifS_Map
mindmap = "semantics_isa" # filename without .mm extension
o = GenDifS_Map(f"../mm/{mindmap}.mm",
pattern = [ "owl", "owl-test", "docu" ],
# use_rdflib = False, # default: true
# remove_attributes= False, # default: true
verbose = 1)
__init__: GenDifS 0.63 (2023-08-01, 2023-09-08)
o.compile()
lexer: Lexer: found #1 start nodes: ['TAXONOMY']
codegen: codegen: generated 4 entries in `ttl_records`
get_code: Collected 10 code lines, pattern: ['owl', 'owl-test', 'docu', 'ALL']
rdflib_parse: rdflib: 10 triples.
# write back ttl in order to highlight source nodes
# o.mindmap.write(f"../mm/{mindmap}.mm", pretty_print=True)
print(o.select_molecules(o.rdflib_graph, [":Animal", ":Cat", "ex:"]))
@prefix : <http://example.net/namespace/default#> .
@prefix ex: <http://example.net/namespace/ex#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:Animal_12_563_091 a :Animal .
ex:Cat_1_208_031_273 a :Cat ;
ex:classifyLike ex:Animal_1_208_031_273 .
:Cat a owl:Class ;
rdfs:subClassOf :Animal .
ex:Animal_1_208_031_273 a :Animal .
:Animal a owl:Class ;
rdfs:subClassOf :topConcept .
o.owlrl()
owlrl: owlrl: 147 triples.
print(o.select_molecules(o.owlrl_graph, [":Animal", ":Cat", "ex:" ]))
@prefix : <http://example.net/namespace/default#> .
@prefix ex: <http://example.net/namespace/ex#> .
@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#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:Animal_12_563_091 a :Animal,
:topConcept,
owl:Thing ;
owl:sameAs ex:Animal_12_563_091 .
ex:Cat_1_208_031_273 a :Animal,
:Cat,
:topConcept,
owl:Thing ;
ex:classifyLike ex:Animal_1_208_031_273 ;
owl:sameAs ex:Cat_1_208_031_273 .
ex:Animal_1_208_031_273 a :Animal,
:topConcept,
owl:Thing ;
owl:sameAs ex:Animal_1_208_031_273 .
owl:Nothing a owl:Class ;
rdfs:subClassOf :Animal,
:Cat,
:topConcept,
owl:Nothing,
owl:Thing ;
owl:equivalentClass owl:Nothing ;
owl:sameAs owl:Nothing .
:Cat a owl:Class ;
rdfs:subClassOf :Animal,
:Cat,
:topConcept,
owl:Thing ;
owl:equivalentClass :Cat ;
owl:sameAs :Cat .
:Animal a owl:Class ;
rdfs:subClassOf :Animal,
:topConcept,
owl:Thing ;
owl:equivalentClass :Animal ;
owl:sameAs :Animal .
q = """
SELECT ?a ?A
WHERE {
?a rdf:type ?A .
?a ex:classifyLike ?b .
}
"""
def show_rows(g, q):
for row in g.query(q):
print([item.n3(g.namespace_manager) for item in row])
show_rows(o.rdflib_graph, q)
['ex:Cat_1_208_031_273', ':Cat']
show_rows(o.owlrl_graph, q)
['ex:Cat_1_208_031_273', ':Cat']
['ex:Cat_1_208_031_273', ':Animal']
['ex:Cat_1_208_031_273', 'owl:Thing']
['ex:Cat_1_208_031_273', ':topConcept']
The complete graphs#
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__
# owl-test:
ex:classifyLike a owl:ObjectProperty .
# __init__
# ALL:
[ rdf:type owl:Ontology ] .
# SUBTAXON.TAXONOMY.a.01 ----
# docu:
# TAXONOMY
# Animal
# SUBTAXON.TAXONOMY.a
# owl: declare class *Animal* being a subclass of topConcept
:Animal
a owl:Class ;
rdfs:subClassOf :topConcept .
# SUBTAXON.TAXONOMY.b
# owl-test: allocate an example instance
ex:Animal_12_563_091
a :Animal .
# SUBTAXON.ISA.a.02 ----
# docu:
# Animal
# ISA
# Cat
# SUBTAXON.ISA.a.02b ----
# owl-test:
ex:Cat_1_208_031_273
ex:classifyLike ex:Animal_1_208_031_273 .
ex:Cat_1_208_031_273 a :Cat .
ex:Animal_1_208_031_273 a :Animal .
# SUBTAXON.ISA.a
# owl: declare class *Cat* being a subclass of Animal
:Cat
a owl:Class ;
rdfs:subClassOf :Animal .
# SUBTAXON.ISA.b
# owl-test: allocate an example instance
ex:Cat_1_208_031_273
a :Cat .
print(o.rdflib_graph.serialize())
@prefix : <http://example.net/namespace/default#> .
@prefix ex: <http://example.net/namespace/ex#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:Animal_12_563_091 a :Animal .
ex:Cat_1_208_031_273 a :Cat ;
ex:classifyLike ex:Animal_1_208_031_273 .
ex:classifyLike a owl:ObjectProperty .
:Cat a owl:Class ;
rdfs:subClassOf :Animal .
ex:Animal_1_208_031_273 a :Animal .
:Animal a owl:Class ;
rdfs:subClassOf :topConcept .
[] a owl:Ontology .
print(o.owlrl_graph.serialize())
@prefix : <http://example.net/namespace/default#> .
@prefix ex: <http://example.net/namespace/ex#> .
@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#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:Animal_12_563_091 a :Animal,
:topConcept,
owl:Thing ;
owl:sameAs ex:Animal_12_563_091 .
ex:Cat_1_208_031_273 a :Animal,
:Cat,
:topConcept,
owl:Thing ;
ex:classifyLike ex:Animal_1_208_031_273 ;
owl:sameAs ex:Cat_1_208_031_273 .
rdf:HTML a rdfs:Datatype ;
owl:sameAs rdf:HTML .
rdf:PlainLiteral a rdfs:Datatype ;
owl:sameAs rdf:PlainLiteral .
rdf:XMLLiteral a rdfs:Datatype ;
owl:sameAs rdf:XMLLiteral .
rdf:langString a rdfs:Datatype ;
owl:sameAs rdf:langString .
rdf:type owl:sameAs rdf:type .
rdfs:Literal a rdfs:Datatype ;
owl:sameAs rdfs:Literal .
rdfs:comment a owl:AnnotationProperty ;
owl:sameAs rdfs:comment .
rdfs:isDefinedBy a owl:AnnotationProperty ;
owl:sameAs rdfs:isDefinedBy .
rdfs:label a owl:AnnotationProperty ;
owl:sameAs rdfs:label .
rdfs:seeAlso a owl:AnnotationProperty ;
owl:sameAs rdfs:seeAlso .
rdfs:subClassOf owl:sameAs rdfs:subClassOf .
rdfs:subPropertyOf owl:sameAs rdfs:subPropertyOf .
xsd:NCName a rdfs:Datatype ;
owl:sameAs xsd:NCName .
xsd:NMTOKEN a rdfs:Datatype ;
owl:sameAs xsd:NMTOKEN .
xsd:Name a rdfs:Datatype ;
owl:sameAs xsd:Name .
xsd:anyURI a rdfs:Datatype ;
owl:sameAs xsd:anyURI .
xsd:base64Binary a rdfs:Datatype ;
owl:sameAs xsd:base64Binary .
xsd:boolean a rdfs:Datatype ;
owl:sameAs xsd:boolean .
xsd:byte a rdfs:Datatype ;
owl:sameAs xsd:byte .
xsd:date a rdfs:Datatype ;
owl:sameAs xsd:date .
xsd:dateTime a rdfs:Datatype ;
owl:sameAs xsd:dateTime .
xsd:dateTimeStamp a rdfs:Datatype ;
owl:sameAs xsd:dateTimeStamp .
xsd:decimal a rdfs:Datatype ;
owl:sameAs xsd:decimal .
xsd:double a rdfs:Datatype ;
owl:sameAs xsd:double .
xsd:float a rdfs:Datatype ;
owl:sameAs xsd:float .
xsd:hexBinary a rdfs:Datatype ;
owl:sameAs xsd:hexBinary .
xsd:int a rdfs:Datatype ;
owl:sameAs xsd:int .
xsd:integer a rdfs:Datatype ;
owl:sameAs xsd:integer .
xsd:language a rdfs:Datatype ;
owl:sameAs xsd:language .
xsd:long a rdfs:Datatype ;
owl:sameAs xsd:long .
xsd:negativeInteger a rdfs:Datatype ;
owl:sameAs xsd:negativeInteger .
xsd:nonNegativeInteger a rdfs:Datatype ;
owl:sameAs xsd:nonNegativeInteger .
xsd:nonPositiveInteger a rdfs:Datatype ;
owl:sameAs xsd:nonPositiveInteger .
xsd:normalizedString a rdfs:Datatype ;
owl:sameAs xsd:normalizedString .
xsd:positiveInteger a rdfs:Datatype ;
owl:sameAs xsd:positiveInteger .
xsd:short a rdfs:Datatype ;
owl:sameAs xsd:short .
xsd:string a rdfs:Datatype ;
owl:sameAs xsd:string .
xsd:time a rdfs:Datatype ;
owl:sameAs xsd:time .
xsd:token a rdfs:Datatype ;
owl:sameAs xsd:token .
xsd:unsignedByte a rdfs:Datatype ;
owl:sameAs xsd:unsignedByte .
xsd:unsignedInt a rdfs:Datatype ;
owl:sameAs xsd:unsignedInt .
xsd:unsignedLong a rdfs:Datatype ;
owl:sameAs xsd:unsignedLong .
xsd:unsignedShort a rdfs:Datatype ;
owl:sameAs xsd:unsignedShort .
owl:backwardCompatibleWith a owl:AnnotationProperty ;
owl:sameAs owl:backwardCompatibleWith .
owl:deprecated a owl:AnnotationProperty ;
owl:sameAs owl:deprecated .
owl:equivalentClass owl:sameAs owl:equivalentClass .
owl:equivalentProperty owl:sameAs owl:equivalentProperty .
owl:incompatibleWith a owl:AnnotationProperty ;
owl:sameAs owl:incompatibleWith .
owl:priorVersion a owl:AnnotationProperty ;
owl:sameAs owl:priorVersion .
owl:sameAs owl:sameAs owl:sameAs .
owl:versionInfo a owl:AnnotationProperty ;
owl:sameAs owl:versionInfo .
ex:Animal_1_208_031_273 a :Animal,
:topConcept,
owl:Thing ;
owl:sameAs ex:Animal_1_208_031_273 .
owl:ObjectProperty owl:sameAs owl:ObjectProperty .
owl:Ontology owl:sameAs owl:Ontology .
ex:classifyLike a owl:ObjectProperty ;
rdfs:subPropertyOf ex:classifyLike ;
owl:equivalentProperty ex:classifyLike ;
owl:sameAs ex:classifyLike .
owl:Nothing a owl:Class ;
rdfs:subClassOf :Animal,
:Cat,
:topConcept,
owl:Nothing,
owl:Thing ;
owl:equivalentClass owl:Nothing ;
owl:sameAs owl:Nothing .
:Cat a owl:Class ;
rdfs:subClassOf :Animal,
:Cat,
:topConcept,
owl:Thing ;
owl:equivalentClass :Cat ;
owl:sameAs :Cat .
owl:Class owl:sameAs owl:Class .
:topConcept owl:sameAs :topConcept .
:Animal a owl:Class ;
rdfs:subClassOf :Animal,
:topConcept,
owl:Thing ;
owl:equivalentClass :Animal ;
owl:sameAs :Animal .
owl:Thing a owl:Class ;
rdfs:subClassOf owl:Thing ;
owl:equivalentClass owl:Thing ;
owl:sameAs owl:Thing .
owl:AnnotationProperty owl:sameAs owl:AnnotationProperty .
rdfs:Datatype owl:sameAs rdfs:Datatype .
_:n4f4f397c438b4da699f9d379d74cc98db1 a owl:Ontology ;
owl:sameAs _:n4f4f397c438b4da699f9d379d74cc98db1 .