org.semanticweb.HermiT.structural.ReducedABoxOnlyClausification Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.semanticweb.hermit Show documentation
Show all versions of org.semanticweb.hermit Show documentation
HermiT is reasoner for ontologies written using the Web
Ontology Language (OWL). Given an OWL file, HermiT can determine whether or
not the ontology is consistent, identify subsumption relationships between
classes, and much more.
This is the maven build of HermiT and is designed for people who wish to use
HermiT from within the OWL API. It is now versioned in the main HermiT
version repository, although not officially supported by the HermiT
developers.
The version number of this package is a composite of the HermiT version and
an value representing releases of this packaged version. So, 1.3.7.1 is the
first release of the mavenized version of HermiT based on the 1.3.7 release
of HermiT.
This package includes the Jautomata library
(http://jautomata.sourceforge.net/), and builds with it directly. This
library appears to be no longer under active development, and so a "fork"
seems appropriate. No development is intended or anticipated on this code
base.
/* Copyright 2008, 2009, 2010 by the Oxford University Computing Laboratory
This file is part of HermiT.
HermiT is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
HermiT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with HermiT. If not, see .
*/
package org.semanticweb.HermiT.structural;
import java.util.HashSet;
import java.util.Set;
import org.semanticweb.HermiT.Configuration;
import org.semanticweb.HermiT.Prefixes;
import org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException;
import org.semanticweb.HermiT.model.Atom;
import org.semanticweb.HermiT.model.AtomicConcept;
import org.semanticweb.HermiT.model.AtomicRole;
import org.semanticweb.HermiT.model.Constant;
import org.semanticweb.HermiT.model.Equality;
import org.semanticweb.HermiT.model.Individual;
import org.semanticweb.HermiT.model.Inequality;
import org.semanticweb.HermiT.model.Term;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataFactory;
import org.semanticweb.owlapi.model.OWLDataProperty;
import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLDataPropertyExpression;
import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLIndividualAxiom;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectComplementOf;
import org.semanticweb.owlapi.model.OWLObjectHasSelf;
import org.semanticweb.owlapi.model.OWLObjectHasValue;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
import org.semanticweb.owlapi.model.OWLSameIndividualAxiom;
import org.semanticweb.owlapi.util.OWLAxiomVisitorAdapter;
public class ReducedABoxOnlyClausification extends OWLAxiomVisitorAdapter {
protected final Configuration.WarningMonitor m_warningMonitor;
protected final boolean m_ignoreUnsupportedDatatypes;
protected final OWLDataFactory m_factory;
protected final Set m_allAtomicConcepts;
protected final Set m_allAtomicObjectRoles;
protected final Set m_allAtomicDataRoles;
protected final Set m_positiveFacts;
protected final Set m_negativeFacts;
protected final Set m_allIndividuals;
public ReducedABoxOnlyClausification(Configuration configuration, OWLDataFactory factory, Set allAtomicConcepts, Set allAtomicObjectRoles, Set allAtomicDataRoles) {
m_warningMonitor=configuration.warningMonitor;
m_ignoreUnsupportedDatatypes=configuration.ignoreUnsupportedDatatypes;
m_factory=factory;
m_allAtomicConcepts=allAtomicConcepts;
m_allAtomicObjectRoles=allAtomicObjectRoles;
m_allAtomicDataRoles=allAtomicDataRoles;
m_positiveFacts=new HashSet();
m_negativeFacts=new HashSet();
m_allIndividuals=new HashSet();
}
public void clausify(OWLIndividualAxiom... axioms) {
m_positiveFacts.clear();
m_negativeFacts.clear();
for (OWLIndividualAxiom fact : axioms)
fact.accept(this);
}
public Set getPositiveFacts() {
return m_positiveFacts;
}
public Set getNegativeFacts() {
return m_negativeFacts;
}
public Set getAllIndividuals() {
return m_allIndividuals;
}
protected Atom getConceptAtom(OWLClass cls, Term term) {
AtomicConcept atomicConcept=AtomicConcept.create(cls.getIRI().toString());
if (m_allAtomicConcepts.contains(atomicConcept))
return Atom.create(atomicConcept,term);
else
throw new IllegalArgumentException("Internal error: fresh classes in class assertions are not compatible with incremental ABox loading!");
}
protected Atom getRoleAtom(OWLObjectPropertyExpression objectProperty,Term first,Term second) {
AtomicRole atomicRole;
objectProperty=objectProperty.getSimplified();
if (objectProperty.isAnonymous()) {
OWLObjectProperty internalObjectProperty=objectProperty.getNamedProperty();
atomicRole=AtomicRole.create(internalObjectProperty.getIRI().toString());
Term tmp=first;
first=second;
second=tmp;
}
else
atomicRole=AtomicRole.create(objectProperty.asOWLObjectProperty().getIRI().toString());
if (m_allAtomicObjectRoles.contains(atomicRole))
return Atom.create(atomicRole,first,second);
else
throw new IllegalArgumentException("Internal error: fresh properties in property assertions are not compatible with incremental ABox loading!");
}
protected Atom getRoleAtom(OWLDataPropertyExpression dataProperty,Term first,Term second) {
AtomicRole atomicRole;
if (dataProperty instanceof OWLDataProperty)
atomicRole=AtomicRole.create(((OWLDataProperty)dataProperty).getIRI().toString());
else
throw new IllegalStateException("Internal error: unsupported type of data property!");
if (m_allAtomicDataRoles.contains(atomicRole))
return Atom.create(atomicRole,first,second);
else
throw new IllegalArgumentException("Internal error: fresh properties in property assertions are not compatible with incremental ABox loading!");
}
protected Individual getIndividual(OWLIndividual individual) {
Individual ind;
if (individual.isAnonymous())
ind=Individual.createAnonymous(individual.asOWLAnonymousIndividual().getID().toString());
else
ind=Individual.create(individual.asOWLNamedIndividual().getIRI().toString());
m_allIndividuals.add(ind);
return ind;
}
public void visit(OWLSameIndividualAxiom object) {
OWLIndividual[] individuals=new OWLIndividual[object.getIndividuals().size()];
object.getIndividuals().toArray(individuals);
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy