Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KonradHoeffner/a351f5c119d992f7ed765de6ed695fb5 to your computer and use it in GitHub Desktop.
Save KonradHoeffner/a351f5c119d992f7ed765de6ed695fb5 to your computer and use it in GitHub Desktop.
select_snik_triplecheckmate_class_table.sparql
# remove leading zeroes and non-numerical characters from hash
# take first 9 numbers so it fits into a 32 bit integer
select distinct (substr(replace(replace(md5(?curi),"[a-f]",""),"^0+",""),1,9) as ?cid) ?curi replace(replace(str(?curi),"^([^/]*/){4}",""),"/",":") as ?cname (substr(replace(replace(md5(sample(?parent)),"[a-f]",""),"^0+",""),1,9) as ?cparent) (count(?child) as ?count_cache) (if(count(?child)=0,1,0) as ?is_leaf)
{
?curi a owl:Class.
OPTIONAL { graph ?g {?curi rdfs:subClassOf ?parent.}}
filter(?g!=<http://snik.eu/ontology/virtual>)
OPTIONAL { {?child rdfs:subClassOf ?curi.} UNION {?child a ?curi.}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment