Skip to content

Commit

Permalink
detect collections types for automatically generated collections
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Jan 17, 2024
1 parent f518bfc commit d138bfe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
31 changes: 30 additions & 1 deletion src/sparqlunicorn_ontdoc/doc/docconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DocConfig:

collectionclasses = {
"http://www.w3.org/2006/vcard/ns#Group":"personcollection",
"http://purl.org/ontology/bibo/Collection":"bibcollction",
"http://purl.org/ontology/bibo/Collection":"bibcollection",
"http://www.w3.org/ns/dcat#Catalog":"datasetcollection",
"http://www.opengis.net/ont/geosparql#FeatureCollection": "geocollection",
"http://www.w3.org/ns/lemon/lime#Lexicon": "lexicon",
Expand All @@ -42,6 +42,35 @@ class DocConfig:
"https://www.w3.org/ns/activitystreams#OrderedCollection": "collection"
}

classToCollectionClass={
"http://www.opengis.net/ont/geosparql#SpatialObject": {"class": "http://www.opengis.net/ont/geosparql#SpatialObjectCollection","prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://www.opengis.net/ont/geosparql#Feature":{"class":"http://www.opengis.net/ont/geosparql#FeatureCollection","prop":"http://www.w3.org/2000/01/rdf-schema#member"},
"http://www.opengis.net/ont/geosparql#Geometry": {"class":"http://www.opengis.net/ont/geosparql#GeometryCollection","prop":"http://www.w3.org/2000/01/rdf-schema#member"},
"http://www.w3.org/2006/vcard/ns#Individual": {"class":"http://www.w3.org/2006/vcard/ns#Group","prop":"http://www.w3.org/2006/vcard/ns#hasMember"},
"http://xmlns.com/foaf/0.1/Person": {"class":"http://www.w3.org/2006/vcard/ns#Group","prop":"http://www.w3.org/2006/vcard/ns#hasMember"},
"http://www.w3.org/ns/lemon/ontolex#LexicalEntry": {"class":"http://www.w3.org/ns/lemon/lime#Lexicon","prop":"http://www.w3.org/ns/lemon/lexicog#entry"},
"http://www.w3.org/ns/dcat#Dataset": {"class":"http://www.w3.org/ns/lemon/lime#Catalog","prop":"http://www.w3.org/ns/dcat#dataset"},
"http://www.w3.org/ns/sosa/Observation":{"class":"http://www.w3.org/ns/sosa/ObservationCollection","prop":"http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Document": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Article": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/AcademicArticle": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Thesis": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/BookSection": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/EditedBook": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Report": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Book": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"},
"http://purl.org/ontology/bibo/Proceedings": {"class": "http://purl.org/ontology/bibo/Collection",
"prop": "http://www.w3.org/2000/01/rdf-schema#member"}
}

geoliteraltypes=["http://www.opengis.net/ont/geosparql#wktLiteral","http://www.opengis.net/ont/geosparql#gmlLiteral","http://www.opengis.net/ont/geosparql#kmlLiteral","http://www.opengis.net/ont/geosparql#geoJSONLiteral","http://www.opengis.net/ont/geosparql#dggsLiteral"]

timeproperties=["http://www.cidoc-crm.org/cidoc-crm/P79_beginning_is_qualified_by","http://www.cidoc-crm.org/cidoc-crm/P80_end_is_qualified_by","http://www.w3.org/2006/time#inXSDDateTime","http://www.w3.org/2006/time#inXSDDate","http://www.w3.org/2006/time#inXSDDateTimeStamp","http://www.w3.org/2006/time#inXSDgYear","http://www.w3.org/2006/time#inXSDgYearMonth"]
Expand Down
9 changes: 8 additions & 1 deletion src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def createCollections(self,graph,namespace):
classToFColl[str(tup[1])]+=1
for cls in classToInstances:
colluri=namespace+DocUtils.shortenURI(cls)+"_collection"
collrelprop="http://www.w3.org/2000/01/rdf-schema#member"
if classToFColl[cls]==len(classToInstances[cls]):
graph.add((URIRef("http://www.opengis.net/ont/geosparql#SpatialObjectCollection"),URIRef("http://www.w3.org/2000/01/rdf-schema#subClassOf"),URIRef("http://www.w3.org/2004/02/skos/core#Collection")))
graph.add((URIRef("http://www.opengis.net/ont/geosparql#FeatureCollection"), URIRef("http://www.w3.org/2000/01/rdf-schema#subClassOf"),URIRef("http://www.opengis.net/ont/geosparql#SpatialObjectCollection")))
Expand All @@ -544,11 +545,17 @@ def createCollections(self,graph,namespace):
graph.add((URIRef("http://www.opengis.net/ont/geosparql#SpatialObjectCollection"),URIRef("http://www.w3.org/2000/01/rdf-schema#subClassOf"),URIRef("http://www.w3.org/2004/02/skos/core#Collection")))
graph.add((URIRef("http://www.opengis.net/ont/geosparql#GeometryCollection"), URIRef("http://www.w3.org/2000/01/rdf-schema#subClassOf"),URIRef("http://www.opengis.net/ont/geosparql#SpatialObjectCollection")))
graph.add((URIRef(colluri), URIRef(self.typeproperty),URIRef("http://www.opengis.net/ont/geosparql#GeometryCollection")))
elif cls in DocConfig.classToCollectionClass:
graph.add((URIRef("http://www.opengis.net/ont/geosparql#GeometryCollection"),
URIRef("http://www.w3.org/2000/01/rdf-schema#subClassOf"),
URIRef("http://www.w3.org/2004/02/skos/core#Collection")))
graph.add((URIRef(colluri),URIRef(self.typeproperty),URIRef(DocConfig.classToCollectionClass[cls]["class"])))
collrelprop=DocConfig.classToCollectionClass[cls]["prop"]
else:
graph.add((URIRef(colluri),URIRef(self.typeproperty),URIRef("http://www.w3.org/2004/02/skos/core#Collection")))
graph.add((URIRef(colluri),URIRef("http://www.w3.org/2000/01/rdf-schema#label"),Literal(str(DocUtils.shortenURI(cls))+" Instances Collection",lang="en")))
for instance in classToInstances[cls]:
graph.add((URIRef(colluri),URIRef("http://www.w3.org/2000/01/rdf-schema#member"),URIRef(instance)))
graph.add((URIRef(colluri),URIRef(collrelprop),URIRef(instance)))
return graph

def getClassTree(self,graph, uritolabel,classidset,uritotreeitem):
Expand Down

0 comments on commit d138bfe

Please sign in to comment.