ISA (Dolphin Shark)

Contents

ISA (Dolphin Shark)#

import gd07
from lxml import etree
m = gd07.GenDifS("../mm/dolphin-shark-ISA.mm", verb=2)
m.describe_mindmap()
self.mindmap_topnode.get('TEXT')='dolphin-shark-ISA'
len(self.mindmap_xml.getroot().xpath('.//node'))=10 nodes
m.compile(language_list_list=[['RDFS', 'RDFStest'], 'SKOS'])
m.describe_taxonomies()
ID_1192646256 TAXONOMY dolphin-shark-ISA: #9 GenDifS nodes;
self.languages={'SKOS', 'RDFS', 'RDFStest'};
self.rdf_graphs.keys()=dict_keys(['RDFS_RDFStest', 'SKOS'])

RDF#

RDFS_RDFStest_ttl = m.taxonomies_by_name["dolphin-shark-ISA"].rdf_graphs_ttl['RDFS_RDFStest']
#print(rdfs_ttl)
RDFS_RDFStest_graph = m.taxonomies_by_name["dolphin-shark-ISA"].rdf_graphs['RDFS_RDFStest']
len(RDFS_RDFStest_graph)
25
# many lines
#print(RDFS_RDFStest_graph.serialize())
focus = "Dolphin"
for paragraph in RDFS_RDFStest_graph.serialize().split("\n\n"):
    if focus in paragraph:
        print(paragraph, "\n")
ex:Dolphin_ID_1803963856 a :Dolphin . 

ex:Dolphin_ID_1818144088 a :Dolphin ;
    gendifs:classify_similar ex:Mammal_ID_1818144088 . 

:Dolphin a owl:Class ;
    rdfs:subClassOf :Mammal . 
import rdflib
g2 = rdflib.Graph()
g2.parse(data=m.taxonomies_by_name["dolphin-shark-ISA"].rdf_graphs_ttl['RDFS_RDFStest'])
len(g2)
25
import owlrl
owlrl.DeductiveClosure(owlrl.OWLRL_Semantics, axiomatic_triples = False).expand(g2)
len(g2)
197
# too many lines
# print(g2.serialize())

focus = "Dolphin"
for paragraph in g2.serialize().split("\n\n"):
    if focus in paragraph:
        print(paragraph, "\n")
ex:Dolphin_ID_1803963856 a :Dolphin,
        :Living,
        :Mammal,
        owl:Thing ;
    owl:sameAs ex:Dolphin_ID_1803963856 . 

ex:Dolphin_ID_1818144088 a :Dolphin,
        :Living,
        :Mammal,
        owl:Thing ;
    gendifs:classify_similar ex:Mammal_ID_1818144088 ;
    owl:sameAs ex:Dolphin_ID_1818144088 . 

owl:Nothing a owl:Class ;
    rdfs:subClassOf :Dolphin,
        :Living,
        :Mammal,
        :Shark,
        owl:Nothing,
        owl:Thing,
        <https://de.wikipedia.org/wiki/Fish> ;
    owl:equivalentClass owl:Nothing ;
    owl:sameAs owl:Nothing . 

:Dolphin a owl:Class ;
    rdfs:subClassOf :Dolphin,
        :Living,
        :Mammal,
        owl:Thing ;
    owl:equivalentClass :Dolphin ;
    owl:sameAs :Dolphin . 

SKOS#

SKOS_ttl = m.taxonomies_by_name["dolphin-shark-ISA"].rdf_graphs_ttl['SKOS']
print(SKOS_ttl)
@prefix cpt: <http://example.net/namespace/cpt#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

cpt:Dolphin a skos:Concept ;
    skos:broader cpt:Mammal .

cpt:Shark a skos:Concept ;
    skos:broader cpt:_https___de_wikipedia_org_wiki_Fish_ .

cpt:Mammal a skos:Concept ;
    skos:broader cpt:Living .

cpt:_https___de_wikipedia_org_wiki_Fish_ a skos:Concept ;
    skos:broader cpt:Living .

cpt:dolphin_shark_ISA a skos:ConceptScheme .

cpt:Living a skos:Concept ;
    skos:inScheme cpt:dolphin_shark_ISA .

[] owl:imports <http://www.w3.org/TR/skos-reference/skos-owl1-dl.rdf> .