当前位置: 首页>>代码示例>>Java>>正文


Java OWLOntology.getSubClassAxiomsForSubClass方法代码示例

本文整理汇总了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();
}
 
开发者ID:julianmendez,项目名称:uel,代码行数:20,代码来源:UelOntology.java

示例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;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:FindGoCodes.java

示例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);
      }
    }
  }
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:17,代码来源:RestrictionVisitor.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:ProvenanceReasonerWrapper.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:LinkMaker.java

示例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);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:21,代码来源:CycleCheck.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:38,代码来源:NCBIConverter.java

示例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);
			}
		}
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:41,代码来源:InferenceBuilder.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:15,代码来源:OwlHelper.java

示例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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:24,代码来源:InferenceBuilder.java


注:本文中的org.semanticweb.owlapi.model.OWLOntology.getSubClassAxiomsForSubClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。