private ImmutableMap<IRI, Datatype> getDescendentNodesPartialMap(ClassifiedTBox reasoner, DataRangeExpression node, Equivalences<DataRangeExpression> nodeSet) { if (node instanceof Datatype) { return reasoner.dataRangesDAG().getSub(nodeSet).stream() .map(Equivalences::getRepresentative) .filter(d -> d != node) .map(this::getPredicateIRI) .filter(Optional::isPresent) .collect(ImmutableCollectors.toMap( Optional::get, d -> (Datatype) node )); } return ImmutableMap.of(); }
/** * modifies the intersection by further intersecting it with a class / property * * IMPORTANT: the class / property is given by the DOWNWRD-SATURATED SET * (in other words, by the result of EquivalencesDAG.getSubRepresentatives * * @param e a non-empty downward saturated set for class / property */ public void intersectWith(T e) { if (elements == null) // we have top, the intersection is sub elements = new HashSet<>(dag.getSubRepresentatives(e)); // copy the set else elements.retainAll(dag.getSubRepresentatives(e)); }
/** * Produces a map from datatypeProperty to corresponding datatype according to the ontology (the datatype may * be inferred). * This is a rewriting of method: * it.unibz.inf.ontop.owlrefplatform.core.mappingprocessing.MappingDataTypeRepair#getDataTypeFromOntology * from Ontop v 1.18.1 */ private ImmutableMultimap<IRI, Datatype> computeDataTypeMap(ClassifiedTBox reasoner) { // TODO: switch to guava > 2.1, and replace by Streams.stream(iterable) return StreamSupport.stream(reasoner.dataRangesDAG().spliterator(), false) .flatMap(n -> getPartialPredicateToDatatypeMap(n, reasoner).entrySet().stream()) .collect(ImmutableCollectors.toMultimap( e -> e.getKey(), Map.Entry::getValue)); }
DataPropertyRangeExpression firstp = (DataPropertyRangeExpression)first; DataPropertyExpression prop = firstp.getProperty(); Equivalences<DataPropertyExpression> vertex = dataPropertyDAG.getVertex(prop); if (vertex == null){ throw new IllegalStateException("Unknown data property: " + prop);
private void process(Connection conn, ClassAssertion ax, PreparedStatement uriidStm, Map<SemanticIndexViewID, PreparedStatement> stmMap) throws SQLException { // replace concept by the canonical representative (which must be a concept name) OClass concept0 = ax.getConcept(); OClass concept = (OClass)reasonerDag.classesDAG().getCanonicalForm(concept0); int conceptIndex = cacheSI.getEntry(concept).getIndex(); ObjectConstant c1 = ax.getIndividual(); SemanticIndexView view = views.getView(c1.getType()); PreparedStatement stm = stmMap.get(view.getId()); if (stm == null) { stm = conn.prepareStatement(view.getINSERT()); stmMap.put(view.getId(), stm); } int uri_id = getObjectConstantUriId(c1, uriidStm); // Construct the database INSERT statements stm.setInt(1, uri_id); stm.setInt(2, conceptIndex); stm.addBatch(); // Register non emptiness view.addIndex(conceptIndex); }
/** * Constructor for the NamedDAG * @param dag the DAG from which we want to keep only the named descriptions */ public static <T> SimpleDirectedGraph <T,DefaultEdge> getNamedDAG(EquivalencesDAG<T> dag) { SimpleDirectedGraph<T,DefaultEdge> namedDAG = new SimpleDirectedGraph<>(DefaultEdge.class); for (Equivalences<T> v : dag) namedDAG.addVertex(v.getRepresentative()); for (Equivalences<T> s : dag) for (Equivalences<T> t : dag.getDirectSuper(s)) namedDAG.addEdge(s.getRepresentative(), t.getRepresentative()); for (Equivalences<T> v : dag) if (!v.isIndexed()) { // eliminate node for (DefaultEdge incEdge : namedDAG.incomingEdgesOf(v.getRepresentative())) { T source = namedDAG.getEdgeSource(incEdge); for (DefaultEdge outEdge : namedDAG.outgoingEdgesOf(v.getRepresentative())) { T target = namedDAG.getEdgeTarget(outEdge); namedDAG.addEdge(source, target); } } namedDAG.removeVertex(v.getRepresentative()); // removes all adjacent edges as well } return namedDAG; }
DataPropertyRangeExpression firstp = (DataPropertyRangeExpression)first; DataPropertyExpression prop = firstp.getProperty(); Equivalences<DataPropertyExpression> vertex = dataPropertyDAG.getVertex(prop); if (vertex == null){ throw new IllegalStateException("Unknown data property: " + prop);
DataPropertyExpression dpe = reasonerDag.dataPropertiesDAG().getCanonicalForm(dpe0); int idx = cacheSI.getEntry(dpe).getIndex();
private ImmutableMap<Predicate, Datatype> getDescendentNodesPartialMap(ClassifiedTBox reasoner, DataRangeExpression node, Equivalences<DataRangeExpression> nodeSet) { if (node instanceof Datatype) { return reasoner.dataRangesDAG().getSub(nodeSet).stream() .map(Equivalences::getRepresentative) .filter(d -> d != node) .map(this::getPredicate) .filter(Optional::isPresent) .collect(ImmutableCollectors.toMap( Optional::get, d -> (Datatype) node )); } return ImmutableMap.of(); }
ObjectSomeValuesFrom firstp = (ObjectSomeValuesFrom)first; ObjectPropertyExpression prop = firstp.getProperty(); ObjectPropertyExpression propRep = objectPropertyDAG.getVertex(prop).getRepresentative(); representative = propRep.getDomain(); DataSomeValuesFrom firstp = (DataSomeValuesFrom)first; DataPropertyExpression prop = firstp.getProperty(); DataPropertyExpression propRep = dataPropertyDAG.getVertex(prop).getRepresentative(); representative = propRep.getDomainRestriction(DatatypeImpl.rdfsLiteral);
OClass equivalent = (OClass)reasoner.classesDAG().getCanonicalForm(c); if (equivalent != null && !equivalent.equals(c)) { return atomFactory.getMutableTripleBodyAtom(bodyAtom.getTerm(0), equivalent.getIRI()); ObjectPropertyExpression equivalent = reasoner.objectPropertiesDAG().getCanonicalForm(ope); if (equivalent != null && !equivalent.equals(ope)) { if (!equivalent.isInverse()) DataPropertyExpression equivalent = reasoner.dataPropertiesDAG().getCanonicalForm(dpe); if (equivalent != null && !equivalent.equals(dpe)) { return atomFactory.getMutableTripleBodyAtom(bodyAtom.getTerm(0), equivalent.getIRI(), bodyAtom.getTerm(2));
public Set<ClassExpression> getSubConcepts() { if (subconcepts == null) { subconcepts = new HashSet<>(); for (ClassExpression con : concepts) subconcepts.addAll(reasoner.classesDAG().getSubRepresentatives(con)); } return subconcepts; }
/** * Produces a map from datatypeProperty to corresponding datatype according to the ontology (the datatype may * be inferred). * This is a rewriting of method: * it.unibz.inf.ontop.owlrefplatform.core.mappingprocessing.MappingDataTypeRepair#getDataTypeFromOntology * from Ontop v 1.18.1 */ private ImmutableMultimap<String, Datatype> computeDataTypeMap(ClassifiedTBox reasoner) { // TODO: switch to guava > 2.1, and replace by Streams.stream(iterable) return StreamSupport.stream(reasoner.dataRangesDAG().spliterator(), false) .flatMap(n -> getPartialPredicateToDatatypeMap(n, reasoner).entrySet().stream()) .collect(ImmutableCollectors.toMultimap( e -> e.getKey().getName(), Map.Entry::getValue)); }
Set<Equivalences<ClassExpression>> subClasses = reasoner.classesDAG().getSub(set); boolean couldBeGenerating = set.size() > 1 || subClasses.size() > 1; for (ClassExpression concept : set) {
ObjectSomeValuesFrom firstp = (ObjectSomeValuesFrom)first; ObjectPropertyExpression prop = firstp.getProperty(); ObjectPropertyExpression propRep = objectPropertyDAG.getVertex(prop).getRepresentative(); representative = propRep.getDomain(); DataSomeValuesFrom firstp = (DataSomeValuesFrom)first; DataPropertyExpression prop = firstp.getProperty(); DataPropertyExpression propRep = dataPropertyDAG.getVertex(prop).getRepresentative(); representative = propRep.getDomainRestriction(DatatypeImpl.rdfsLiteral);
throw new RuntimeException("INVERSE PROPERTIES ARE NOT SUPPORTED IN ABOX:" + ax); ObjectPropertyExpression ope = reasonerDag.objectPropertiesDAG().getCanonicalForm(ope0);
for (ClassExpression b : concepts) if (b instanceof ObjectSomeValuesFrom) extension.addAll(reasoner.classesDAG().getSubRepresentatives(b)); concepts.addAll(extension); for (ClassExpression b : concepts) if (b instanceof OClass) { Set<ClassExpression> bsubconcepts = reasoner.classesDAG().getSubRepresentatives(b); Iterator<ClassExpression> i = concepts.iterator(); while (i.hasNext()) { ObjectSomeValuesFrom some = (ObjectSomeValuesFrom)b; ObjectPropertyExpression prop = some.getProperty(); Set<ObjectPropertyExpression> bsubproperties = reasoner.objectPropertiesDAG().getSubRepresentatives(prop); Iterator<ClassExpression> i = concepts.iterator(); while (i.hasNext()) {
for (Equivalences<ObjectPropertyExpression> subpropNode : reasoner.objectPropertiesDAG().getSub(propNode)) { for (ObjectPropertyExpression subprop : subpropNode) { if (subprop.isInverse()) for (Equivalences<DataPropertyExpression> subpropNode : reasoner.dataPropertiesDAG().getSub(propNode)) { for (DataPropertyExpression subprop : subpropNode) { DataAtom<AtomPredicate> body = translate(subprop, variableXname, variableYname); for (Equivalences<ClassExpression> subclassNode : reasoner.classesDAG().getSub(classNode)) { for (ClassExpression subclass : subclassNode) { DataAtom<AtomPredicate> body = translate(subclass, variableYname);
private void setIndex(String iri, int type, int idx) { if (type == CLASS_TYPE) { OClass c = reasonerDag.classes().get(iri); if (reasonerDag.classesDAG().getVertex(c) == null) throw new RuntimeException("UNKNOWN CLASS: " + iri); if (cacheSI.getEntry(ope) != null) { DataPropertyExpression dpe = reasonerDag.dataProperties().get(iri); if (reasonerDag.dataPropertiesDAG().getVertex(dpe) != null) { if (cacheSI.getEntry(dpe) != null) throw new RuntimeException("DUPLICATE PROPERTY: " + iri); if (reasonerDag.dataPropertiesDAG().getVertex(dpe) != null) { if (cacheSI.getEntry(dpe) != null) throw new RuntimeException("DUPLICATE PROPERTY: " + iri);
TMappingIndexEntry currentNodeMappings = getMappings(mappingIndex, currentPredicate); for (Equivalences<DataPropertyExpression> descendants : dag.getSub(propertySet)) { for(DataPropertyExpression childproperty : descendants) {