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 bb8dbd2 commit de5982f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
subjectstorender = set()
subjectstorender.add(URIRef(voidds))
nonnscount={}
instancecount={}
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 @@ -316,6 +317,10 @@ def generateOntDocForNameSpace(self, prefixnamespace,dataformat="HTML"):
labeltouri[str(tup[1])] = str(sub)
uritolabel[str(sub)] = {"label":str(tup[1])}
label=str(tup[1])
elif str(tup[0])==self.typeproperty:
if str(tup[1]) not in instancecount:
instancecount[str(tup[1])]=0
instancecount[str(tup[1])]+=1
elif str(tup[1]) == "http://www.w3.org/2002/07/owl#Restriction":
restriction = True
elif str(tup[0]) == "http://www.w3.org/2000/01/rdf-schema#subClassOf":
Expand Down Expand Up @@ -362,7 +367,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,nonnscount,self.startconcept)
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
with open(outpath + "style.css", 'w', encoding='utf-8') as f:
Expand Down
11 changes: 3 additions & 8 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,nonnscount=None,startconcept=None):
def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modtime,language,stats,classtree=None,propstats=None,nonnscount=None,objectmap=None,startconcept=None):
g=Graph()
if dsname==None or dsname=="":
dsname="dataset"
Expand Down Expand Up @@ -62,13 +62,8 @@ def createVoidDataset(dsname,prefixnamespace,deploypath,outpath,licenseuri,modti
g.add((URIRef(voidds), URIRef("http://rdfs.org/ns/void#classPartition"), URIRef(cururi)))
g.add((URIRef(cururi), URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),URIRef("http://rdfs.org/ns/void#Dataset")))
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#class"), URIRef(item["id"])))
g.add((URIRef(cururi), URIRef("http://rdfs.org/ns/void#entities"),Literal(str(stats["http://rdfs.org/ns/void#entities"]), datatype="http://www.w3.org/2001/XMLSchema#integer")))
objectmap={}
for obj in objectmap:
cururi = voidds + "_" + DocUtils.shortenURI(item)
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)))
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")))
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")))
Expand Down

0 comments on commit de5982f

Please sign in to comment.