org.semanticweb.elk.reasoner.taxonomy.IndividualTaxonomy Maven / Gradle / Ivy
Show all versions of elk-reasoner Show documentation
/*
* #%L
* ELK Reasoner
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2011 - 2016 Department of Computer Science, University of Oxford
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.semanticweb.elk.reasoner.taxonomy;
import java.util.Set;
import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkEntity;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.owl.predefined.PredefinedElkClassFactory;
import org.semanticweb.elk.reasoner.taxonomy.impl.AbstractDistinctBottomTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.impl.AbstractUpdateableGenericInstanceTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.impl.BottomGenericTypeNode;
import org.semanticweb.elk.reasoner.taxonomy.impl.ConcurrentNodeStore;
import org.semanticweb.elk.reasoner.taxonomy.impl.IndividualNode;
import org.semanticweb.elk.reasoner.taxonomy.impl.NonBottomGenericTypeNode;
import org.semanticweb.elk.reasoner.taxonomy.model.ComparatorKeyProvider;
import org.semanticweb.elk.reasoner.taxonomy.model.GenericInstanceNode;
import org.semanticweb.elk.reasoner.taxonomy.model.GenericTypeNode;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.model.TaxonomyNodeFactory;
/**
* Instance taxonomy that is suitable for concurrent processing. Taxonomy
* objects are only constructed for consistent ontologies, and some consequences
* of this are hardcoded here.
*
* This class extends an implementation of a class taxonomy, so it may be
* suboptimal for use with ontologies with no individuals.
*
* @author Peter Skocovsky
*/
public class IndividualTaxonomy
extends AbstractUpdateableGenericInstanceTaxonomy<
ElkClass,
ElkNamedIndividual,
GenericTypeNode.Projection,
GenericInstanceNode.Projection,
NonBottomGenericTypeNode.Projection,
IndividualNode.Projection2
> {
private final GenericTypeNode.Projection bottomNode_;
public IndividualTaxonomy(final PredefinedElkClassFactory elkFactory,
final ComparatorKeyProvider classKeyProvider,
final ComparatorKeyProvider instanceKeyProvider) {
super(
new ConcurrentNodeStore<
ElkClass,
NonBottomGenericTypeNode.Projection
>(classKeyProvider),
new TaxonomyNodeFactory<
ElkClass,
NonBottomGenericTypeNode.Projection,
AbstractDistinctBottomTaxonomy<
ElkClass,
GenericTypeNode.Projection,
NonBottomGenericTypeNode.Projection
>
>() {
@Override
public NonBottomGenericTypeNode.Projection createNode(
final Iterable extends ElkClass> members, final int size,
final AbstractDistinctBottomTaxonomy<
ElkClass,
GenericTypeNode.Projection,
NonBottomGenericTypeNode.Projection
> taxonomy) {
return new NonBottomGenericTypeNode.Projection(
taxonomy, members, size);
}
},
new ConcurrentNodeStore<
ElkNamedIndividual,
IndividualNode.Projection2
>(instanceKeyProvider),
new TaxonomyNodeFactory<
ElkNamedIndividual,
IndividualNode.Projection2,
InstanceTaxonomy
>() {
@Override
public IndividualNode.Projection2 createNode(
final Iterable extends ElkNamedIndividual> members, final int size,
final InstanceTaxonomy taxonomy) {
return new IndividualNode.Projection2(
taxonomy, members, size);
}
},
elkFactory.getOwlThing());
this.bottomNode_ = new BottomGenericTypeNode.Projection(
this, elkFactory.getOwlNothing());
}
@Override
public GenericTypeNode.Projection getBottomNode() {
return bottomNode_;
}
@Override
protected Set extends GenericTypeNode.Projection> toTaxonomyNodes(
final Set extends NonBottomGenericTypeNode.Projection> nodes) {
return nodes;
}
}