Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

circular property ( like rdfs:isDefinedBy or dcterms:isVersionOf ) in .ttl causes owl:imports to overwrite OntologyIRI #1080

Open
SimonBin opened this issue Dec 2, 2022 · 3 comments

Comments

@SimonBin
Copy link

SimonBin commented Dec 2, 2022

@prefix : <https://www.example.org/onto1> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <https://www.example.org/onto1> .

<https://www.example.org/onto1> rdf:type owl:Ontology ;
                                owl:imports <https://www.example.org/onto2> ;
                                rdfs:isDefinedBy <https://www.example.org/onto1> .

###  Generated by the OWL API (version 4.5.22.2022-05-07T21:32:11Z) https://github.com/owlcs/owlapi

expected: https://www.example.org/onto1
result: https://www.example.org/onto2

image

@SimonBin
Copy link
Author

SimonBin commented Dec 2, 2022

same issue with for

<https://www.example.org/onto1> 
     ...
     dcterms:isVersionOf <https://www.example.org/onto1> ;

@SimonBin SimonBin changed the title circular rdfs:isDefinedBy in .ttl causes owl:imports to overwrite OntologyIRI circular property ( like rdfs:isDefinedBy or dcterms:isVersionOf ) in .ttl causes owl:imports to overwrite OntologyIRI Dec 2, 2022
@vChavezB
Copy link

I encountered this error as well. After debugging the owl api it seems this happens because the OWLRDFConsumer ignores any IRI that is used for annotation

// Choose one that isn't the object of an annotation assertion
Set<IRI> candidateIRIs = createSet(ontologyIRIs);
ontology.annotations().forEach(a -> a.getValue().asIRI().ifPresent(iri -> {
if (ontologyIRIs.contains(iri)) {
candidateIRIs.remove(iri);
}
}));

@vChavezB
Copy link

I think this could be solved if the IRI used as subject for the predicate owl:imports is taken into account as possible IRI.

@Override
public void handleTriple(IRI s, IRI p, IRI o) {
consume(s, p, o);
consumer.addOntology(s);
consumer.addOntology(o);

The in the code I mentioned above in OWLRDFConsumer, do not remove it from candidateIRIS if the IRI is used as subject for imports:

TripleHandler

 public void handleTriple(IRI s, IRI p, IRI o) { 
     consume(s, p, o); 
    // add a second parameter to indicate the IRI is a possible ontology IRI 
    // since its the subject
     consumer.addOntology(s,true); 
     consumer.addOntology(o,false); 
 } 

OWLRDFConsumer

    protected void addOntology(IRI iri,bool subjectIRI) {
        if (ontologyIRIs.isEmpty()) {
            firstOntologyIRI = iri;
        }
        ontologyIRIs.add(iri);
        if (subjectIRI) {
           importsubjectIRI.add(iri)
        }
    }
 ontology.annotations().forEach(a -> a.getValue().asIRI().ifPresent(iri -> { 
     if (ontologyIRIs.contains(iri) && importSubjectIRI != iri) { 
         candidateIRIs.remove(iri); 
     } 
 })); 

Disclaimer: I am not familiar with java syntax. Take this suggestion just as an idea but feel free to improve it :)

vChavezB pushed a commit to vChavezB/owlapi that referenced this issue Nov 26, 2023
This fix adds a condition to check wether the parsed IRIs
are used as subject for the owl#imports. This fixes owlcs#1080
for owl api version 4.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
ignazio1977 pushed a commit that referenced this issue Mar 10, 2024
This fix adds a condition to check wether the parsed IRIs
are used as subject for the owl#imports. This fixes #1080
for owl api version 4.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants