[ 
https://issues.apache.org/jira/browse/RYA-293?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16120158#comment-16120158
 ] 

ASF GitHub Bot commented on RYA-293:
------------------------------------

Github user jessehatfield commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/180#discussion_r132230928
  
    --- Diff: 
sail/src/main/java/org/apache/rya/rdftriplestore/inference/InferenceEngine.java 
---
    @@ -142,6 +143,53 @@ public void refreshGraph() throws 
InferenceEngineException {
                     }
                 }
     
    +            // Add unions to the subclass graph: if c owl:unionOf LIST(c1, 
c2, ... cn), then any
    +            // instances of c1, c2, ... or cn are also instances of c, 
meaning c is a superclass
    +            // of all the rest.
    +            // (In principle, an instance of c is likewise implied to be 
at least one of the other
    +            // types, but this fact is ignored for now to avoid 
nondeterministic reasoning.)
    +            iter = RyaDAOHelper.query(ryaDAO, null, OWL.UNIONOF, null, 
conf);
    +            try {
    +                while (iter.hasNext()) {
    +                    Statement st = iter.next();
    +                    Value unionType = st.getSubject();
    +                    // Traverse the list of types constituting the union
    +                    Value current = st.getObject();
    +                    while (current instanceof Resource && 
!RDF.NIL.equals(current)) {
    +                        Resource listNode = (Resource) current;
    +                        CloseableIteration<Statement, 
QueryEvaluationException> listIter = RyaDAOHelper.query(ryaDAO,
    +                                listNode, RDF.FIRST, null, conf);
    +                        try {
    +                            if (listIter.hasNext()) {
    +                                Statement firstStatement = listIter.next();
    +                                if (firstStatement.getObject() instanceof 
Resource) {
    +                                    Resource subclass = (Resource) 
firstStatement.getObject();
    +                                    Statement subclassStatement = 
vf.createStatement(subclass, RDFS.SUBCLASSOF, unionType);
    +                                    addStatementEdge(graph, 
RDFS.SUBCLASSOF.stringValue(), subclassStatement);
    +                                }
    +                            }
    +                        } finally {
    +                            listIter.close();
    +                        }
    +                        listIter = RyaDAOHelper.query(ryaDAO, listNode, 
RDF.REST, null, conf);
    +                        try {
    +                            if (listIter.hasNext()) {
    +                                current = listIter.next().getObject();
    --- End diff --
    
    Yep, a union is given as a linked list so we just walk down adding subclass 
statements until we get to a node with no rdf:rest or with rdf:rest equal to 
rdf:nil. If the list is poorly-formed or someone tries to express the union 
using the wrong collection type ([describes unionOf 
expression](https://www.w3.org/TR/owl2-rdf-based-semantics/#Semantic_Conditions_for_Boolean_Connectives)
 | [gives interpretation of 
sequence](https://www.w3.org/TR/owl2-rdf-based-semantics/#Semantic_Conditions)) 
then it won't work. In most cases that just means the intended union isn't 
fully represented, but I suppose if it were somehow a cyclical list, we'd end 
up in an infinite loop.


> Implement owl:unionOf inference
> -------------------------------
>
>                 Key: RYA-293
>                 URL: https://issues.apache.org/jira/browse/RYA-293
>             Project: Rya
>          Issue Type: Sub-task
>          Components: sail
>            Reporter: Jesse Hatfield
>            Assignee: Jesse Hatfield
>
> An *{{owl:unionOf}}* expression defines one type to be equivalent to the 
> union of another set of types. If the ontology states that {{:Parent}} is the 
> union of {{:Mother}} and {{:Father}}, then the inference engine should 
> rewrite statement patterns of the form {{?x rdf:type :Parent}} to check for 
> resources that are stated to be any of the types {{:Mother}}, {{:Father}}, or 
> {{:Parent}}.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to