[ https://issues.apache.org/jira/browse/RYA-294?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16140103#comment-16140103 ]
ASF GitHub Bot commented on RYA-294: ------------------------------------ Github user ejwhite922 commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/217#discussion_r135021324 --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/SomeValuesFromVisitor.java --- @@ -0,0 +1,110 @@ +package org.apache.rya.rdftriplestore.inference; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.apache.rya.api.RdfCloudTripleStoreConfiguration; +import org.apache.rya.api.utils.NullableStatementImpl; +import org.apache.rya.rdftriplestore.utils.FixedStatementPattern; +import org.openrdf.model.Resource; +import org.openrdf.model.URI; +import org.openrdf.model.vocabulary.OWL; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.query.algebra.StatementPattern; +import org.openrdf.query.algebra.Var; + +/** + * Expands the query tree to account for any existential class expressions (property restrictions + * using owl:someValuesFrom) in the ontology known to the {@link InferenceEngine}. + * + * Operates on {@link StatementPattern} nodes whose predicate is rdf:type and whose object is a + * defined type (not a variable) which corresponds to a someValuesFrom expression in the ontology. + * When applicable, replaces the node with a union of itself and a subtree that matches any instance + * that can be inferred to have the type in question via the semantics of owl:someValuesFrom. + * + * An existential class expression references a predicate and a value class, and represents the set + * of individuals with at least one value of that class for that predicate. Therefore, membership + * in the class expression should be inferred for any individual which is the subject of a triple + * with that predicate and with an object belonging to the value type. This implication is similar + * to rdfs:domain except that it only applies when the object of the triple belongs to a specific + * type. + * + * (Note: The inference in the other direction would be that, if an individual is declared to belong + * to the class expression, then there exists some other individual which satisfies the requirement + * that there is at least one value of the appropriate type. However, this other individual may be + * any arbitrary resource, explicitly represented in the data or otherwise, so this implication is + * not used.) + */ +public class SomeValuesFromVisitor extends AbstractInferVisitor { + /** + * Creates a new {@link SomeValuesFromVisitor}, which is enabled by default. + * @param conf The {@link RdfCloudTripleStoreConfiguration}. + * @param inferenceEngine The InferenceEngine containing the relevant ontology. + */ + public SomeValuesFromVisitor(RdfCloudTripleStoreConfiguration conf, InferenceEngine inferenceEngine) { + super(conf, inferenceEngine); + include = true; --- End diff -- A config value for SomeValuesFrom inferencing should be added to RdfCloudTripleStoreConfiguration. > Implement owl:someValuesFrom inference > -------------------------------------- > > Key: RYA-294 > URL: https://issues.apache.org/jira/browse/RYA-294 > Project: Rya > Issue Type: Sub-task > Components: sail > Reporter: Jesse Hatfield > Assignee: Jesse Hatfield > > An *{{owl:someValuesFrom}}* restriction defines the set of resources which, > for a given predicate and other type, have at least one value of that other > type for that predicate. > If the ontology states that {{:Chair}} is the set of resources who are > {{:headOf}} at least one resource which must itself be a {{:Department}}, > then: > {{?x rdf:type :Chair}} > should be expanded to: > {noformat} > { ?x :headOf ?dept . > ?dept rdf:type :Department } > UNION > {?x rdf:type :Chair } > {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)