本文整理汇总了Java中org.semanticweb.owlapi.model.OWLSubClassOfAxiom.getSuperClass方法的典型用法代码示例。如果您正苦于以下问题:Java OWLSubClassOfAxiom.getSuperClass方法的具体用法?Java OWLSubClassOfAxiom.getSuperClass怎么用?Java OWLSubClassOfAxiom.getSuperClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.model.OWLSubClassOfAxiom
的用法示例。
在下文中一共展示了OWLSubClassOfAxiom.getSuperClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadPrimitiveDefinition
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的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: hasLinks
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的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;
}
示例3: getMappings
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
public Set<Mapping> getMappings() {
Set<Mapping> ms = new HashSet<Mapping>();
OWLAnnotationProperty vap = getVariableAnnotationProperty();
for (OWLSubClassOfAxiom sca : ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED)) {
Mapping m = new Mapping();
Set<OWLAnnotation> anns = sca.getAnnotations(vap);
for (OWLAnnotation ann : anns) {
IRI v = (IRI) ann.getValue();
m.vars.add(v);
}
if (m.vars.size() > 0) {
m.src = sca.getSubClass();
m.tgt = sca.getSuperClass();
ms.add(m);
LOG.info("MAPPING: "+m);
}
}
return ms;
}
示例4: getSvfClasses
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
Set<OWLClass> getSvfClasses(OWLClass c, OWLObjectProperty p) {
Set<OWLSubClassOfAxiom> axioms = new HashSet<OWLSubClassOfAxiom>();
for(OWLOntology ont : getAllOntologies()) {
axioms.addAll(ont.getSubClassAxiomsForSubClass(c));
}
Set<OWLClass> superClasses = new HashSet<OWLClass>();
for (OWLSubClassOfAxiom axiom : axioms) {
OWLClassExpression expr = axiom.getSuperClass();
if (expr instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) expr;
if (p.equals(svf.getProperty())) {
OWLClassExpression filler = svf.getFiller();
if (filler instanceof OWLClass) {
superClasses.add((OWLClass) filler);
}
}
}
}
return superClasses;
}
示例5: visit
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
@Override
public void visit(OWLSubClassOfAxiom axiom) {
OWLClassExpression subClass = axiom.getSubClass();
OWLClassExpression superClass = axiom.getSuperClass();
HandlerResult modifiedSubClass = subClass.accept(handler);
HandlerResult modifiedSuperClass = superClass.accept(handler);
if (modifiedSubClass != null || modifiedSuperClass != null) {
if (modifiedSubClass != null) {
if (modifiedSubClass.remove) {
remove(ontology, axiom);
return;
}
subClass = modifiedSubClass.modified;
}
if (modifiedSuperClass != null) {
if (modifiedSuperClass.remove) {
remove(ontology, axiom);
return;
}
superClass = modifiedSuperClass.modified;
}
remove(ontology, axiom);
OWLSubClassOfAxiom newAxiom = factory.getOWLSubClassOfAxiom(subClass, superClass, axiom.getAnnotations());
add(ontology, newAxiom);
}
}
示例6: getAdjacent
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的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: addSubClassAxiom
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
private void addSubClassAxiom(OWLSubClassOfAxiom axiom)
{
OWLClassExpression subClass = axiom.getSubClass();
OWLClassExpression superClass = axiom.getSuperClass();
OwlNode<OWLClassExpression> subClassNode = createNode(subClass);
OwlNode<OWLClassExpression> superClassNode = createNode(superClass);
if (mClassCache.contains(subClass)) {
subClassNode = findNode(subClass);
superClassNode.setParent(subClassNode.getParent());
subClassNode.setParent(superClassNode);
}
else if (mClassCache.contains(superClass)) {
superClassNode = findNode(superClass);
subClassNode.setParent(superClassNode);
}
else {
superClassNode.setParent(mRoot);
subClassNode.setParent(superClassNode);
}
mClassCache.add(subClass);
mClassCache.add(superClass);
}
示例8: visit
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
@Override
public void visit(OWLSubClassOfAxiom axiom) {
// process subclass
OWLClassExpression subClass = axiom.getSubClass();
if(!subClass.isOWLThing()){// we do not need to convert owl:Thing
String subClassPattern = expressionConverter.asGroupGraphPattern(subClass, subjectVar);
sparql += subClassPattern;
}
// process superclass
OWLClassExpression superClass = axiom.getSuperClass();
boolean needsOuterTriplePattern = subClass.isOWLThing() &&
(superClass.getClassExpressionType() == ClassExpressionType.OBJECT_COMPLEMENT_OF ||
superClass.getClassExpressionType() == ClassExpressionType.DATA_ALL_VALUES_FROM ||
superClass.getClassExpressionType() == ClassExpressionType.OBJECT_ALL_VALUES_FROM);
String superClassPattern = expressionConverter.asGroupGraphPattern(superClass, subjectVar,
needsOuterTriplePattern);
sparql += superClassPattern;
}
示例9: updateRedundant
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的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);
}
}
}
}
示例10: checkPotentialRedundantSubClassAxioms
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
/**
* Check all classes for potential redundant subClass axioms of type:
* <pre>
* A SubClassOf R some B
* and
* A SubClassOf B
* </pre>
*
* @return list of axiom pairs
*/
public List<PotentialRedundant> checkPotentialRedundantSubClassAxioms() {
List<PotentialRedundant> result = new ArrayList<PotentialRedundant>();
for(OWLClass cls : graph.getAllOWLClasses()) {
Set<OWLSubClassOfAxiom> axioms = graph.getAllOWLSubClassOfAxiomsForSubClass(cls);
if (axioms.size() > 1) {
// only check sets with more than one axiom
for (OWLSubClassOfAxiom main : axioms) {
OWLClassExpression mainSuperClassCE = main.getSuperClass();
if (mainSuperClassCE.isAnonymous()) {
continue;
}
OWLClass mainSuperClass = mainSuperClassCE.asOWLClass();
for (OWLSubClassOfAxiom current : axioms) {
if (main == current) {
continue;
}
OWLClassExpression currentSuperClass = current.getSuperClass();
if (currentSuperClass.isAnonymous() && currentSuperClass instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) currentSuperClass;
final OWLClassExpression filler = someValuesFrom.getFiller();
if (mainSuperClass.equals(someValuesFrom.getFiller())) {
final OWLObjectPropertyExpression property = someValuesFrom.getProperty();
final OWLClassExpression subClass = current.getSubClass();
final PotentialRedundant redundant = new PotentialRedundant(main, current, subClass.asOWLClass(), property.asOWLObjectProperty(), filler.asOWLClass());
result.add(redundant);
}
}
}
}
}
}
if (!result.isEmpty()) {
return result;
}
return null;
}
示例11: testOrganismPair
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
@Test
public void testOrganismPair() throws Exception{
g = getOntologyWrapper("limb_gci.owl");
ElkReasonerFactory rf = new ElkReasonerFactory();
OWLReasoner r = rf.createReasoner(g.getSourceOntology());
try {
Set<OWLSubClassOfAxiom> axioms = GCIUtil.getSubClassOfSomeValuesFromAxioms(r);
int n = 0;
for (OWLSubClassOfAxiom axiom : axioms) {
String c = ((OWLClass) axiom.getSubClass()).getIRI().toString();
OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) axiom.getSuperClass();
String rel = ((OWLObjectProperty) svf.getProperty()).getIRI().toString();
String p = ((OWLClass) svf.getFiller()).getIRI().toString();
String axstr = c + " " + rel + " " + p;
System.out.println(axstr);
if ("http://x.org/phalanx-development http://x.org/part-of http://x.org/digit-development".equals(axstr)) {
n |= 1;
}
if ("http://x.org/digit-development http://x.org/part-of http://x.org/autopod-development".equals(axstr)) {
n |= 2;
}
if ("http://x.org/limb-development http://x.org/part-of http://x.org/organism-development".equals(axstr)) {
n |= 4;
}
if ("http://x.org/autopod-development http://x.org/part-of http://x.org/limb-development".equals(axstr)) {
n |= 8;
}
}
assertEquals(4, axioms.size());
assertEquals(15, n);
}
finally {
r.dispose();
}
}
示例12: getSuperSVFs
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
private static Set<OWLObjectSomeValuesFrom> getSuperSVFs(Set<OWLSubClassOfAxiom> axioms) {
final Set<OWLObjectSomeValuesFrom> svfs = new HashSet<OWLObjectSomeValuesFrom>();
for (OWLSubClassOfAxiom existing : axioms) {
OWLClassExpression superCE = existing.getSuperClass();
superCE.accept(new OWLClassExpressionVisitorAdapter() {
@Override
public void visit(OWLObjectSomeValuesFrom svf) {
svfs.add(svf);
}
});
}
return svfs;
}
示例13: visit
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
public void visit(OWLSubClassOfAxiom subClassAxiom) {
OWLClassExpression subClass = subClassAxiom.getSubClass();
OWLClassExpression supClass = subClassAxiom.getSuperClass();
subClass.accept(this);
supClass.accept(this);
}
示例14: visit
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
@Override
public Set<ComplexIntegerAxiom> visit(OWLSubClassOfAxiom axiom) throws TranslationException {
Objects.requireNonNull(axiom);
OWLClassExpression owlSubClass = axiom.getSubClass();
OWLClassExpression owlSuperClass = axiom.getSuperClass();
IntegerClassExpression leftDescription = translateClassExpression(owlSubClass);
IntegerClassExpression rightDescription = translateClassExpression(owlSuperClass);
ComplexIntegerAxiom ret = getAxiomFactory().createSubClassOfAxiom(leftDescription, rightDescription,
translateAnnotations(axiom.getAnnotations()));
return Collections.singleton(ret);
}
示例15: visit
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; //导入方法依赖的package包/类
/**
* A utility method to process OWL <code>SubClassOf(CE1 CE2)</code> axiom and produce inferred
* mapping assertions.
*/
@Override
public void visit(OWLSubClassOfAxiom axiom)
{
/*
* Trace all the ancestors of the class expression in the given OWL SubClassOf axiom.
*/
Set<OWLSubClassOfAxiom> ancestors = mOntology.traceAncestors(axiom.getSubClass(), true);
for (OWLSubClassOfAxiom ax : ancestors) {
/*
* Get all (copy) known mappings for the visited subclass expression.
*/
OWLClassExpression subClass = ax.getSubClass();
subClass.accept(this); // this call will produce (subclass) mSignature
Set<IMapping> subClassMappings = getMappingsForClassExpression();
if (subClassMappings.isEmpty()) {
continue;
}
/*
* Produce the "extra" mappings for the visited super class expression as many as the known
* mappings in the subclass expression.
*/
OWLClassExpression superClass = ax.getSuperClass();
superClass.accept(this); // this call will produce (super class) mSignature and mIsInverse
URI superClassSignature = mSignature;
for (IMapping subClassMapping : subClassMappings) {
IClassMapping cm = createClassMapping(superClassSignature, subClassMapping, mIsInverse);
addInferredMapping(cm);
}
}
}