Search in sources :

Example 1 with ProtegeOWLReasonerInfo

use of org.protege.editor.owl.model.inference.ProtegeOWLReasonerInfo in project snow-owl by b2ihealthcare.

the class ReasonerTaxonomyInferrer method createReasoner.

private static OWLReasoner createReasoner(final String reasonerId, final OWLOntology owlOntology) {
    final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
    final IExtension[] extensions = extensionPoint.getExtensions();
    for (final IExtension extension : extensions) {
        final IConfigurationElement[] configurationElements = extension.getConfigurationElements();
        final String extensionId = extension.getUniqueIdentifier();
        if (reasonerId.equals(extensionId)) {
            final Optional<IConfigurationElement> classElement = Arrays.asList(configurationElements).stream().filter(e -> CLASS_ELEMENT.equals(e.getName())).findFirst();
            if (!classElement.isPresent()) {
                throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId);
            }
            final ProtegeOWLReasonerInfo reasonerInfo;
            try {
                reasonerInfo = (ProtegeOWLReasonerInfo) classElement.get().createExecutableExtension(VALUE_ATTRIBUTE);
                reasonerInfo.initialise();
            } catch (final Exception e) {
                throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId, e);
            }
            final OWLReasonerFactory reasonerFactory = reasonerInfo.getReasonerFactory();
            final OWLReasonerConfiguration reasonerConfiguration = reasonerInfo.getConfiguration(new LoggingProgressMonitor(LOGGER));
            return reasonerFactory.createNonBufferingReasoner(owlOntology, reasonerConfiguration);
        }
    }
    throw new ReasonerApiException("Couldn't create reasoner info instance for extension '%s'.", reasonerId);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) java.util(java.util) Stopwatch(com.google.common.base.Stopwatch) LoggerFactory(org.slf4j.LoggerFactory) RateLimiter(com.google.common.util.concurrent.RateLimiter) com.b2international.snowowl.snomed.datastore.index.taxonomy(com.b2international.snowowl.snomed.datastore.index.taxonomy) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) PrimitiveSets(com.b2international.collections.PrimitiveSets) SnomedRequests(com.b2international.snowowl.snomed.datastore.request.SnomedRequests) LongSet(com.b2international.collections.longs.LongSet) LongSets(com.b2international.commons.collect.LongSets) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ProtegeOWLReasonerInfo(org.protege.editor.owl.model.inference.ProtegeOWLReasonerInfo) org.semanticweb.owlapi.reasoner(org.semanticweb.owlapi.reasoner) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) PrimitiveLists(com.b2international.collections.PrimitiveLists) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) DelegateOntology(com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntology) SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) IExtension(org.eclipse.core.runtime.IExtension) Logger(org.slf4j.Logger) RevisionDocument(com.b2international.snowowl.core.repository.RevisionDocument) LongList(com.b2international.collections.longs.LongList) Ordering(com.google.common.collect.Ordering) OWLClassNodeSet(org.semanticweb.owlapi.reasoner.impl.OWLClassNodeSet) Sort(com.b2international.snowowl.core.request.SearchResourceRequest.Sort) Platform(org.eclipse.core.runtime.Platform) BranchContext(com.b2international.snowowl.core.domain.BranchContext) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException) OWLClass(org.semanticweb.owlapi.model.OWLClass) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ReasonerApiException(com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) ProtegeOWLReasonerInfo(org.protege.editor.owl.model.inference.ProtegeOWLReasonerInfo)

Aggregations

PrimitiveLists (com.b2international.collections.PrimitiveLists)1 PrimitiveSets (com.b2international.collections.PrimitiveSets)1 LongList (com.b2international.collections.longs.LongList)1 LongSet (com.b2international.collections.longs.LongSet)1 LongSets (com.b2international.commons.collect.LongSets)1 BranchContext (com.b2international.snowowl.core.domain.BranchContext)1 RevisionDocument (com.b2international.snowowl.core.repository.RevisionDocument)1 Sort (com.b2international.snowowl.core.request.SearchResourceRequest.Sort)1 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)1 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)1 com.b2international.snowowl.snomed.datastore.index.taxonomy (com.b2international.snowowl.snomed.datastore.index.taxonomy)1 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)1 ReasonerApiException (com.b2international.snowowl.snomed.reasoner.exceptions.ReasonerApiException)1 DelegateOntology (com.b2international.snowowl.snomed.reasoner.ontology.DelegateOntology)1 Stopwatch (com.google.common.base.Stopwatch)1 Ordering (com.google.common.collect.Ordering)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 RateLimiter (com.google.common.util.concurrent.RateLimiter)1 java.util (java.util)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1