discovering identical classes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

discovering identical classes

Wynne, Robert (NIH/NLM/LHC) [C]

Hi all,

 

[Apologies for cross-posting; not sure if this a Protégé/owlapi/ELK question.]

 

I am working with a pre-existing ontology in EL++ with multiple defined classes.  I used the owlapi to add more classes in the same namespace with definitions equivalent to one or more of the existing defined classes.  After running the ELK reasoner, and switching to the Inferred hierarchy view, these identical classes are properly displayed such as ‘A B’. [1]

 

How would I use Protégé, or the owlapi, to report these?  I have tried the following..

 

owlapi with the ELK 0.50 reasoner:

 

                   for( OWLClass cls : reasoner.getSubClasses(rootClass, false).entities().collect((Collectors.toSet())) ) {

                             for( OWLClass eqClass : reasoner.getEquivalentClasses(cls).getEntitiesMinus(cls) )  {  //without minus this only seems to return cls

                                      System.out.println(eqClass.getIRI().toString() + " equivalent to " +  cls.getIRI().toString());

                             }

                   }

 

Also (in hopes of generating an inferred OWL to work with):

 

                   ArrayList<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();

                   gens.add(new InferredSubClassAxiomGenerator());

                   gens.add(new InferredEquivalentClassAxiomGenerator());

 

                   System.out.println("Instantiating InferredOntologyGenerator..");

                   InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);

 

                   System.out.println("Filling new ontology with inferred axioms..");                          

                   iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);

                            

                   System.out.println("Saving new ontology with inferred axioms..");                         

                   outputOntologyManager.saveOntology(infOnt,      IRI.create((new File("./RxNorm2Snomed_DRAFT_Inf.owl").toURI())));

 

(Though this resulted in an ontology less than half the size of the unmodified original.)

 

I have traced through some Protégé classes, such as InferredOWLClassHierarchyProvider.  Method getEquivalents seems to make the same call, though does this use ELK or the included StructuralReasoner?  Would I need to somehow refresh ELK after the new classes are added?

 

[1]

 

Thanks!

Rob

 


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: discovering identical classes

Wynne, Robert (NIH/NLM/LHC) [C]

The following seems to work. 

 

                   reasoner.dispose();

                   reasonerFactory = new ElkReasonerFactory();

                   reasoner = reasonerFactory.createReasoner(ontology);  

 

Now left wondering if there any configurations to the reasoner which would allow it to stay updated as the ontology is modified?

 

(I’ve moved this inquiry to the owlapi github: https://github.com/owlcs/owlapi/issues/819)

 

Rob

 

From: Wynne, Robert (NIH/NLM/LHC) [C]
Sent: Wednesday, February 6, 2019 12:58 PM
To: User support for WebProtege and Protege Desktop ([hidden email]) <[hidden email]>; '[hidden email]' <[hidden email]>
Subject: discovering identical classes

 

Hi all,

 

[Apologies for cross-posting; not sure if this a Protégé/owlapi/ELK question.]

 

I am working with a pre-existing ontology in EL++ with multiple defined classes.  I used the owlapi to add more classes in the same namespace with definitions equivalent to one or more of the existing defined classes.  After running the ELK reasoner, and switching to the Inferred hierarchy view, these identical classes are properly displayed such as ‘A B’. [1]

 

How would I use Protégé, or the owlapi, to report these?  I have tried the following..

 

owlapi with the ELK 0.50 reasoner:

 

                   for( OWLClass cls : reasoner.getSubClasses(rootClass, false).entities().collect((Collectors.toSet())) ) {

                             for( OWLClass eqClass : reasoner.getEquivalentClasses(cls).getEntitiesMinus(cls) )  {  //without minus this only seems to return cls

                                      System.out.println(eqClass.getIRI().toString() + " equivalent to " +  cls.getIRI().toString());

                             }

                   }

 

Also (in hopes of generating an inferred OWL to work with):

 

                   ArrayList<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();

                   gens.add(new InferredSubClassAxiomGenerator());

                   gens.add(new InferredEquivalentClassAxiomGenerator());

 

                   System.out.println("Instantiating InferredOntologyGenerator..");

                   InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);

 

                   System.out.println("Filling new ontology with inferred axioms..");                          

                   iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);

                            

                   System.out.println("Saving new ontology with inferred axioms..");                         

                   outputOntologyManager.saveOntology(infOnt,      IRI.create((new File("./RxNorm2Snomed_DRAFT_Inf.owl").toURI())));

 

(Though this resulted in an ontology less than half the size of the unmodified original.)

 

I have traced through some Protégé classes, such as InferredOWLClassHierarchyProvider.  Method getEquivalents seems to make the same call, though does this use ELK or the included StructuralReasoner?  Would I need to somehow refresh ELK after the new classes are added?

 

[1]

 

Thanks!

Rob

 


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