private Collection<Collection<String>> getClassExpressionOfType( Collection<OWLClassExpression> classExpressions, ClassExpressionType type) { Collection<Collection<String>> collection = new HashSet<Collection<String>>(); for (OWLClassExpression expression : classExpressions) { final ClassExpressionType classExpressionType = expression .getClassExpressionType(); if (type.equals(classExpressionType)) { final Set<OWLClass> equivalentClassesList = expression .getClassesInSignature(); List<String> classAsStringList = new ArrayList<String>(); for (OWLClass clz : equivalentClassesList) { classAsStringList.add(clz.getIRI().toString()); } collection.add(classAsStringList); } } return collection; }
@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; }
private Collection<Collection<String>> getEquivalentClassByClassExpresionType( final String c, ClassExpressionType type) { final OWLDataFactory factory = ontology.getOWLOntologyManager() .getOWLDataFactory(); final OWLClass owlClass = factory.getOWLClass(IRI.create(c)); final Set<OWLOntology> ontologySet = new HashSet<OWLOntology>(); ontologySet.add(ontology); ontologySet.addAll(ontology.getImportsClosure()); final Set<OWLClassExpression> equivalentClasses = owlClass .getEquivalentClasses(ontologySet); return getClassExpressionOfType(equivalentClasses, type); }
public Collection<Collection<String>> getClassDisjointWith(String c) { final OWLDataFactory factory = ontology.getOWLOntologyManager() .getOWLDataFactory(); final OWLClass owlClass = factory.getOWLClass(IRI.create(c)); final Set<OWLOntology> ontologySet = new HashSet<OWLOntology>(); ontologySet.add(ontology); ontologySet.addAll(ontology.getImportsClosure()); final Set<OWLClassExpression> disjointClasses = owlClass .getDisjointClasses(ontologySet); return getClassExpressionOfType(disjointClasses, ClassExpressionType.OWL_CLASS); }
private ATermAppl convertToATerm(OWLClassExpression expr, KnowledgeBase kb) { return expr.getClassExpressionType() == ClassExpressionType.OBJECT_COMPLEMENT_OF ? CCUtils.classExprToATerm( expr.getComplementNNF(), kb ) : CCUtils.classExprToATerm( expr, kb ); }
public Collection<Collection<String>> getClassIntersectionOf(String c) { return getEquivalentClassByClassExpresionType(c, ClassExpressionType.OBJECT_INTERSECTION_OF); }
public Collection<Collection<String>> getClassUnionOf(String c) { return getEquivalentClassByClassExpresionType(c, ClassExpressionType.OBJECT_UNION_OF); }
public Collection<Collection<String>> getClassComplementOf(String c) { return getEquivalentClassByClassExpresionType(c, ClassExpressionType.OBJECT_COMPLEMENT_OF); }
public Collection<Collection<String>> getClassEquivalentClass(String c) { return getEquivalentClassByClassExpresionType(c, ClassExpressionType.OWL_CLASS); }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_MAX_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_MIN_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_HAS_VALUE; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_SOME_VALUES_FROM; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_ALL_VALUES_FROM; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_INTERSECTION_OF; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_MIN_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_HAS_SELF; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_COMPLEMENT_OF; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_MAX_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_UNION_OF; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_EXACT_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_ONE_OF; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.DATA_EXACT_CARDINALITY; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_HAS_VALUE; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OBJECT_ALL_VALUES_FROM; }
@Override public ClassExpressionType getClassExpressionType() { return ClassExpressionType.OWL_CLASS; }