qudt / qudt-public-repo

QUDT -Quantities, Units, Dimensions and dataTypes - public repository
Other
114 stars 71 forks source link

SWRL with DROOLS (protege) prefix/base error with QuantityKind vocab #819

Closed vChavezB closed 10 months ago

vChavezB commented 10 months ago

For my use case I need to create individuals with SWRL syntax swrlx:makeOWLThing. As mentioned here https://github.com/qudt/qudt-public-repo/issues/62#issuecomment-1823126573, reasoning seems to be working fine with Pellet in Protege but Pellet does not support this syntax. Hence, I am using DROOLS in protege with the SWRL Tab

I tried importing the QuantityKind vocabulary but the owlapi which is called by starting the DROOLS reasoner in the SWRL TAB protege 5.50 gives the error:

org.semanticweb.owlapi.model.OWLRuntimeException: Prefix not registered for prefix name: _:

grafik

If I have more nformation to pinpoint this error I will update the post.

vChavezB commented 10 months ago

I have followed the solution in https://stackoverflow.com/a/72390218 and added the prefix @prefix _: <http://qudt.org/2.1/vocab/dimensionvector#> . to solve this problem.

Now I am getting an out of memory error so I will try to find out more about this

java.lang.OutOfMemoryError: GC overhead limit exceeded

steveraysteveray commented 10 months ago

Try http://qudt.org/2.1/vocab/dimensionvector/ instead of http://qudt.org/2.1/vocab/dimensionvector#

vChavezB commented 10 months ago

Yes sorry, my bad. It should be

@prefix _: <http://qudt.org/2.1/vocab/dimensionvector> .

I think it is now working. It just seems to be too many axioms to compute all the OWL2 RL/RDF rules . If I reduce the set of OWL2 RL rules it is able to finish the reasoning.

vChavezB commented 10 months ago

I tested importing by url http://qudt.org/2.1/schema/qudt in protege and using DROOLS and the reasoning works.

However, when I only import the vocabulary http://qudt.org/2.1/vocab/quantitykind I need to save a copy of the vocabulary and add

@prefix _: <http://qudt.org/2.1/vocab/dimensionvector> .

due to how protege works with the SWRL plugin

vChavezB commented 10 months ago

I have done a more detailed inspection.

When I import the vocabulary from the URL http://qudt.org/2.1/vocab/quantitykind and then save it as a local turtle file in protege the first lines look as follows.

@prefix : <http://www.semanticweb.org/owl/owlapi/turtle#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix mc: <http://www.linkedmodel.org/owl/schema/core#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix soqk: <http://qudt.org/vocab/soqk/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix vaem: <http://www.linkedmodel.org/schema/vaem#> .
@prefix voag: <http://voag.linkedmodel.org/schema/voag#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix constant: <http://qudt.org/vocab/constant/> .
@prefix quantitykind: <http://qudt.org/2.1/vocab/quantitykind#> .
@base <http://qudt.org/2.1/vocab/dimensionvector> .

What I dont get is why the base is changed by protege to http://qudt.org/2.1/vocab/dimensionvector. As I understand by inspecting the original vocabulary when downloaded over the url http://qudt.org/2.1/vocab/quantitykind , the base is defined at the first line of the file as # baseURI: http://qudt.org/2.1/vocab/quantitykind.

grafik

I have changed the base to http://qudt.org/2.1/vocab/quantitykind added the _ prefix (as per the stackoverflow suggestion) and it seems that SWRL tab seems to be working now.

 @prefix : <http://www.semanticweb.org/owl/owlapi/turtle#> .
@prefix _: <http://qudt.org/2.1/vocab/quantitykind> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix mc: <http://www.linkedmodel.org/owl/schema/core#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix soqk: <http://qudt.org/vocab/soqk/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix vaem: <http://www.linkedmodel.org/schema/vaem#> .
@prefix voag: <http://voag.linkedmodel.org/schema/voag#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix constant: <http://qudt.org/vocab/constant/> .
@prefix quantitykind: <http://qudt.org/2.1/vocab/quantitykind#> .
@base <http://qudt.org/2.1/vocab/quantitykind> .
vChavezB commented 10 months ago

Update I get the following reasoner error from the java based Drools engine

java.lang.IllegalArgumentException: could not resolve an OWL data range from a Drools data range with id owl:Thing

This happens when I activate the OWL 2 RL/RDF rule related to semantic vocabulary range (Table 9, scm-rng1).

which is defined as

If Then
T(?p, rdfs:range, ?c1)
T(?c1, rdfs:subClassOf, ?c2)
T(?p, rdfs:range, ?c2)

I will deactivate it for now in DROOLS (SCM_RNG1) and continue testing the vocabulary with DROOLS reasoner and report any other findings.

vChavezB commented 10 months ago

I found out that the BASE IRI is decoded correctly by protege if the annotation property rdfs:isDefinedBy is deleted

i.e. rdfs:isDefinedBy <http://qudt.org/2.1/vocab/quantitykind> ;

This happens in general with any ontology that uses rdfs:isDefinedBy and points to the same ontology IRI in protege.

vChavezB commented 10 months ago

So this is my summary so far

Protege has a problem decoding the BASE IRI (see https://github.com/protegeproject/protege/issues/1181) and setting it in the GUI as I showed in https://github.com/qudt/qudt-public-repo/issues/819#issuecomment-1824864832 when the annotation property rdfs:isDefinedBy is set to the Ontology IRI. Will probably report this to protege.

And the workaround I found is to download the vocabulary from qudt and adding the prefix @prefix _: <http://qudt.org/2.1/vocab/quantitykind/> .

# baseURI: http://qudt.org/2.1/vocab/quantitykind
# imports: http://qudt.org/2.1/schema/facade/qudt
# imports: http://qudt.org/2.1/vocab/dimensionvector
@prefix constant: <http://qudt.org/vocab/constant/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix mc: <http://www.linkedmodel.org/owl/schema/core#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix qkdv: <http://qudt.org/vocab/dimensionvector/> .
@prefix quantitykind: <http://qudt.org/vocab/quantitykind/> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix soqk: <http://qudt.org/vocab/soqk/> .
@prefix unit: <http://qudt.org/vocab/unit/> .
@prefix vaem: <http://www.linkedmodel.org/schema/vaem#> .
@prefix voag: <http://voag.linkedmodel.org/schema/voag#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix _: <http://qudt.org/2.1/vocab/quantitykind/> .

In addition, I think this issue is not that critical. I am importing this vocabulary in another ontology I am developing and it works without the _ prefix. Only the main ontology used for reasoning requires the _ prefix.

So I guess I will leave this just as info in case someone is trying to reason with DROOLS in protege and bumps into this issue :)