Cannot recognize "defines" property in ontology
Opened this issue · 2 comments
Mec-iS commented
I have a context like:
"@context":
{"dbpedia": "http://dbpedia.org/ontology/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"owl": "http://www.w3.org/2002/07/owl#",
"@base": "<myurl>/astronomy",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"schema": "https://schema.org/",
"defines": {"@reverse": "rdfs:isDefinedBy"},
}
and then in the same JSON-LD a "defines" to set classes and properties:
"@id": "",
"@type": ['http://www.w3.org/2002/07/owl#Ontology']
"defines" : [{
"@id": <some_url>
},...
]
I can correctly convert this same JSON-LD in the playground, but there is no way of making PyLD to print out in compacted or expanded mode the very same.
compacted = jsonld.compact(body, context)
returns only @id and @type of the ontology but anything else.
dlongley commented
Sorry for the slow response, extremely busy around here. Thanks for the bug report, we will look into this when we can.
dlongley commented
When running this:
import json
from pyld import jsonld
doc = {
"@context": {
"dbpedia": "http://dbpedia.org/ontology/",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"owl": "http://www.w3.org/2002/07/owl#",
"@base": "http://myurl.com/astronomy",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"skos": "http://www.w3.org/2004/02/skos/core#",
"schema": "https://schema.org/",
"defines": {"@reverse": "rdfs:isDefinedBy"}
},
"@id": "",
"@type": ["http://www.w3.org/2002/07/owl#Ontology"],
"defines" : [{"@id": "http://example.com"}]
}
result = jsonld.expand(doc);
print(json.dumps(result, indent=2))
It produces:
[
{
"@reverse": {
"http://www.w3.org/2000/01/rdf-schema#isDefinedBy": [
{
"@id": "http://example.com"
}
]
},
"@id": "http://myurl.com/astronomy",
"@type": [
"http://www.w3.org/2002/07/owl#Ontology"
]
}
]
If I change it to run compaction over the document with the same context:
result = jsonld.compact(doc, doc['@context']);
print(json.dumps(result, indent=2))
I get this:
{
"@context": {
"owl": "http://www.w3.org/2002/07/owl#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"@base": "http://myurl.com/astronomy",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"dbpedia": "http://dbpedia.org/ontology/",
"schema": "https://schema.org/",
"skos": "http://www.w3.org/2004/02/skos/core#",
"defines": {
"@reverse": "rdfs:isDefinedBy"
}
},
"@id": "astronomy",
"@type": "owl:Ontology",
"defines": {
"@id": "http://example.com"
}
}
What code are you running that is dropping the defines
property? Are you including the context in the input?