You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by ejwhite922 <gi...@git.apache.org> on 2017/08/23 16:23:10 UTC

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

GitHub user ejwhite922 opened a pull request:

    https://github.com/apache/incubator-rya/pull/215

    RYA-300 Added owl:oneOf inference.

    ## Description
    Inference applies owl:oneOf semantics for queries including statement patterns of the form "?x rdf:type :DefinedClass".
    
    OWL provides a construct for defining a range of data values, namely an enumerated datatype. This datatype format makes use of the owl:oneOf construct, that is also used for describing an enumerated class. In the case of an enumerated datatype, the subject of owl:oneOf is a blank node of class owl:DataRange and the object is a list of literals. Unfortunately, we cannot use the rdf:parseType="Collection" idiom for specifying the literal list, because RDF requires the collection to be a list of RDF node elements. Therefore we have to specify the list of data values with the basic list constructs rdf:first, rdf:rest and rdf:nil.
    
    The InferenceEngine, at refresh time, stores information about owl:oneOf. It stores a mapping of each type that has an enumeration. These mapped definitions can then be accessed by the method: getEnumeration(Resource).
    
    OneOfVisitor processes statement patterns of the form "?x rdf:type :T2", and if :T2 is the value type for any owl:oneOf restriction according to the inference engine, it replaces the statement pattern with a binding set assignment of all the enumeration items
    
    RdfCloudTripleStoreConnection calls the visitor along with the other inference logic.
    
    Added a simple example of a query that relies on this inference to MongoRyaDirectExample.
    
    ### Tests
    Unit tests
    
    ### Links
    [Jira](https://issues.apache.org/jira/browse/RYA-300)
    
    ### Checklist
    - [ ] Code Review
    - [ ] Squash Commits
    
    #### People To Review
    @jessehatfield 
    @meiercaleb 
    @isper3at 
    @pujav65 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ejwhite922/incubator-rya RYA-300_OneOfInference

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-rya/pull/215.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #215
    
----
commit 825f1af7e1f9c84b46c02243aa358201cb786b4b
Author: eric.white <er...@parsons.com>
Date:   2017-08-23T15:08:58Z

    RYA-300 Added owl:oneOf inference.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/438/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by meiercaleb <gi...@git.apache.org>.
Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r134867088
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,108 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String inferQuery = "select distinct ?card { GRAPH <http://updated/test> { ?card a <urn:Card> . ?suit a <urn:Suits> . ?card <urn:HasSuit> ?suit} } \n";
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  { ?card <urn:HasSuit> <urn:Clubs> }\n"
    --- End diff --
    
    Is there some sort of shorthand going on here?  Where did the ?card a <urn:Card> statement pattern go?  <urn:Card> is only a subClass of the Range property restrictions on <urn:hasRank> and <urn:hasSuit>.  Seems like you would still need to join on <urn:Card> here unless you replace subClassOf with equivalentClass.  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-rya/pull/215


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135109142
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import java.util.LinkedHashSet;
    +import java.util.Set;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +/**
    + * Visitor for handling owl:oneOf inferencing on a node.
    + */
    +public class OneOfVisitor extends AbstractInferVisitor {
    +    private static final Logger log = Logger.getLogger(OneOfVisitor.class);
    +
    +    /**
    +     * Creates a new instance of {@link OneOfVisitor}.
    +     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.
    +     * @param inferenceEngine the {@link InferenceEngine}.
    +     */
    +    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {
    +        super(conf, inferenceEngine);
    +        include = conf.isInferOneOf();
    +    }
    +
    +    @Override
    +    protected void meetSP(final StatementPattern node) throws Exception {
    +        final Var subVar = node.getSubjectVar();
    +        final Var predVar = node.getPredicateVar();
    +        final Var objVar = node.getObjectVar();
    +        final Var conVar = node.getContextVar();
    +        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
    +            final URI object = (URI) objVar.getValue();
    --- End diff --
    
    Switched to Resource and added extra check.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/431/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135055573
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java ---
    @@ -0,0 +1,80 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import java.util.LinkedHashSet;
    +import java.util.Set;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +/**
    + * Visitor for handling owl:oneOf inferencing on a node.
    + */
    +public class OneOfVisitor extends AbstractInferVisitor {
    +    private static final Logger log = Logger.getLogger(OneOfVisitor.class);
    +
    +    /**
    +     * Creates a new instance of {@link OneOfVisitor}.
    +     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.
    +     * @param inferenceEngine the {@link InferenceEngine}.
    +     */
    +    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {
    +        super(conf, inferenceEngine);
    +        include = conf.isInferOneOf();
    +    }
    +
    +    @Override
    +    protected void meetSP(final StatementPattern node) throws Exception {
    +        final Var subVar = node.getSubjectVar();
    +        final Var predVar = node.getPredicateVar();
    +        final Var objVar = node.getObjectVar();
    +        final Var conVar = node.getContextVar();
    +        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
    +            final URI object = (URI) objVar.getValue();
    +            if (inferenceEngine.isEnumeratedType(object)) {
    +                final Set<BindingSet> solutions = new LinkedHashSet<>();
    +                final Set<Resource> enumeration = inferenceEngine.getEnumeration(object);
    +                if (enumeration != null && !enumeration.isEmpty()) {
    --- End diff --
    
    Yep. Removed check.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135055461
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java ---
    @@ -1281,4 +1324,34 @@ public void setSchedule(final boolean schedule) {
             }
             return null;
         }
    +
    +    /**
    +     * For a given type, return all sets of types such that owl:oneOf
    +     * restrictions on those properties could imply this type. A enumeration
    +     * of all the types that are part of the specified class type.
    +     * @param type The type (URI or bnode) to check against the known oneOf
    +     * sets.
    +     * @return A {@link Set} of {@link Resource} types that represents the
    +     * enumeration of resources that belong to the class type.
    +     * {@code null} is returned if no enumerations were found for the specified
    +     * type.
    +     */
    +    public Set<Resource> getEnumeration(final Resource type) {
    +        if (enumerations != null) {
    +            final Set<Resource> oneOfSet = enumerations.get(type);
    +            return oneOfSet;
    +        }
    +        return null;
    --- End diff --
    
    Replaced with an empty set.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/434/<h2>Failed Tests: <span class='status-failure'>1</span></h2><h3><a name='incubator-rya-master-with-optionals-pull-requests/org.apache.rya:rya.indexing' /><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/434/org.apache.rya$rya.indexing/testReport'>incubator-rya-master-with-optionals-pull-requests/org.apache.rya:rya.indexing</a>: <span class='status-failure'>1</span></h3><ul><li><a href='https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/434/org.apache.rya$rya.indexing/testReport/org.apache.rya.indexing.mongo/MongoTemporalIndexerTest/org_apache_rya_indexing_mongo_MongoTemporalIndexerTest/'><strong>org.apache.rya.indexing.mongo.MongoTemporalIndexerTest.org.apache.rya.indexing.mongo.MongoTemporalIndexerTest</strong></a></li></ul>



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r134877065
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,108 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String inferQuery = "select distinct ?card { GRAPH <http://updated/test> { ?card a <urn:Card> . ?suit a <urn:Suits> . ?card <urn:HasSuit> ?suit} } \n";
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  { ?card <urn:HasSuit> <urn:Clubs> }\n"
    --- End diff --
    
    The explicitQuery doesn't have the ontology information yet (i.e. urn:Card is a subClass of the Range property restrictions on urn:hasRank and urn:hasSuit) to show how something would be done without using owl:oneOf.  I guess inferQuery is a little out of place and should be moved down closer to where it's called.
    
    I'll change subClassOf to equivalentClass.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by jessehatfield <gi...@git.apache.org>.
Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135076533
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java ---
    @@ -0,0 +1,78 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import java.util.LinkedHashSet;
    +import java.util.Set;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +/**
    + * Visitor for handling owl:oneOf inferencing on a node.
    + */
    +public class OneOfVisitor extends AbstractInferVisitor {
    +    private static final Logger log = Logger.getLogger(OneOfVisitor.class);
    +
    +    /**
    +     * Creates a new instance of {@link OneOfVisitor}.
    +     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.
    +     * @param inferenceEngine the {@link InferenceEngine}.
    +     */
    +    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {
    +        super(conf, inferenceEngine);
    +        include = conf.isInferOneOf();
    +    }
    +
    +    @Override
    +    protected void meetSP(final StatementPattern node) throws Exception {
    +        final Var subVar = node.getSubjectVar();
    +        final Var predVar = node.getPredicateVar();
    +        final Var objVar = node.getObjectVar();
    +        final Var conVar = node.getContextVar();
    +        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
    +            final URI object = (URI) objVar.getValue();
    --- End diff --
    
    Should this be Resource instead of URI, and should we verify the type in the if condition?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135109161
  
    --- Diff: sail/src/test/java/org/apache/rya/rdftriplestore/inference/OneOfVisitorTest.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNotNull;
    +import static org.junit.Assert.assertTrue;
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.rya.accumulo.AccumuloRdfConfiguration;
    +import org.junit.Test;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.Value;
    +import org.openrdf.model.ValueFactory;
    +import org.openrdf.model.impl.ValueFactoryImpl;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.Binding;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.Projection;
    +import org.openrdf.query.algebra.ProjectionElem;
    +import org.openrdf.query.algebra.ProjectionElemList;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +import com.beust.jcommander.internal.Lists;
    +import com.google.common.collect.Sets;
    +
    +/**
    + * Tests the methods of {@link OneOfVisitor}.
    + */
    +public class OneOfVisitorTest {
    +    private final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    +    private static final ValueFactory VF = new ValueFactoryImpl();
    +
    +    private static final URI SUITS = VF.createURI("urn:Suits");
    +    private static final URI RANKS = VF.createURI("urn:Ranks");
    +
    +    // Definition #1: :Suits owl:oneOf(:Clubs, :Diamonds, :Hearts, :Spades)
    +    private static final URI CLUBS = VF.createURI("urn:Clubs");
    +    private static final URI DIAMONDS = VF.createURI("urn:Diamonds");
    +    private static final URI HEARTS = VF.createURI("urn:Hearts");
    +    private static final URI SPADES = VF.createURI("urn:Spades");
    +
    +    // Definition #2: :Ranks owl:oneOf(:Ace, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +    private static final URI ACE = VF.createURI("urn:Ace");
    +    private static final URI TWO = VF.createURI("urn:2");
    +    private static final URI THREE = VF.createURI("urn:3");
    +    private static final URI FOUR = VF.createURI("urn:4");
    +    private static final URI FIVE = VF.createURI("urn:5");
    +    private static final URI SIX = VF.createURI("urn:6");
    +    private static final URI SEVEN = VF.createURI("urn:7");
    +    private static final URI EIGHT = VF.createURI("urn:8");
    +    private static final URI NINE = VF.createURI("urn:9");
    +    private static final URI TEN = VF.createURI("urn:10");
    +    private static final URI JACK = VF.createURI("urn:Jack");
    +    private static final URI QUEEN = VF.createURI("urn:Queen");
    +    private static final URI KING = VF.createURI("urn:King");
    +
    +    private static final Set<Resource> CARD_SUIT_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        );
    +    private static final Set<Resource> CARD_RANK_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(
    +                ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN,
    +                JACK, QUEEN, KING
    +            )
    +        );
    +
    +    @Test
    +    public void testOneOf() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    --- End diff --
    
    Good catch.  Removed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/444/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by jessehatfield <gi...@git.apache.org>.
Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135080995
  
    --- Diff: sail/src/test/java/org/apache/rya/rdftriplestore/inference/OneOfVisitorTest.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNotNull;
    +import static org.junit.Assert.assertTrue;
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.rya.accumulo.AccumuloRdfConfiguration;
    +import org.junit.Test;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.Value;
    +import org.openrdf.model.ValueFactory;
    +import org.openrdf.model.impl.ValueFactoryImpl;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.Binding;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.Projection;
    +import org.openrdf.query.algebra.ProjectionElem;
    +import org.openrdf.query.algebra.ProjectionElemList;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +import com.beust.jcommander.internal.Lists;
    +import com.google.common.collect.Sets;
    +
    +/**
    + * Tests the methods of {@link OneOfVisitor}.
    + */
    +public class OneOfVisitorTest {
    +    private final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    +    private static final ValueFactory VF = new ValueFactoryImpl();
    +
    +    private static final URI SUITS = VF.createURI("urn:Suits");
    +    private static final URI RANKS = VF.createURI("urn:Ranks");
    +
    +    // Definition #1: :Suits owl:oneOf(:Clubs, :Diamonds, :Hearts, :Spades)
    +    private static final URI CLUBS = VF.createURI("urn:Clubs");
    +    private static final URI DIAMONDS = VF.createURI("urn:Diamonds");
    +    private static final URI HEARTS = VF.createURI("urn:Hearts");
    +    private static final URI SPADES = VF.createURI("urn:Spades");
    +
    +    // Definition #2: :Ranks owl:oneOf(:Ace, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +    private static final URI ACE = VF.createURI("urn:Ace");
    +    private static final URI TWO = VF.createURI("urn:2");
    +    private static final URI THREE = VF.createURI("urn:3");
    +    private static final URI FOUR = VF.createURI("urn:4");
    +    private static final URI FIVE = VF.createURI("urn:5");
    +    private static final URI SIX = VF.createURI("urn:6");
    +    private static final URI SEVEN = VF.createURI("urn:7");
    +    private static final URI EIGHT = VF.createURI("urn:8");
    +    private static final URI NINE = VF.createURI("urn:9");
    +    private static final URI TEN = VF.createURI("urn:10");
    +    private static final URI JACK = VF.createURI("urn:Jack");
    +    private static final URI QUEEN = VF.createURI("urn:Queen");
    +    private static final URI KING = VF.createURI("urn:King");
    +
    +    private static final Set<Resource> CARD_SUIT_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        );
    +    private static final Set<Resource> CARD_RANK_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(
    +                ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN,
    +                JACK, QUEEN, KING
    +            )
    +        );
    +
    +    @Test
    +    public void testOneOf() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    --- End diff --
    
    Doesn't look like this is used


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by jessehatfield <gi...@git.apache.org>.
Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135073684
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,108 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  ?card a <urn:Card> . \n"
    +                + "  VALUES ?suit { <urn:Clubs> <urn:Diamonds> <urn:Hearts> <urn:Spades> } . \n"
    +                + "  ?card <urn:HasSuit> ?suit . \n"
    +                + "}}";
    +        log.info("Running Explicit Query");
    +        CountingResultHandler resultHandler = new CountingResultHandler();
    +        TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
    +        tupleQuery.evaluate(resultHandler);
    +        log.info("Result count : " + resultHandler.getCount());
    +        Validate.isTrue(resultHandler.getCount() == 5);
    +        log.info("Adding owl:oneOf Schema");
    +        // ONTOLOGY - :Suits oneOf (:Clubs, :Diamonds, :Hearts, :Spades)
    +        // ONTOLOGY - :Ranks oneOf (:Ace, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +        final String ontology = "INSERT DATA { GRAPH <http://updated/test> {\n"
    +                + "  <urn:Suits> owl:oneOf _:bnodeS1 . \n"
    +                + "  _:bnodeS1 rdf:first <urn:Clubs> . \n"
    +                + "  _:bnodeS1 rdf:rest _:bnodeS2 . \n"
    +                + "  _:bnodeS2 rdf:first <urn:Diamonds> . \n"
    +                + "  _:bnodeS2 rdf:rest _:bnodeS3 . \n"
    +                + "  _:bnodeS3 rdf:first <urn:Hearts> . \n"
    +                + "  _:bnodeS3 rdf:rest _:bnodeS4 . \n"
    +                + "  _:bnodeS4 rdf:first <urn:Spades> . \n"
    +                + "  _:bnodeS4 rdf:rest rdf:nil . \n"
    +                + "  <urn:Ranks> owl:oneOf _:bnodeR1 . \n"
    +                + "  _:bnodeR1 rdf:first <urn:Ace> . \n"
    +                + "  _:bnodeR1 rdf:rest _:bnodeR2 . \n"
    +                + "  _:bnodeR2 rdf:first <urn:2> . \n"
    +                + "  _:bnodeR2 rdf:rest _:bnodeR3 . \n"
    +                + "  _:bnodeR3 rdf:first <urn:3> . \n"
    +                + "  _:bnodeR3 rdf:rest _:bnodeR4 . \n"
    +                + "  _:bnodeR4 rdf:first <urn:4> . \n"
    +                + "  _:bnodeR4 rdf:rest _:bnodeR5 . \n"
    +                + "  _:bnodeR5 rdf:first <urn:5> . \n"
    +                + "  _:bnodeR5 rdf:rest _:bnodeR6 . \n"
    +                + "  _:bnodeR6 rdf:first <urn:6> . \n"
    +                + "  _:bnodeR6 rdf:rest _:bnodeR7 . \n"
    +                + "  _:bnodeR7 rdf:first <urn:7> . \n"
    +                + "  _:bnodeR7 rdf:rest _:bnodeR8 . \n"
    +                + "  _:bnodeR8 rdf:first <urn:8> . \n"
    +                + "  _:bnodeR8 rdf:rest _:bnodeR9 . \n"
    +                + "  _:bnodeR9 rdf:first <urn:9> . \n"
    +                + "  _:bnodeR9 rdf:rest _:bnodeR10 . \n"
    +                + "  _:bnodeR10 rdf:first <urn:10> . \n"
    +                + "  _:bnodeR10 rdf:rest _:bnodeR11 . \n"
    +                + "  _:bnodeR11 rdf:first <urn:Jack> . \n"
    +                + "  _:bnodeR11 rdf:rest _:bnodeR12 . \n"
    +                + "  _:bnodeR12 rdf:first <urn:Queen> . \n"
    +                + "  _:bnodeR12 rdf:rest _:bnodeR13 . \n"
    +                + "  _:bnodeR13 rdf:first <urn:King> . \n"
    +                + "  _:bnodeR13 rdf:rest rdf:nil . \n"
    +                + "  <urn:Card> rdfs:equivalentClass [\n"
    +                + "    owl:onProperty <urn:HasRank> ; owl:range <urn:Ranks> ;\n"
    +                + "    owl:onProperty <urn:HasSuit> ; owl:range <urn:Suits> ;\n"
    +                + "  ] . \n"
    --- End diff --
    
    Not sure what this :Card equivalentClass statement is meant to express, but I don't think it's quite right. Looks like it doesn't affect the queries. But if we want to keep it for example purposes:
    1. onProperty doesn't interact with (rdfs:)range; range applies directly to the property regardless of what type of object has it. If you want to tie it to Card specifically, you could use owl:allValuesFrom, owl:someValuesFrom, or a cardinality restriction (owl:cardinality, owl:qualifiedCardinality, owl:minQualifiedCardinality, ...), depending on what you want to express. Or if you want to make a more general statement you could say "<urn:hasRank> rdfs:range <urn:Ranks>" (if anything has a rank, then the rank is a urn:hasRank).
    2. Two property restrictions in the same class won't really work like that, since there's no way to make sure the right onProperty triple goes with the right someValuesFrom/allValuesFrom/cardinality/etc triple.
    
    So one alternative formulation might be:
    ```
    <urn:Card> owl:intersectionOf (
        [ owl:onProperty <urn:HasRank> ; owl:someValuesFrom <urn:Ranks> ] 
        [ owl:onProperty <urn:HasSuit> ; owl:someValuesFrom <urn:Suits> ]
    )
    ```
    That says a Card is anything with at least one Suits for hasSuit and at least one Ranks for hasRank. (I don't think Rya will be able to apply that inference right now since it relies on combining intersection and someValuesFrom logic.)
    Replace someValuesFrom with allValuesFrom and it says: Anything a Card has for a hasSuit is a Suits, and anything a Card has for hasRank is a Ranks.
    Or replace with something involving cardinality, or some combination of expressions, or just the range expressions without restricting to Card.
    But the simplest thing would be to remove it, and it looks like that would be safe.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135109178
  
    --- Diff: sail/src/test/java/org/apache/rya/rdftriplestore/inference/OneOfVisitorTest.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNotNull;
    +import static org.junit.Assert.assertTrue;
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.rya.accumulo.AccumuloRdfConfiguration;
    +import org.junit.Test;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.Value;
    +import org.openrdf.model.ValueFactory;
    +import org.openrdf.model.impl.ValueFactoryImpl;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.Binding;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.Projection;
    +import org.openrdf.query.algebra.ProjectionElem;
    +import org.openrdf.query.algebra.ProjectionElemList;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +import com.beust.jcommander.internal.Lists;
    +import com.google.common.collect.Sets;
    +
    +/**
    + * Tests the methods of {@link OneOfVisitor}.
    + */
    +public class OneOfVisitorTest {
    +    private final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    +    private static final ValueFactory VF = new ValueFactoryImpl();
    +
    +    private static final URI SUITS = VF.createURI("urn:Suits");
    +    private static final URI RANKS = VF.createURI("urn:Ranks");
    +
    +    // Definition #1: :Suits owl:oneOf(:Clubs, :Diamonds, :Hearts, :Spades)
    +    private static final URI CLUBS = VF.createURI("urn:Clubs");
    +    private static final URI DIAMONDS = VF.createURI("urn:Diamonds");
    +    private static final URI HEARTS = VF.createURI("urn:Hearts");
    +    private static final URI SPADES = VF.createURI("urn:Spades");
    +
    +    // Definition #2: :Ranks owl:oneOf(:Ace, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +    private static final URI ACE = VF.createURI("urn:Ace");
    +    private static final URI TWO = VF.createURI("urn:2");
    +    private static final URI THREE = VF.createURI("urn:3");
    +    private static final URI FOUR = VF.createURI("urn:4");
    +    private static final URI FIVE = VF.createURI("urn:5");
    +    private static final URI SIX = VF.createURI("urn:6");
    +    private static final URI SEVEN = VF.createURI("urn:7");
    +    private static final URI EIGHT = VF.createURI("urn:8");
    +    private static final URI NINE = VF.createURI("urn:9");
    +    private static final URI TEN = VF.createURI("urn:10");
    +    private static final URI JACK = VF.createURI("urn:Jack");
    +    private static final URI QUEEN = VF.createURI("urn:Queen");
    +    private static final URI KING = VF.createURI("urn:King");
    +
    +    private static final Set<Resource> CARD_SUIT_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        );
    +    private static final Set<Resource> CARD_RANK_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(
    +                ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN,
    +                JACK, QUEEN, KING
    +            )
    +        );
    +
    +    @Test
    +    public void testOneOf() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    +        enumerations.put(SUITS, CARD_SUIT_ENUMERATION);
    +        when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true);
    +        when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION);
    +        enumerations.put(RANKS, CARD_RANK_ENUMERATION);
    +        when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true);
    +        when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION);
    +        // Query for a  Suits and rewrite using the visitor:
    +        final Projection query = new Projection(
    +                new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)),
    +                new ProjectionElemList(new ProjectionElem("s", "subject")));
    +        query.visit(new OneOfVisitor(conf, inferenceEngine));
    +        // Expected structure: BindingSetAssignment containing the enumeration:
    +        // BindingSetAssignment(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        // Collect the arguments to the BindingSetAssignment:
    +        assertTrue(query.getArg() instanceof BindingSetAssignment);
    +        final BindingSetAssignment bsa = (BindingSetAssignment) query.getArg();
    +        final Iterable<BindingSet> iterable = bsa.getBindingSets();
    +        final Iterator<BindingSet> iter = iterable.iterator();
    +
    +        assertBindingSet(iter, CARD_SUIT_ENUMERATION.iterator());
    +
    +        // Query for a Ranks and rewrite using the visitor:
    +        final Projection query2 = new Projection(
    +                new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", RANKS)),
    +                new ProjectionElemList(new ProjectionElem("s", "subject")));
    +        query2.visit(new OneOfVisitor(conf, inferenceEngine));
    +        // Expected structure: BindingSetAssignment containing the enumeration:
    +        // BindingSetAssignment(ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, JACK, QUEEN, KING)
    +        // Collect the arguments to the BindingSetAssignment:
    +        assertTrue(query2.getArg() instanceof BindingSetAssignment);
    +        final BindingSetAssignment bsa2 = (BindingSetAssignment) query2.getArg();
    +        final Iterable<BindingSet> iterable2 = bsa2.getBindingSets();
    +        final Iterator<BindingSet> iter2 = iterable2.iterator();
    +
    +        assertBindingSet(iter2, CARD_RANK_ENUMERATION.iterator());
    +    }
    +
    +    @Test
    +    public void testOneOfDisabled() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    --- End diff --
    
    Done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135052173
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,112 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  { ?card <urn:HasSuit> <urn:Clubs> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Diamonds> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Hearts> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Spades> }\n"
    +                + "}}";
    +        log.info("Running Explicit Query");
    +        CountingResultHandler resultHandler = new CountingResultHandler();
    +        TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
    +        tupleQuery.evaluate(resultHandler);
    +        log.info("Result count : " + resultHandler.getCount());
    +        Validate.isTrue(resultHandler.getCount() == 5);
    +        log.info("Adding owl:oneOf Schema");
    +        // ONTOLOGY - :Suits oneOf (:Clubs, :Diamonds, :Hearts, :Spades)
    +        // ONTOLOGY - :Ranks oneOf (:Ace, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +        final String ontology = "INSERT DATA { GRAPH <http://updated/test> {\n"
    +                + "  <urn:Suits> owl:oneOf _:bnodeS1 . \n"
    +                + "  _:bnodeS1 rdf:first <urn:Clubs> . \n"
    +                + "  _:bnodeS1 rdf:rest _:bnodeS2 . \n"
    +                + "  _:bnodeS2 rdf:first <urn:Diamonds> . \n"
    +                + "  _:bnodeS2 rdf:rest _:bnodeS3 . \n"
    +                + "  _:bnodeS3 rdf:first <urn:Hearts> . \n"
    +                + "  _:bnodeS3 rdf:rest _:bnodeS4 . \n"
    +                + "  _:bnodeS4 rdf:first <urn:Spades> . \n"
    +                + "  _:bnodeS4 rdf:rest rdf:nil . \n"
    +                + "  <urn:Ranks> owl:oneOf _:bnodeR1 . \n"
    +                + "  _:bnodeR1 rdf:first <urn:Ace> . \n"
    +                + "  _:bnodeR1 rdf:rest _:bnodeR2 . \n"
    +                + "  _:bnodeR2 rdf:first <urn:2> . \n"
    +                + "  _:bnodeR2 rdf:rest _:bnodeR3 . \n"
    +                + "  _:bnodeR3 rdf:first <urn:3> . \n"
    +                + "  _:bnodeR3 rdf:rest _:bnodeR4 . \n"
    +                + "  _:bnodeR4 rdf:first <urn:4> . \n"
    +                + "  _:bnodeR4 rdf:rest _:bnodeR5 . \n"
    +                + "  _:bnodeR5 rdf:first <urn:5> . \n"
    +                + "  _:bnodeR5 rdf:rest _:bnodeR6 . \n"
    +                + "  _:bnodeR6 rdf:first <urn:6> . \n"
    +                + "  _:bnodeR6 rdf:rest _:bnodeR7 . \n"
    +                + "  _:bnodeR7 rdf:first <urn:7> . \n"
    +                + "  _:bnodeR7 rdf:rest _:bnodeR8 . \n"
    +                + "  _:bnodeR8 rdf:first <urn:8> . \n"
    +                + "  _:bnodeR8 rdf:rest _:bnodeR9 . \n"
    +                + "  _:bnodeR9 rdf:first <urn:9> . \n"
    +                + "  _:bnodeR9 rdf:rest _:bnodeR10 . \n"
    +                + "  _:bnodeR10 rdf:first <urn:10> . \n"
    +                + "  _:bnodeR10 rdf:rest _:bnodeR11 . \n"
    +                + "  _:bnodeR11 rdf:first <urn:Jack> . \n"
    +                + "  _:bnodeR11 rdf:rest _:bnodeR12 . \n"
    +                + "  _:bnodeR12 rdf:first <urn:Queen> . \n"
    +                + "  _:bnodeR12 rdf:rest _:bnodeR13 . \n"
    +                + "  _:bnodeR13 rdf:first <urn:King> . \n"
    +                + "  _:bnodeR13 rdf:rest rdf:nil . \n"
    +                + "  <urn:Card> rdfs:equivalentClass [\n"
    +                + "    owl:onProperty <urn:HasRank> ; owl:range <urn:Ranks> ;\n"
    +                + "    owl:onProperty <urn:HasSuit> ; owl:range <urn:Suits> ;\n"
    +                + "  ] . \n"
    +                + "}}";
    +        update = conn.prepareUpdate(QueryLanguage.SPARQL, ontology);
    +        update.execute();
    +        log.info("Running Inference-dependent Query without refreshing InferenceEngine");
    +        resultHandler.resetCount();
    +        final String inferQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    --- End diff --
    
    It should be expanded to:
    SELECT ?card { GRAPH <http://updated/test> {
    ?card a <urn:Card> .
    VALUES ?suit { <urn:Clubs> <urn:Diamonds> <urn:Hearts> <urn:Spades> } .
    ?card <urn:HasSuit> ?suit
    }}
    The explicit query was just showing how it would be done without the ontology. I can replace it with the expanded query.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by meiercaleb <gi...@git.apache.org>.
Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135040985
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,112 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  { ?card <urn:HasSuit> <urn:Clubs> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Diamonds> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Hearts> }\n"
    +                + "  UNION \n"
    +                + "  { ?card <urn:HasSuit> <urn:Spades> }\n"
    +                + "}}";
    +        log.info("Running Explicit Query");
    +        CountingResultHandler resultHandler = new CountingResultHandler();
    +        TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
    +        tupleQuery.evaluate(resultHandler);
    +        log.info("Result count : " + resultHandler.getCount());
    +        Validate.isTrue(resultHandler.getCount() == 5);
    +        log.info("Adding owl:oneOf Schema");
    +        // ONTOLOGY - :Suits oneOf (:Clubs, :Diamonds, :Hearts, :Spades)
    +        // ONTOLOGY - :Ranks oneOf (:Ace, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +        final String ontology = "INSERT DATA { GRAPH <http://updated/test> {\n"
    +                + "  <urn:Suits> owl:oneOf _:bnodeS1 . \n"
    +                + "  _:bnodeS1 rdf:first <urn:Clubs> . \n"
    +                + "  _:bnodeS1 rdf:rest _:bnodeS2 . \n"
    +                + "  _:bnodeS2 rdf:first <urn:Diamonds> . \n"
    +                + "  _:bnodeS2 rdf:rest _:bnodeS3 . \n"
    +                + "  _:bnodeS3 rdf:first <urn:Hearts> . \n"
    +                + "  _:bnodeS3 rdf:rest _:bnodeS4 . \n"
    +                + "  _:bnodeS4 rdf:first <urn:Spades> . \n"
    +                + "  _:bnodeS4 rdf:rest rdf:nil . \n"
    +                + "  <urn:Ranks> owl:oneOf _:bnodeR1 . \n"
    +                + "  _:bnodeR1 rdf:first <urn:Ace> . \n"
    +                + "  _:bnodeR1 rdf:rest _:bnodeR2 . \n"
    +                + "  _:bnodeR2 rdf:first <urn:2> . \n"
    +                + "  _:bnodeR2 rdf:rest _:bnodeR3 . \n"
    +                + "  _:bnodeR3 rdf:first <urn:3> . \n"
    +                + "  _:bnodeR3 rdf:rest _:bnodeR4 . \n"
    +                + "  _:bnodeR4 rdf:first <urn:4> . \n"
    +                + "  _:bnodeR4 rdf:rest _:bnodeR5 . \n"
    +                + "  _:bnodeR5 rdf:first <urn:5> . \n"
    +                + "  _:bnodeR5 rdf:rest _:bnodeR6 . \n"
    +                + "  _:bnodeR6 rdf:first <urn:6> . \n"
    +                + "  _:bnodeR6 rdf:rest _:bnodeR7 . \n"
    +                + "  _:bnodeR7 rdf:first <urn:7> . \n"
    +                + "  _:bnodeR7 rdf:rest _:bnodeR8 . \n"
    +                + "  _:bnodeR8 rdf:first <urn:8> . \n"
    +                + "  _:bnodeR8 rdf:rest _:bnodeR9 . \n"
    +                + "  _:bnodeR9 rdf:first <urn:9> . \n"
    +                + "  _:bnodeR9 rdf:rest _:bnodeR10 . \n"
    +                + "  _:bnodeR10 rdf:first <urn:10> . \n"
    +                + "  _:bnodeR10 rdf:rest _:bnodeR11 . \n"
    +                + "  _:bnodeR11 rdf:first <urn:Jack> . \n"
    +                + "  _:bnodeR11 rdf:rest _:bnodeR12 . \n"
    +                + "  _:bnodeR12 rdf:first <urn:Queen> . \n"
    +                + "  _:bnodeR12 rdf:rest _:bnodeR13 . \n"
    +                + "  _:bnodeR13 rdf:first <urn:King> . \n"
    +                + "  _:bnodeR13 rdf:rest rdf:nil . \n"
    +                + "  <urn:Card> rdfs:equivalentClass [\n"
    +                + "    owl:onProperty <urn:HasRank> ; owl:range <urn:Ranks> ;\n"
    +                + "    owl:onProperty <urn:HasSuit> ; owl:range <urn:Suits> ;\n"
    +                + "  ] . \n"
    +                + "}}";
    +        update = conn.prepareUpdate(QueryLanguage.SPARQL, ontology);
    +        update.execute();
    +        log.info("Running Inference-dependent Query without refreshing InferenceEngine");
    +        resultHandler.resetCount();
    +        final String inferQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    --- End diff --
    
    Would this query be expanded out to the following?
    
    select distinct ?card {Graph... {
    ?card a <urn:Card>
    ?card <urn:HasSuit> ?suit
    Union {?suit a <urn:Club>}
    Union {?suit a <urn:Diamond}
    Union {?suit a <urn:Heart}
    Union {?suit a <urn:Spade}}}
    
    I'm just trying to reconcile this with the explicit query above.  Is that query meant to reflect what the query will look like after expansion, or was that just meant to get the right results?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/430/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by ejwhite922 <gi...@git.apache.org>.
Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135109057
  
    --- Diff: extras/indexingExample/src/main/java/MongoRyaDirectExample.java ---
    @@ -572,6 +573,108 @@ public static void testAllValuesFromInference(final SailRepositoryConnection con
             Validate.isTrue(resultHandler.getCount() == 2);
         }
     
    +    public static void testOneOfInference(final SailRepositoryConnection conn, final Sail sail) throws MalformedQueryException, RepositoryException, UpdateExecutionException, QueryEvaluationException, TupleQueryResultHandlerException, InferenceEngineException {
    +        log.info("Adding Data");
    +        final String instances = "INSERT DATA"
    +                + "{ GRAPH <http://updated/test> {\n"
    +                + "  <urn:FlopCard1> a <urn:Card> . \n"
    +                + "    <urn:FlopCard1> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard1> <urn:HasSuit> <urn:Diamonds> . \n"
    +                + "  <urn:FlopCard2> a <urn:Card> . \n"
    +                + "    <urn:FlopCard2> <urn:HasRank> <urn:Ace> . \n"
    +                + "    <urn:FlopCard2> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "  <urn:FlopCard3> a <urn:Card> . \n"
    +                + "    <urn:FlopCard3> <urn:HasRank> <urn:King> . \n"
    +                + "    <urn:FlopCard3> <urn:HasSuit> <urn:Spades> . \n"
    +                + "  <urn:TurnCard> a <urn:Card> . \n"
    +                + "    <urn:TurnCard> <urn:HasRank> <urn:10> . \n"
    +                + "    <urn:TurnCard> <urn:HasSuit> <urn:Clubs> . \n"
    +                + "  <urn:RiverCard> a <urn:Card> . \n"
    +                + "    <urn:RiverCard> <urn:HasRank> <urn:Queen> . \n"
    +                + "    <urn:RiverCard> <urn:HasSuit> <urn:Hearts> . \n"
    +                + "}}";
    +        Update update = conn.prepareUpdate(QueryLanguage.SPARQL, instances);
    +        update.execute();
    +        final String explicitQuery = "select distinct ?card { GRAPH <http://updated/test> {\n"
    +                + "  ?card a <urn:Card> . \n"
    +                + "  VALUES ?suit { <urn:Clubs> <urn:Diamonds> <urn:Hearts> <urn:Spades> } . \n"
    +                + "  ?card <urn:HasSuit> ?suit . \n"
    +                + "}}";
    +        log.info("Running Explicit Query");
    +        CountingResultHandler resultHandler = new CountingResultHandler();
    +        TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, explicitQuery);
    +        tupleQuery.evaluate(resultHandler);
    +        log.info("Result count : " + resultHandler.getCount());
    +        Validate.isTrue(resultHandler.getCount() == 5);
    +        log.info("Adding owl:oneOf Schema");
    +        // ONTOLOGY - :Suits oneOf (:Clubs, :Diamonds, :Hearts, :Spades)
    +        // ONTOLOGY - :Ranks oneOf (:Ace, :1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +        final String ontology = "INSERT DATA { GRAPH <http://updated/test> {\n"
    +                + "  <urn:Suits> owl:oneOf _:bnodeS1 . \n"
    +                + "  _:bnodeS1 rdf:first <urn:Clubs> . \n"
    +                + "  _:bnodeS1 rdf:rest _:bnodeS2 . \n"
    +                + "  _:bnodeS2 rdf:first <urn:Diamonds> . \n"
    +                + "  _:bnodeS2 rdf:rest _:bnodeS3 . \n"
    +                + "  _:bnodeS3 rdf:first <urn:Hearts> . \n"
    +                + "  _:bnodeS3 rdf:rest _:bnodeS4 . \n"
    +                + "  _:bnodeS4 rdf:first <urn:Spades> . \n"
    +                + "  _:bnodeS4 rdf:rest rdf:nil . \n"
    +                + "  <urn:Ranks> owl:oneOf _:bnodeR1 . \n"
    +                + "  _:bnodeR1 rdf:first <urn:Ace> . \n"
    +                + "  _:bnodeR1 rdf:rest _:bnodeR2 . \n"
    +                + "  _:bnodeR2 rdf:first <urn:2> . \n"
    +                + "  _:bnodeR2 rdf:rest _:bnodeR3 . \n"
    +                + "  _:bnodeR3 rdf:first <urn:3> . \n"
    +                + "  _:bnodeR3 rdf:rest _:bnodeR4 . \n"
    +                + "  _:bnodeR4 rdf:first <urn:4> . \n"
    +                + "  _:bnodeR4 rdf:rest _:bnodeR5 . \n"
    +                + "  _:bnodeR5 rdf:first <urn:5> . \n"
    +                + "  _:bnodeR5 rdf:rest _:bnodeR6 . \n"
    +                + "  _:bnodeR6 rdf:first <urn:6> . \n"
    +                + "  _:bnodeR6 rdf:rest _:bnodeR7 . \n"
    +                + "  _:bnodeR7 rdf:first <urn:7> . \n"
    +                + "  _:bnodeR7 rdf:rest _:bnodeR8 . \n"
    +                + "  _:bnodeR8 rdf:first <urn:8> . \n"
    +                + "  _:bnodeR8 rdf:rest _:bnodeR9 . \n"
    +                + "  _:bnodeR9 rdf:first <urn:9> . \n"
    +                + "  _:bnodeR9 rdf:rest _:bnodeR10 . \n"
    +                + "  _:bnodeR10 rdf:first <urn:10> . \n"
    +                + "  _:bnodeR10 rdf:rest _:bnodeR11 . \n"
    +                + "  _:bnodeR11 rdf:first <urn:Jack> . \n"
    +                + "  _:bnodeR11 rdf:rest _:bnodeR12 . \n"
    +                + "  _:bnodeR12 rdf:first <urn:Queen> . \n"
    +                + "  _:bnodeR12 rdf:rest _:bnodeR13 . \n"
    +                + "  _:bnodeR13 rdf:first <urn:King> . \n"
    +                + "  _:bnodeR13 rdf:rest rdf:nil . \n"
    +                + "  <urn:Card> rdfs:equivalentClass [\n"
    +                + "    owl:onProperty <urn:HasRank> ; owl:range <urn:Ranks> ;\n"
    +                + "    owl:onProperty <urn:HasSuit> ; owl:range <urn:Suits> ;\n"
    +                + "  ] . \n"
    --- End diff --
    
    I replaced with the intersectionOf example and added separate range statements for HasRank and HasSuit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by jessehatfield <gi...@git.apache.org>.
Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135081022
  
    --- Diff: sail/src/test/java/org/apache/rya/rdftriplestore/inference/OneOfVisitorTest.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertNotNull;
    +import static org.junit.Assert.assertTrue;
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.rya.accumulo.AccumuloRdfConfiguration;
    +import org.junit.Test;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.Value;
    +import org.openrdf.model.ValueFactory;
    +import org.openrdf.model.impl.ValueFactoryImpl;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.Binding;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.Projection;
    +import org.openrdf.query.algebra.ProjectionElem;
    +import org.openrdf.query.algebra.ProjectionElemList;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +import com.beust.jcommander.internal.Lists;
    +import com.google.common.collect.Sets;
    +
    +/**
    + * Tests the methods of {@link OneOfVisitor}.
    + */
    +public class OneOfVisitorTest {
    +    private final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    +    private static final ValueFactory VF = new ValueFactoryImpl();
    +
    +    private static final URI SUITS = VF.createURI("urn:Suits");
    +    private static final URI RANKS = VF.createURI("urn:Ranks");
    +
    +    // Definition #1: :Suits owl:oneOf(:Clubs, :Diamonds, :Hearts, :Spades)
    +    private static final URI CLUBS = VF.createURI("urn:Clubs");
    +    private static final URI DIAMONDS = VF.createURI("urn:Diamonds");
    +    private static final URI HEARTS = VF.createURI("urn:Hearts");
    +    private static final URI SPADES = VF.createURI("urn:Spades");
    +
    +    // Definition #2: :Ranks owl:oneOf(:Ace, :2, :3, :4, :5, :6, :7, :8, :9, :10, :Jack, :Queen, :King)
    +    private static final URI ACE = VF.createURI("urn:Ace");
    +    private static final URI TWO = VF.createURI("urn:2");
    +    private static final URI THREE = VF.createURI("urn:3");
    +    private static final URI FOUR = VF.createURI("urn:4");
    +    private static final URI FIVE = VF.createURI("urn:5");
    +    private static final URI SIX = VF.createURI("urn:6");
    +    private static final URI SEVEN = VF.createURI("urn:7");
    +    private static final URI EIGHT = VF.createURI("urn:8");
    +    private static final URI NINE = VF.createURI("urn:9");
    +    private static final URI TEN = VF.createURI("urn:10");
    +    private static final URI JACK = VF.createURI("urn:Jack");
    +    private static final URI QUEEN = VF.createURI("urn:Queen");
    +    private static final URI KING = VF.createURI("urn:King");
    +
    +    private static final Set<Resource> CARD_SUIT_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        );
    +    private static final Set<Resource> CARD_RANK_ENUMERATION =
    +        Sets.newLinkedHashSet(
    +            Lists.newArrayList(
    +                ACE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN,
    +                JACK, QUEEN, KING
    +            )
    +        );
    +
    +    @Test
    +    public void testOneOf() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    +        enumerations.put(SUITS, CARD_SUIT_ENUMERATION);
    +        when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true);
    +        when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION);
    +        enumerations.put(RANKS, CARD_RANK_ENUMERATION);
    +        when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true);
    +        when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION);
    +        // Query for a  Suits and rewrite using the visitor:
    +        final Projection query = new Projection(
    +                new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)),
    +                new ProjectionElemList(new ProjectionElem("s", "subject")));
    +        query.visit(new OneOfVisitor(conf, inferenceEngine));
    +        // Expected structure: BindingSetAssignment containing the enumeration:
    +        // BindingSetAssignment(CLUBS, DIAMONDS, HEARTS, SPADES)
    +        // Collect the arguments to the BindingSetAssignment:
    +        assertTrue(query.getArg() instanceof BindingSetAssignment);
    +        final BindingSetAssignment bsa = (BindingSetAssignment) query.getArg();
    +        final Iterable<BindingSet> iterable = bsa.getBindingSets();
    +        final Iterator<BindingSet> iter = iterable.iterator();
    +
    +        assertBindingSet(iter, CARD_SUIT_ENUMERATION.iterator());
    +
    +        // Query for a Ranks and rewrite using the visitor:
    +        final Projection query2 = new Projection(
    +                new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", RANKS)),
    +                new ProjectionElemList(new ProjectionElem("s", "subject")));
    +        query2.visit(new OneOfVisitor(conf, inferenceEngine));
    +        // Expected structure: BindingSetAssignment containing the enumeration:
    +        // BindingSetAssignment(ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, JACK, QUEEN, KING)
    +        // Collect the arguments to the BindingSetAssignment:
    +        assertTrue(query2.getArg() instanceof BindingSetAssignment);
    +        final BindingSetAssignment bsa2 = (BindingSetAssignment) query2.getArg();
    +        final Iterable<BindingSet> iterable2 = bsa2.getBindingSets();
    +        final Iterator<BindingSet> iter2 = iterable2.iterator();
    +
    +        assertBindingSet(iter2, CARD_RANK_ENUMERATION.iterator());
    +    }
    +
    +    @Test
    +    public void testOneOfDisabled() throws Exception {
    +        // Configure a mock instance engine with an ontology:
    +        final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    +        final Map<Resource, Set<Resource>> enumerations = new HashMap<>();
    --- End diff --
    
    Doesn't look like this is used


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by meiercaleb <gi...@git.apache.org>.
Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135049554
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java ---
    @@ -0,0 +1,80 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import java.util.LinkedHashSet;
    +import java.util.Set;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +/**
    + * Visitor for handling owl:oneOf inferencing on a node.
    + */
    +public class OneOfVisitor extends AbstractInferVisitor {
    +    private static final Logger log = Logger.getLogger(OneOfVisitor.class);
    +
    +    /**
    +     * Creates a new instance of {@link OneOfVisitor}.
    +     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.
    +     * @param inferenceEngine the {@link InferenceEngine}.
    +     */
    +    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {
    +        super(conf, inferenceEngine);
    +        include = conf.isInferOneOf();
    +    }
    +
    +    @Override
    +    protected void meetSP(final StatementPattern node) throws Exception {
    +        final Var subVar = node.getSubjectVar();
    +        final Var predVar = node.getPredicateVar();
    +        final Var objVar = node.getObjectVar();
    +        final Var conVar = node.getContextVar();
    +        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
    +            final URI object = (URI) objVar.getValue();
    +            if (inferenceEngine.isEnumeratedType(object)) {
    +                final Set<BindingSet> solutions = new LinkedHashSet<>();
    +                final Set<Resource> enumeration = inferenceEngine.getEnumeration(object);
    +                if (enumeration != null && !enumeration.isEmpty()) {
    --- End diff --
    
    If getEnumeration returned an empty Set (if no enumerations existed), you wouldn't need this check.  Also, doesn't isEnumeratedType(...) = true -> enumeration != null?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by jessehatfield <gi...@git.apache.org>.
Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135078753
  
    --- Diff: sail/src/test/java/org/apache/rya/rdftriplestore/inference/InferenceIT.java ---
    @@ -400,4 +400,97 @@ public void testIntersectionOfQuery() throws Exception {
             expectedMen.add(new ListBindingSet(varNames, vf.createURI("urn:Bob")));
             Assert.assertEquals(expectedMen, new HashSet<>(solutions));
         }
    +
    +    @Test
    +    public void testOneOfQuery() throws Exception {
    +        final String ontology = "INSERT DATA { GRAPH <http://updated/test> {\n"
    +                + "  <urn:Suits> owl:oneOf _:bnodeS1 . \n"
    +                + "  _:bnodeS1 rdf:first <urn:Clubs> . \n"
    +                + "  _:bnodeS1 rdf:rest _:bnodeS2 . \n"
    +                + "  _:bnodeS2 rdf:first <urn:Diamonds> . \n"
    +                + "  _:bnodeS2 rdf:rest _:bnodeS3 . \n"
    +                + "  _:bnodeS3 rdf:first <urn:Hearts> . \n"
    +                + "  _:bnodeS3 rdf:rest _:bnodeS4 . \n"
    +                + "  _:bnodeS4 rdf:first <urn:Spades> . \n"
    +                + "  _:bnodeS4 rdf:rest rdf:nil . \n"
    +                + "  <urn:Ranks> owl:oneOf _:bnodeR1 . \n"
    +                + "  _:bnodeR1 rdf:first <urn:Ace> . \n"
    +                + "  _:bnodeR1 rdf:rest _:bnodeR2 . \n"
    +                + "  _:bnodeR2 rdf:first <urn:2> . \n"
    +                + "  _:bnodeR2 rdf:rest _:bnodeR3 . \n"
    +                + "  _:bnodeR3 rdf:first <urn:3> . \n"
    +                + "  _:bnodeR3 rdf:rest _:bnodeR4 . \n"
    +                + "  _:bnodeR4 rdf:first <urn:4> . \n"
    +                + "  _:bnodeR4 rdf:rest _:bnodeR5 . \n"
    +                + "  _:bnodeR5 rdf:first <urn:5> . \n"
    +                + "  _:bnodeR5 rdf:rest _:bnodeR6 . \n"
    +                + "  _:bnodeR6 rdf:first <urn:6> . \n"
    +                + "  _:bnodeR6 rdf:rest _:bnodeR7 . \n"
    +                + "  _:bnodeR7 rdf:first <urn:7> . \n"
    +                + "  _:bnodeR7 rdf:rest _:bnodeR8 . \n"
    +                + "  _:bnodeR8 rdf:first <urn:8> . \n"
    +                + "  _:bnodeR8 rdf:rest _:bnodeR9 . \n"
    +                + "  _:bnodeR9 rdf:first <urn:9> . \n"
    +                + "  _:bnodeR9 rdf:rest _:bnodeR10 . \n"
    +                + "  _:bnodeR10 rdf:first <urn:10> . \n"
    +                + "  _:bnodeR10 rdf:rest _:bnodeR11 . \n"
    +                + "  _:bnodeR11 rdf:first <urn:Jack> . \n"
    +                + "  _:bnodeR11 rdf:rest _:bnodeR12 . \n"
    +                + "  _:bnodeR12 rdf:first <urn:Queen> . \n"
    +                + "  _:bnodeR12 rdf:rest _:bnodeR13 . \n"
    +                + "  _:bnodeR13 rdf:first <urn:King> . \n"
    +                + "  _:bnodeR13 rdf:rest rdf:nil . \n"
    +                + "  <urn:Card> owl:equivalentClass [\n"
    +                + "    owl:onProperty <urn:HasRank> ; owl:range <urn:Ranks> ;\n"
    +                + "    owl:onProperty <urn:HasSuit> ; owl:range <urn:Suits> ;\n"
    +                + "  ] . \n"
    --- End diff --
    
    Same comment as with the example regarding equivalent class statement


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by meiercaleb <gi...@git.apache.org>.
Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135051321
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/OneOfVisitor.java ---
    @@ -0,0 +1,80 @@
    +/*
    + * 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.
    + */
    +package org.apache.rya.rdftriplestore.inference;
    +
    +import java.util.LinkedHashSet;
    +import java.util.Set;
    +
    +import org.apache.log4j.Logger;
    +import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
    +import org.openrdf.model.Resource;
    +import org.openrdf.model.URI;
    +import org.openrdf.model.vocabulary.RDF;
    +import org.openrdf.query.BindingSet;
    +import org.openrdf.query.algebra.BindingSetAssignment;
    +import org.openrdf.query.algebra.StatementPattern;
    +import org.openrdf.query.algebra.Var;
    +import org.openrdf.query.algebra.evaluation.QueryBindingSet;
    +
    +/**
    + * Visitor for handling owl:oneOf inferencing on a node.
    + */
    +public class OneOfVisitor extends AbstractInferVisitor {
    +    private static final Logger log = Logger.getLogger(OneOfVisitor.class);
    +
    +    /**
    +     * Creates a new instance of {@link OneOfVisitor}.
    +     * @param conf the {@link RdfCloudeTripleStoreConfiguration}.
    +     * @param inferenceEngine the {@link InferenceEngine}.
    +     */
    +    public OneOfVisitor(final RdfCloudTripleStoreConfiguration conf, final InferenceEngine inferenceEngine) {
    +        super(conf, inferenceEngine);
    +        include = conf.isInferOneOf();
    +    }
    +
    +    @Override
    +    protected void meetSP(final StatementPattern node) throws Exception {
    +        final Var subVar = node.getSubjectVar();
    +        final Var predVar = node.getPredicateVar();
    +        final Var objVar = node.getObjectVar();
    +        final Var conVar = node.getContextVar();
    +        if (predVar != null && objVar != null && objVar.getValue() != null && RDF.TYPE.equals(predVar.getValue()) && !EXPANDED.equals(conVar)) {
    +            final URI object = (URI) objVar.getValue();
    +            if (inferenceEngine.isEnumeratedType(object)) {
    +                final Set<BindingSet> solutions = new LinkedHashSet<>();
    +                final Set<Resource> enumeration = inferenceEngine.getEnumeration(object);
    +                if (enumeration != null && !enumeration.isEmpty()) {
    +                    for (final Resource enumType : enumeration) {
    +                        final QueryBindingSet qbs = new QueryBindingSet();
    +                        qbs.addBinding(subVar.getName(), enumType);
    +                        solutions.add(qbs);
    +                    }
    +
    +                    if (!solutions.isEmpty()) {
    +                        final BindingSetAssignment enumNode = new BindingSetAssignment();
    --- End diff --
    
    Ahh, okay.  This makes a lot of sense.  Better than adding all of those unions!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya issue #215: RYA-300 Added owl:oneOf inference.

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit commented on the issue:

    https://github.com/apache/incubator-rya/pull/215
  
    
    Refer to this link for build results (access rights to CI server needed): 
    https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/446/



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-rya pull request #215: RYA-300 Added owl:oneOf inference.

Posted by meiercaleb <gi...@git.apache.org>.
Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/215#discussion_r135048927
  
    --- Diff: sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java ---
    @@ -1281,4 +1324,34 @@ public void setSchedule(final boolean schedule) {
             }
             return null;
         }
    +
    +    /**
    +     * For a given type, return all sets of types such that owl:oneOf
    +     * restrictions on those properties could imply this type. A enumeration
    +     * of all the types that are part of the specified class type.
    +     * @param type The type (URI or bnode) to check against the known oneOf
    +     * sets.
    +     * @return A {@link Set} of {@link Resource} types that represents the
    +     * enumeration of resources that belong to the class type.
    +     * {@code null} is returned if no enumerations were found for the specified
    +     * type.
    +     */
    +    public Set<Resource> getEnumeration(final Resource type) {
    +        if (enumerations != null) {
    +            final Set<Resource> oneOfSet = enumerations.get(type);
    +            return oneOfSet;
    +        }
    +        return null;
    --- End diff --
    
    Maybe better to return an Optional or an empty Set here than null.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---