本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntology.getSubClassAxiomsForSubClass方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntology.getSubClassAxiomsForSubClass方法的具體用法?Java OWLOntology.getSubClassAxiomsForSubClass怎麽用?Java OWLOntology.getSubClassAxiomsForSubClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntology
的用法示例。
在下文中一共展示了OWLOntology.getSubClassAxiomsForSubClass方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadPrimitiveDefinition
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
private OWLClassExpression loadPrimitiveDefinition(OWLClass cls) {
Set<OWLClassExpression> allDefinitions = new HashSet<>();
for (OWLOntology ontology : ontologies) {
for (OWLSubClassOfAxiom definingAxiom : ontology.getSubClassAxiomsForSubClass(cls)) {
OWLClassExpression superClass = definingAxiom.getSuperClass();
if (!superClass.equals(top)) {
// do not expand definitions beyond top
allDefinitions.add(definingAxiom.getSuperClass());
}
}
}
if (allDefinitions.size() < 1) {
return null;
}
if (allDefinitions.size() > 1) {
return OWLManager.getOWLDataFactory().getOWLObjectIntersectionOf(allDefinitions);
}
return allDefinitions.iterator().next();
}
示例2: getNamedDirectSuperClasses
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
private Set<OWLClass> getNamedDirectSuperClasses(OWLClass current, OWLOntology model) {
final Set<OWLClass> dedup = new HashSet<OWLClass>();
Set<OWLOntology> closure = model.getImportsClosure();
for (OWLOntology ont : closure) {
for(OWLSubClassOfAxiom ax : ont.getSubClassAxiomsForSubClass(current)) {
ax.getSuperClass().accept(new OWLClassExpressionVisitorAdapter(){
@Override
public void visit(OWLClass cls) {
if (cls.isBuiltIn() == false) {
dedup.add(cls);
}
}
});
}
}
return dedup;
}
示例3: visit
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Override
public void visit(OWLClass desc) {
if (!processedClasses.contains(desc)) {
// If we are processing inherited restrictions then we
// recursively visit named supers. Note that we need to keep
// track of the classes that we have processed so that we don't
// get caught out by cycles in the taxonomy
processedClasses.add(desc);
for (final OWLOntology ontology : ontologies) {
for (final OWLSubClassOfAxiom ax : ontology
.getSubClassAxiomsForSubClass(desc)) {
ax.getSuperClass().accept(this);
}
}
}
}
示例4: isEdgeEntailed
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public boolean isEdgeEntailed(OWLEdge e, OWLOntology currentOntology, OWLReasoner reasoner) {
OWLOntologyManager m = getManager();
Set<OWLSubClassOfAxiom> scas = currentOntology.getSubClassAxiomsForSubClass(e.c);
Set<OWLSubClassOfAxiom> rmAxioms = new HashSet<OWLSubClassOfAxiom>();
for (OWLSubClassOfAxiom sca : scas) {
if (sca.getSuperClass().equals(e.p)) {
LOG.info("REMOVING: "+sca);
rmAxioms.add(sca);
}
}
boolean isEdgeAsserted = rmAxioms.size() > 0;
if (isEdgeAsserted) {
m.removeAxioms(currentOntology, rmAxioms);
reasoner.flush();
}
boolean isEntailed;
isEntailed = reasoner.getSuperClasses(e.c, false).containsEntity(e.p);
if (isEdgeAsserted) {
m.addAxioms(currentOntology, rmAxioms);
reasoner.flush();
}
return isEntailed;
}
示例5: hasLinks
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Check that the given subClass does not already has a matching subClass axiom.
*
* @param subCls
* @param p
* @param superCls
* @return existing axiom or null
*/
private OWLAxiom hasLinks(OWLClass subCls, OWLObjectProperty p, OWLClass superCls) {
for(OWLOntology o : allOntologies) {
Set<OWLSubClassOfAxiom> subClsAxioms = o.getSubClassAxiomsForSubClass(subCls);
for (OWLSubClassOfAxiom subClsAxiom : subClsAxioms) {
OWLClassExpression ce = subClsAxiom.getSuperClass();
if (ce instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) ce;
OWLObjectPropertyExpression property = someValuesFrom.getProperty();
if (p.equals(property)) {
OWLClassExpression filler = someValuesFrom.getFiller();
if (superCls.equals(filler)) {
return subClsAxiom;
}
}
}
}
}
return null;
}
示例6: getAdjacent
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
@Override
public List<OWLClass> getAdjacent(OWLClass cls) {
Set<OWLClass> results = new HashSet<OWLClass>();
Set<OWLOntology> allOntologies = graph.getAllOntologies();
for (OWLOntology owlOntology : allOntologies) {
Set<OWLSubClassOfAxiom> axioms = owlOntology.getSubClassAxiomsForSubClass(cls);
if (axioms != null && !axioms.isEmpty()) {
for (OWLSubClassOfAxiom axiom : axioms) {
OWLClassExpression expression = axiom.getSuperClass();
if (!expression.isAnonymous()) {
results.add(expression.asOWLClass());
}
}
}
}
if (results.isEmpty()) {
return Collections.emptyList();
}
return new ArrayList<OWLClass>(results);
}
示例7: checkTaxon
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Check to make sure that this taxon has the required properties.
*
* <ul>
* <li>label exists</li>
* <li>exactly one superClass</li>
* </ul>
*
* @param ontology the current ontology
* @param taxon the subject
* @return true if the check succeeds, otherwise false.
*/
public static Boolean checkTaxon(OWLOntology ontology,
OWLClass taxon) {
String id = getTaxonID(taxon);
String label = getFirstLiteral(ontology, taxon,
"rdfs:label");
if (label == null || label.trim().length() == 0) {
logger.error("No SCIENTIFIC NAME provided for " + id);
return false;
}
Set<OWLSubClassOfAxiom> axioms = ontology.getSubClassAxiomsForSubClass(taxon);
Set<OWLClassExpression> superClasses = new HashSet<>();
for(OWLSubClassOfAxiom ax : axioms) {
superClasses.add(ax.getSuperClass());
}
if (superClasses.size() < 1 && !id.equals("1")) {
logger.error("No PARENT ID for " + id);
return false;
} else if (superClasses.size() > 1) {
logger.error("Multiple PARENT IDs for " + id);
return false;
}
return true;
}
示例8: updateRedundant
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Update the set of redundant axioms for the given {@link OWLClass} cls.
*
* @param cls
* @param ontology
* @param redundantAxioms
* @param reasoner
* @param dataFactory
*/
protected static void updateRedundant(OWLClass cls, OWLOntology ontology, Set<OWLAxiom> redundantAxioms,
OWLReasoner reasoner, OWLDataFactory dataFactory)
{
final OWLClass owlThing = dataFactory.getOWLThing();
// get all direct super classes
final Set<OWLClass> direct = reasoner.getSuperClasses(cls, true).getFlattened();
direct.remove(owlThing);
// get all super classes (includes direct ones)
final Set<OWLClass> indirect = reasoner.getSuperClasses(cls, false).getFlattened();
indirect.remove(owlThing);
// remove direct super classes from all -> redundant super classes
indirect.removeAll(direct);
// rename
final Set<OWLClass> redundant = indirect;
// filter
// subclass of axioms, which have a super class in the redundant set
Set<OWLSubClassOfAxiom> axioms = ontology.getSubClassAxiomsForSubClass(cls);
for (OWLSubClassOfAxiom subClassOfAxiom : axioms) {
OWLClassExpression ce = subClassOfAxiom.getSuperClass();
if (!ce.isAnonymous()) {
OWLClass superClass = ce.asOWLClass();
if (redundant.contains(superClass)) {
redundantAxioms.add(subClassOfAxiom);
}
}
}
}
示例9: getSuperClasses
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
public static Set<OWLClassExpression> getSuperClasses(OWLClass subCls, OWLOntology ont) {
Set<OWLClassExpression> result;
if (subCls != null && ont != null) {
result = new HashSet<>();
Set<OWLSubClassOfAxiom> axioms = ont.getSubClassAxiomsForSubClass(subCls);
for (OWLSubClassOfAxiom axiom : axioms) {
result.add(axiom.getSuperClass());
}
}
else {
result = Collections.emptySet();
}
return result;
}
示例10: hasAssertedSubClassAxiom
import org.semanticweb.owlapi.model.OWLOntology; //導入方法依賴的package包/類
/**
* Check the ontology for an existing subClassOf axiom with the given sub- and superclass.
* This search ignores axiom annotations (i.e. is_inferred=true).
*
* WARNING: Do not use {@link OWLOntology#containsAxiomIgnoreAnnotations(OWLAxiom)}
* In the current OWL-API, this seems to be very very slow.
*
* @param subClass
* @param superClass
* @param ontology
* @return true, if there is an axiom for this subClass statement.
*/
protected boolean hasAssertedSubClassAxiom(OWLClass subClass, OWLClassExpression superClass, OWLOntology ontology) {
Set<OWLSubClassOfAxiom> existing = ontology.getSubClassAxiomsForSubClass(subClass);
if (existing != null) {
for (OWLSubClassOfAxiom sca : existing) {
if (superClass.equals(sca.getSuperClass())) {
return true;
}
}
}
return false;
}