You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by "Jesse Hatfield (JIRA)" <ji...@apache.org> on 2017/07/20 21:09:00 UTC

[jira] [Commented] (RYA-300) Implement owl:oneOf inference

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

Jesse Hatfield commented on RYA-300:
------------------------------------

Unlike other rules about types, if we know that a variable belongs to an enumeration, then we know all possible values it could take on (before being subject to any filters or joins in the rest of the query). E.g. if we have a statement pattern {{?x rdf:type :PrimaryColor}}, then we know {{?x}} must be one of {{:Red}}, {{:Green}}, or {{:Blue}}, so there's no need to keep the type itself in the query or do any further reasoning with the type. The entire statement pattern can be replaced by the set of possible values for the variable.
Example:
{code}SELECT * WHERE {
    ?color a :PrimaryColor .
    ?x :hasColor ?color .
}{code}
becomes
{code}SELECT * WHERE {
    VALUES ?color { :Red :Green :Blue }
    ?x :hasColor ?color .
}{code}
In the inference engine, we need to record enumerations at refresh time:
{code}
enumerationTypes <- Map<type, Set<resource>>
for (enumType, listHead) in query(?enumType owl:oneOf ?listHead):
    enumerationTypes[enumType] = Set<resource>()
    current <- listHead
    while current != rdf:nil:
        element <- query(current rdf:first ?)[0]
        enumerationTypes[enumType].add(element)
        current <- query(current rdf:rest ?)[0]
{code}
Then we need a visitor to replace the type statement with the enumerated set of possible bindings:
{code}
meet(StatementPattern sp):
    if sp like (?subject rdf:type :c1) and inferenceEngine.isEnumeratedType(c1): // where subject is a variable and C1 is a defined class
        solutions <- Set<BindingSet>()
        for value in inferenceEngine.getEnumeration(c1):
            bs <- BindingSet()
            bs.addBinding(value as ?subject)
            solutions.add(bs)
        enumNode <- new BindingSetAssignment()
        enumNode.setBindingSets(solutions)
        sp.replaceWith(enumNode)
{code}

> Implement owl:oneOf inference
> -----------------------------
>
>                 Key: RYA-300
>                 URL: https://issues.apache.org/jira/browse/RYA-300
>             Project: Rya
>          Issue Type: Sub-task
>          Components: sail
>            Reporter: Jesse Hatfield
>
> *{{owl:oneOf}}* defines an enumeration by associating a class with a list of resources which belong to that class.
> If the ontology states that {{:PrimaryColor}} is the class representing the enumeration {{(:Red, :Green, :Blue)}} , then a query of the form {{?x rdf:type :PrimaryColor}} should be rewritten to find bindings {{:Red}} , {{:Green}} , and {{:Blue}} for {{?x}}.



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