Closed oising closed 3 years ago
Here's my python script (at first I used the python reasoner, then tried reasonable
to make sure)
g = Graph(load_brick=False)
g.load_file("apartment.ttl")
print(f"Asserted graph has {len(g)} triples")
g.expand(profile="owlrl", backend="reasonable")
print(f"Inferred graph has {len(g)} triples")
valid, _, report = g.validate(default_brick_shapes=True)
if not valid:
print(report)
exit(1)
else:
print("valid")
print(g.serialize(format="turtle", destination="apartment-inferred.ttl"))
Ok, so I guessed maybe the reasoner requires load_brick=True
but now it performs reasoning over the entire Brick schema as well as the apartment. And I end up with garbage/anonymous types in the output:
apt:my_apartment a _:f274a078263c444a0ba67e94ad7ce2e65b4,
_:f274a078263c444a0ba67e94ad7ce2e65b5,
_:ub1bL14227C21,
owl:Thing,
brick:Apartment,
brick:Class,
brick:Location,
brick:Space ;
owl:sameAs apt:my_apartment ;
brick:hasPart apt:bedroom,
apt:kitchen,
apt:living_room ;
brick:hasTag tag:Location,
tag:Space .
apt:thermostat1 a _:f274a078263c444a0ba67e94ad7ce2e65b10,
_:f274a078263c444a0ba67e94ad7ce2e65b1281,
_:ub1bL14452C21,
_:ub1bL6865C21,
_:ub1bL6865C60,
owl:Thing,
brick:Class,
brick:Equipment,
brick:HVAC_Equipment,
brick:Thermostat ;
owl:sameAs apt:thermostat1 ;
brick:hasPart apt:setpoint1 ;
brick:hasTag tag:Equipment,
tag:HVAC,
tag:Thermostat ;
brick:isPartOf apt:thermostat_zone .
This is not as clean as I thought it would be :/
But the point still remains -- why does it add redundant owl:Sameas predicates?
Hi @oising; sorry I missed this issue. GitHub has decided it is not delivering notifications to me anymore.
I will need to spend a little time digging into this to figure out what is going on, but can you provide some context? Which reasoner are you using: OWL-RL (default), Allegrograph (if you have docker
installed), or reasonable (if you have reasonable
installed)?
The anonymous types in the output are an unfortunate consequence of a couple implementation details in Brick. There are some long-term musings to reduce this output by moving some elements of Brick to SHACL rather than OWL (not likely to happen in the coming months), but perhaps some useful functionality for brickschema
to provide is a filtering out of blank nodes that are leafs in the model.
The redundant owl:sameAs
predicates are technically part of the OWL-RL spec. I definitely agree that the reflexive properties of OWL are noisy and redundant, but many reasoning implementations still make them explicit. I think OWL-RL has an option to disable these kinds of "axiomatic" triples (https://owl-rl.readthedocs.io/en/latest/owlrl.html) but this would require further investigation.
Closing for now, but let me know if any of the above issues come up again
I noticed that the OWLRS expand adds
owl:sameAs
axioms for every node, targeting self?If we take the example
apartment.ttl
from brick (slightly modified to add a setpoint and which has 23 asserted triples in total), and run inference, I end up with 150 triples, the majority (entirety even?) of which are:a owl:sameAs :a
-- well, obviously :DAlso, none of the inverse relationships are inferred? e.g. all of the
brick:isPartOf
references... I would have expected inferrence to have added thebrick:hasPart
axioms? Isn't that the whole point of this?apartment input:
Inferred output: