Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Jan 23, 2024
1 parent b6574a7 commit 40aa87f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
self.updateProgressBar(0, 1, "Creating classtree and search index")
subjectstorender = set()
subjectstorender.add(URIRef(voidds))
nonnscount={}
for sub in self.graph.subjects(None,None,True):
if (prefixnamespace in sub and (isinstance(sub,URIRef)) or isinstance(sub,BNode)):
subjectstorender.add(sub)
Expand All @@ -319,6 +320,13 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
restriction = True
elif str(tup[0]) == "http://www.w3.org/2000/01/rdf-schema#subClassOf":
ressubcls=str(tup[1])
if isinstance(tup[1],URIRef) and prefixnamespace not in str(tup[1]):
ns=DocUtils.shortenURI(str(tup[1],True))
if str(tup[0]) not in nonnscount:
nonnscount[str(tup[0])]={}
if ns not in nonnscount[str(tup[0])]:
nonnscount[str(tup[0])][ns]=0
nonnscount[str(tup[0])][ns]+=1
if isinstance(sub,BNode) and restriction:
self.graph.add((sub, URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
Literal(label + " [Restriction]", lang="en")))
Expand Down Expand Up @@ -354,7 +362,7 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
tree["core"]["data"].append(tr)
voidstats["http://rdfs.org/ns/void#classes"]=len(classidset)
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,self.startconcept)
voidgraph=VoidExporter.createVoidDataset(self.datasettitle,prefixnamespace,self.deploypath,self.outpath,self.licenseuri,self.modtime,self.labellang,voidstats,tree,predmap,nonnscount,self.startconcept)
self.voidstatshtml=VoidExporter.toHTML(voidstats,self.deploypath)
self.graph+=voidgraph
with open(outpath + "style.css", 'w', encoding='utf-8') as f:
Expand Down Expand Up @@ -1382,7 +1390,7 @@ def createHTML(self,savepath, predobjs, subject, baseurl, subpreds, graph, searc
if metadatatablecontentcounter>=0:
f.write("<h5>Metadata</h5>")
f.write(templates["htmltabletemplate"].replace("{{tablecontent}}", metadatatablecontents))
f.write(self.replaceStandardVariables(templates["footer"],"",checkdepth,"false").replace("{{exports}}",myexports).replace("{{license}}",curlicense).replace("{{bibtex}}","").replace("{{stats}}",self.voidstatshtml))
f.write(self.replaceStandardVariables(templates["footer"],"",checkdepth,"false").replace("{{exports}}",myexports).replace("{{license}}",curlicense).replace("{{bibtex}}","").replace("{{stats}}",""))
f.close()
except Exception as inst:
print("Could not write "+str(completesavepath))
Expand Down
9 changes: 7 additions & 2 deletions src/sparqlunicorn_ontdoc/export/data/voidexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class VoidExporter:

@staticmethod
def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modtime,language,stats,classtree=None,propstats=None,startconcept=None):
def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modtime,language,stats,classtree=None,propstats=None,nonnscount=None,startconcept=None):
g=Graph()
if dsname==None or dsname=="":
dsname="dataset"
Expand Down Expand Up @@ -69,7 +69,12 @@ def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modti
g.add((URIRef(voidds), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
URIRef("http://rdfs.org/ns/void#Dataset")))
g.add((URIRef(voidds), URIRef("http://rdfs.org/ns/void#classPartition"), URIRef(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#triples"),Literal(str(nonnscount[prop][ns],datatype="http://www.w3.org/2001/XMLSchema#integer"))))
g.serialize(outpath+"/void.ttl", encoding="utf-8")
return g

Expand Down

0 comments on commit 40aa87f

Please sign in to comment.