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 a value representing the OWLAPI release it is compatible with. Note that the group id for the upstream HermiT is com.hermit-reasoner, while this fork is released under net.sourceforge.owlapi.
This fork exists to allow HermiT users to use newer OWLAPI versions than the ones supported by the original HermiT codebase.
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.
The newest version!
/* 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 static org.semanticweb.owlapi.util.OWLAPIStreamUtils.asList;
import java.util.HashSet;
import java.util.List;
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.*;
/**ReducedABoxOnlyClausification.*/
public class ReducedABoxOnlyClausification implements OWLAxiomVisitor {
protected final Configuration.WarningMonitor m_warningMonitor;
protected final boolean m_ignoreUnsupportedDatatypes;
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;
/**
* @param configuration configuration
* @param allAtomicConcepts allAtomicConcepts
* @param allAtomicObjectRoles allAtomicObjectRoles
* @param allAtomicDataRoles allAtomicDataRoles
*/
public ReducedABoxOnlyClausification(Configuration configuration, Set allAtomicConcepts, Set allAtomicObjectRoles, Set allAtomicDataRoles) {
m_warningMonitor=configuration.warningMonitor;
m_ignoreUnsupportedDatatypes=configuration.ignoreUnsupportedDatatypes;
m_allAtomicConcepts=allAtomicConcepts;
m_allAtomicObjectRoles=allAtomicObjectRoles;
m_allAtomicDataRoles=allAtomicDataRoles;
m_positiveFacts=new HashSet<>();
m_negativeFacts=new HashSet<>();
m_allIndividuals=new HashSet<>();
}
/**
* @param axioms axioms
*/
public void clausify(OWLIndividualAxiom... axioms) {
m_positiveFacts.clear();
m_negativeFacts.clear();
for (OWLIndividualAxiom fact : axioms)
fact.accept(this);
}
/**
* @return positive facts
*/
public Set getPositiveFacts() {
return m_positiveFacts;
}
/**
* @return negative facts
*/
public Set getNegativeFacts() {
return m_negativeFacts;
}
/**
* @return all individuals
*/
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) {
Term first=_first;
Term second=_second;
AtomicRole atomicRole;
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;
}
@Override
public void visit(OWLSameIndividualAxiom object) {
List individuals=asList(object.individuals());
for (int i=0;i individuals=asList(object.individuals());
for (int i=0;i