Skip to content

Commit

Permalink
class partition rendering fix
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Jan 23, 2024
1 parent 4a221c5 commit edf85b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
voidstats["http://rdfs.org/ns/void#triples"] = len(self.graph)
voidgraph=VoidExporter.createVoidDataset(self.datasettitle,prefixnamespace,self.deploypath,self.outpath,self.licenseuri,self.modtime,self.labellang,voidstats,tree,predmap,nonnscount,instancecount,self.startconcept)
self.voidstatshtml=VoidExporter.toHTML(voidstats,self.deploypath)
self.graph+=voidgraph
self.graph+=voidgraph["graph"]
subjectstorender+=voidgraph["subjects"]
with open(outpath + "style.css", 'w', encoding='utf-8') as f:
f.write(templates["stylesheet"])
f.close()
Expand Down
17 changes: 11 additions & 6 deletions src/sparqlunicorn_ontdoc/export/data/voidexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class VoidExporter:
@staticmethod
def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modtime,language,stats,classtree=None,propstats=None,nonnscount=None,objectmap=None,startconcept=None):
g=Graph()
subjects=set()
if dsname==None or dsname=="":
dsname="dataset"
voidds=prefixnamespace+dsname
Expand Down Expand Up @@ -56,6 +57,7 @@ def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modti
URIRef("http://rdfs.org/ns/void#Dataset")))
g.add((URIRef(cururi),URIRef("http://rdfs.org/ns/void#property"),URIRef(pred)))
g.add((URIRef(cururi),URIRef("http://rdfs.org/ns/void#triples"),Literal(str(propstats[pred]["triples"]),datatype="http://www.w3.org/2001/XMLSchema#integer")))
subjects.add(cururi)
for item in classtree["core"]["data"]:
if item["type"]=="class":
cururi = voidds +"_"+ DocUtils.shortenURI(item["id"])
Expand All @@ -64,15 +66,18 @@ def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modti
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#class"), URIRef(item["id"])))
if item["id"] in objectmap:
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#entities"),Literal(str(objectmap[item["id"]]), datatype="http://www.w3.org/2001/XMLSchema#integer")))
subjects.add(cururi)
for prop in nonnscount:
for ns in nonnscount[prop]:
g.add((URIRef(voidds+"_"+DocUtils.shortenURI(ns)), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),URIRef("http://rdfs.org/ns/void#Linkset")))
g.add((URIRef(voidds + "_" + DocUtils.shortenURI(ns)),URIRef("http://rdfs.org/ns/void#subjectsTarget"),URIRef(voidds)))
g.add((URIRef(voidds + "_" + DocUtils.shortenURI(ns)), URIRef("http://rdfs.org/ns/void#objectsTarget"),URIRef(ns)))
g.add((URIRef(voidds + "_" + DocUtils.shortenURI(ns)), URIRef("http://rdfs.org/ns/void#linkPredicate"),URIRef(prop)))
g.add((URIRef(voidds + "_" + DocUtils.shortenURI(ns)), URIRef("http://rdfs.org/ns/void#triples"),Literal(str(nonnscount[prop][ns]),datatype="http://www.w3.org/2001/XMLSchema#integer")))
cururi=voidds+"_"+DocUtils.shortenURI(ns)
g.add((URIRef(cururi), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),URIRef("http://rdfs.org/ns/void#Linkset")))
g.add((URIRef(cururi),URIRef("http://rdfs.org/ns/void#subjectsTarget"),URIRef(voidds)))
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#objectsTarget"),URIRef(ns)))
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#linkPredicate"),URIRef(prop)))
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#triples"),Literal(str(nonnscount[prop][ns]),datatype="http://www.w3.org/2001/XMLSchema#integer")))
subjects.add(cururi)
g.serialize(outpath+"/void.ttl", encoding="utf-8")
return g
return {"graph":g,"subjects":subjects}

@staticmethod
def toHTML(stats,deploypath):
Expand Down

0 comments on commit edf85b4

Please sign in to comment.