Skip to content

Commit

Permalink
update example and use owl descriptions for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyseale committed Jan 8, 2024
1 parent 612b26a commit 47af001
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions code/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ def add_to_context(uri):
context[name] = {"@id": str(uri)}
class_obj = RdfClass(name=name, uri=uri)
classes[uri] = class_obj
for s1, p1, o1 in g.triples((class_obj.uri, None, None)):
class_obj.__dict__[short_name(p1)] = o1
fill_object(class_obj)
for s, p, o in g.triples((None, RDFS.subClassOf, uri)):
add_to_context(s)
add_to_context(s)

if hasattr(class_obj, 'targetClass'):
owl_class = RdfClass(name=name, uri=class_obj.targetClass)
fill_object(owl_class)
if owl_class.description and owl_class.description != '':
print(f'description: {owl_class.description}')
class_obj.description = owl_class.description

for s, p, o in g.triples((uri, SH.property, None)):
property_name = short_name(o)
property_name = property_name.replace(f'{name}-', '')
Expand All @@ -99,6 +106,11 @@ def add_to_context(uri):
# context[name] = {"@id": str(uri)}


def fill_object(obj):
for s1, p1, o1 in g.triples((obj.uri, None, None)):
obj.__dict__[short_name(p1)] = o1


# Add classes and properties to the context
for class_uri in g.subjects():
add_to_context(class_uri)
Expand Down
4 changes: 2 additions & 2 deletions docs/respec/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ <h2>Data Product (DPROD) Model</h2>
"outputPort": {
"@type": "dcat:DataService",
"dcat:endpointURL": "https://y.com/uk-10-year-bonds",
"offersDistribution": {
"isAccessServiceOf": {
"@type": "dcat:Distribution",
"dcterms:format": "https://www.iana.org/assignments/media-types/application/json",
"belongsToDataset": {
"isDistributionOf": {
"@type": "dcat:Dataset",
"dcat:conformsTo": "https://spec.edmcouncil.org/fibo/ontology/SEC/Debt/Bonds/CallableBond"
}
Expand Down

0 comments on commit 47af001

Please sign in to comment.