Re: owl-diff question

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: owl-diff question

Elena
Hello!

Seems like I've sent the question to a wrong email address. Re-sending here:

Here is my question:

I'm trying to calculate differences between 2 ontologies and using similar code to the code that protege owl-diff plugin is using:

OWLOntologyManager manager1 = OWLManager.createOWLOntologyManager();
OWLOntologyLoaderConfiguration config = manager1
           .getOntologyLoaderConfiguration();
manager1.setOntologyLoaderConfiguration(config);
OWLOntology ontology1 = 
manager1.loadOntologyFromOntologyDocument(baseline);
OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();
    manager2.setOntologyLoaderConfiguration(config);
OWLOntology ontology2 = 
    manager2.loadOntologyFromOntologyDocument(altered);
logger.info("Running diff");
Engine e = new Engine(ontology1, ontology2);
e.setAlignmentAlgorithms(new MatchByCode(), new MatchById());
e.setPresentationAlgorithms(new IdentifyRenameOperation(), new 
     IdentifyMergedConcepts(), new IdentifyRetiredConcepts());
e.phase1();
logger.info("Calculating presentation");
e.phase2();

I'm testing how changing different properties affect difference calculation. No matter what I change (for example I change rdfs:label) when I run difference I can only get "Added" or "Deleted" axiom, never "Annotation changed", as protege owl-diff plugin shows.

Changes changes = e.getChanges();

Collection<EntityBasedDiff> ediffs = changes.getEntityBasedDiffs();
for (EntityBasedDiff ediff : ediffs) {
     if (ediff.getDiffType() == DiffType.MODIFIED) {
         matches = new ArrayList<MatchedAxiom>(ediff.getAxiomMatches());

         OWLAxiom axiom;
         for (int i = 0; i < size; i++) {
             MatchedAxiom match = matches.get(i);

             logger.info("desc: " + match.getDescription().toString());
             axiom = match.getSourceAxiom();
             logger.info("source: " + (axiom == null ? "NULL" : axiom.toString()));
             axiom = match.getTargetAxiom();
             logger.info("target: " + (axiom == null ? "NULL" : axiom.toString()));

        }
    }
}

When I run the code above, in the situations when ontology 1 has label:"label1" and ontology 2 has label:"label2", I'd expect match.getDescription().toString() to be "Annotation changed" (protege shows correctly), but instead I get "Add" for label:"label1" and "Delete" for label:"label2". I use

// https://mvnrepository.com/artifact/edu.stanford.protege/owl-diff
compile group: 'edu.stanford.protege', name: 'owl-diff', version: '6.0.2'

I guess I need to use different algorithms? Or something else I'm doing wrong? Thank you!


On Wed, Dec 27, 2017 at 3:05 AM, Elena <[hidden email]> wrote:
Hello!

I'm not sure if this is the way to use your mailing list, please correct me if I'm wrong.

Here is my question:

I'm trying to calculate differences between 2 ontologies and using similar code to the code that protege owl-diff plugin is using:

OWLOntologyManager manager1 = OWLManager.createOWLOntologyManager();
OWLOntologyLoaderConfiguration config = manager1
           .getOntologyLoaderConfiguration();
manager1.setOntologyLoaderConfiguration(config);
OWLOntology ontology1 = 
manager1.loadOntologyFromOntologyDocument(baseline);
OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();
    manager2.setOntologyLoaderConfiguration(config);
OWLOntology ontology2 = 
    manager2.loadOntologyFromOntologyDocument(altered);
logger.info("Running diff");
Engine e = new Engine(ontology1, ontology2);
e.setAlignmentAlgorithms(new MatchByCode(), new MatchById());
e.setPresentationAlgorithms(new IdentifyRenameOperation(), new 
     IdentifyMergedConcepts(), new IdentifyRetiredConcepts());
e.phase1();
logger.info("Calculating presentation");
e.phase2();

I'm testing how changing different properties affect difference calculation. No matter what I change (for example I change rdfs:label) when I run difference I can only get "Added" or "Deleted" axiom, never "Annotation changed", as protege owl-diff plugin shows.

Changes changes = e.getChanges();

Collection<EntityBasedDiff> ediffs = changes.getEntityBasedDiffs();
for (EntityBasedDiff ediff : ediffs) {
     if (ediff.getDiffType() == DiffType.MODIFIED) {
         matches = new ArrayList<MatchedAxiom>(ediff.getAxiomMatches());

         OWLAxiom axiom;
         for (int i = 0; i < size; i++) {
             MatchedAxiom match = matches.get(i);

             logger.info("desc: " + match.getDescription().toString());
             axiom = match.getSourceAxiom();
             logger.info("source: " + (axiom == null ? "NULL" : axiom.toString()));
             axiom = match.getTargetAxiom();
             logger.info("target: " + (axiom == null ? "NULL" : axiom.toString()));

        }
    }
}

When I run the code above, in the situations when ontology 1 has label:"label1" and ontology 2 has label:"label2", I'd expect match.getDescription().toString() to be "Annotation changed" (protege shows correctly), but instead I get "Add" for label:"label1" and "Delete" for label:"label2". I use

// https://mvnrepository.com/artifact/edu.stanford.protege/owl-diff
compile group: 'edu.stanford.protege', name: 'owl-diff', version: '6.0.2'

I guess I need to use different algorithms? Or something else I'm doing wrong? Thank you!



_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev