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

Annotations on DifferentIndividualsAxioms lost #816

Closed
matthewhorridge opened this issue Jan 23, 2019 · 2 comments
Closed

Annotations on DifferentIndividualsAxioms lost #816

matthewhorridge opened this issue Jan 23, 2019 · 2 comments
Labels

Comments

@matthewhorridge
Copy link
Contributor

Small test case below. Produced with 4.5.8. The axiom annotation is not saved in RDF/XML. Note, that it is saved in OWL/XML (I first thought that this was a Protege problem). Haven't tested with 5.x or later.

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.formats.RDFXMLDocumentFormat;
import org.semanticweb.owlapi.model.*;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 2019-01-23
 */
public class DifferentIndividualsAxiom_Annotation_TestCase {

    @Test
    public void shouldSaveDifferentIndividualsAxiomWithAnnotations() throws OWLException {
        OWLOntologyManager man = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = man.createOntology(IRI.create("http://stuff.com/ont"));
        OWLDataFactory dataFactory = man.getOWLDataFactory();

        OWLDifferentIndividualsAxiom ax = dataFactory.getOWLDifferentIndividualsAxiom(
                dataFactory.getOWLNamedIndividual(IRI.create("http://stuff.com/ont/a")),
                dataFactory.getOWLNamedIndividual(IRI.create("http://stuff.com/ont/b"))
        );
        OWLAnnotation anno = dataFactory.getOWLAnnotation(dataFactory.getRDFSLabel(), dataFactory.getOWLLiteral("Hello"));
        OWLAxiom annotatedAx = ax.getAnnotatedAxiom(Collections.singleton(anno));

        man.addAxiom(ontology, annotatedAx);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        man.saveOntology(ontology, new RDFXMLDocumentFormat(), byteArrayOutputStream);

        OWLOntologyManager man2 = OWLManager.createOWLOntologyManager();
        OWLOntology reloadedOntology = man2.loadOntologyFromOntologyDocument(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));

        assertThat(reloadedOntology.containsAxiom(annotatedAx), is(true));
    }
}
@ignazio1977
Copy link
Contributor

Nasty one. Bug in rendering, bug in parsing, and the bug depends on how many individuals are in the axiom. Also, similar bug exists on OWLSameIndividuals.
I've fixed Different individuals for three and above for all syntaxes. Manchester syntax with two elements is still broken. Same individuals needs fixing.

@ignazio1977 ignazio1977 changed the title Annotations on DifferentIndividualsAxioms are not saved in RDF/XML Annotations on DifferentIndividualsAxioms lost Jan 30, 2019
@ignazio1977
Copy link
Contributor

Bugs uncovered in RDF/XML and Manchester Syntax, for Different and Same individuals. Miraculously, part of the fix was deleting code. Nasty ones, 'm surprised we haven't met these before.

ignazio1977 added a commit that referenced this issue Jan 30, 2019
Errors and missing rendering/parsing for annotations on three-argument
different/same individuals. Missng roundtrip tests.
ignazio1977 added a commit that referenced this issue Feb 9, 2019
Errors and missing rendering/parsing for annotations on three-argument
different/same individuals. Missng roundtrip tests.
ignazio1977 added a commit that referenced this issue Feb 17, 2019
Errors and missing rendering/parsing for annotations on three-argument
different/same individuals. Missng roundtrip tests.
ignazio1977 added a commit that referenced this issue Sep 24, 2022
Errors and missing rendering/parsing for annotations on three-argument
different/same individuals. Missng roundtrip tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants