AtomGraph / Processor

Ontology-driven Linked Data processor and server for SPARQL backends. Apache License.
https://hub.docker.com/r/atomgraph/processor/
Apache License 2.0
58 stars 6 forks source link

Refactor skolemization #22

Closed namedgraph closed 5 years ago

namedgraph commented 7 years ago

Currently skolemization considers all classes with ldt:skolemTemplate that:

This leads to ambiguities when a resources carries multiple rdf:type statements.

The solution would be to narrow down the class selection by only considering descendants of the class/restriction hierarchy, starting from the matching class of the current request.

Some examples follow. AVF stands for AllValuesFrom OWL restriction.

Ontology

Class                         Path

:RootContainer
- path                        "/"
- AVF(sioc:has_parent)
  :PersonContainer
  - path                      "/persons/"
  ^ AVF(sioc:has_parent)
    :Container
    - path                    "{slug}/"
  - AVF(sioc:has_container)
    :PersonItem
    - path                    "/persons/{primaryTopic.givenName}-{primaryTopic.familyName}"
    - AVF(foaf:primaryTopic)
      :Person
      - segment               "{givenName}-{familyName}"
      - fragment              "this"
  :AgentContainer
  - path                      "/agents/"
  ^ AVF(sioc:has_parent)
    :Container
    - path                    "{slug}/"
  - AVF(sioc:has_container)
    :AgentItem
    - path                    "/agents/{slug}"
    ^ segment                 "{slug}"
    - AVF(foaf:primaryTopic)
      :Agent
      - segment               "{isPrimaryTopicOf.slug}"
      - fragment              "this"
:OrganizationContainer
- path                        "/orgs/"
^ AVF(sioc:has_parent)
  :Item
  - path                      "{slug}"
:OrganizationItem
- path                        "/orgs/{slug}"
- AVF(foaf:primaryTopic)
  :Organization
  - segment?                  "{title}"
  - fragment                  "this"

Matching

Match:

<persons/sub/>                :Container
<persons/Tim-Berners-Lee>     :PersonItem
<agents/timbl>                :AgentItem
<orgs/W3C>                    :OrganizationItem

No match:

<persons/timbl>
<Tim-Berners-Lee>
<W3C>

Skolemization

Request with one rdf:type:

POST persons/

_:container a :Container ;
  dh:slug "sub" .

Result:

{

  <persons/sub/> sioc:has_parent <persons/> .

}

{

  <persons/sub/> a :Container ;
    dh:slug "sub" .

}

Request with 2 types:

POST persons/

_:item a :PersonItem, :AgentItem ;
  dh:slug "timbl" ;
  foaf:primaryTopic _:person .

_:person a :Person, :Agent ;
  foaf:givenName "Tim" ;
  foaf:familyName "Berners-Lee" ;
  foaf:isPrimaryTopic _:item .

Result:

{

  <persons/Tim-Berners-Lee> sioc:has_container <persons/> .

}

{

  <persons/Tim-Berners-Lee> a :PersonItem, :AgentItem ;
    dh:slug "timbl" ;
    foaf:primaryTopic <persons/Tim-Berners-Lee#this> .

  <persons/Tim-Berners-Lee#this> a :Person, :Agent ;
    foaf:givenName "Tim" ;
    foaf:familyName "Berners-Lee" ;
    foaf:isPrimaryTopic <persons/Tim-Berners-Lee> .

}

:PersonItem used since it is a "child" class of persons/ : :PersonContainer.

Request with non-matching item and matching topic type:

POST agents/

_:item a :PersonItem ;
  dh:slug "timbl" ;
  foaf:primaryTopic _:agent .

_:agent a :Person, :Agent ;
  foaf:givenName "Tim" ;
  foaf:familyName "Berners-Lee" ;
  foaf:isPrimaryTopic _:item .

Result:

{

  <agents/timbl> sioc:has_container <agents/> .

}

{

  _:item a :PersonItem ;
    dh:slug "timbl" ;
    foaf:primaryTopic <agents/timbl#this> .

  <agents/timbl#this> a :Person, :Agent ;
    foaf:givenName "Tim" ;
    foaf:familyName "Berners-Lee" ;
    foaf:isPrimaryTopic _:item .

}

Item is not skolemized since it has no type that is descendant of :AgentContainer. Topic is skolemized using :Agent used since it is descendant class of :AgentContainer via :AgentItem.

Request with no types:

POST orgs/

_:item dh:slug "w3c" ;
  foaf:primaryTopic _:org .

_:org dct:title "W3C" ;
  foaf:isPrimaryTopicOf _:item .

Result:

_:item dh:slug "w3c" ;
  foaf:primaryTopic _:org .

_:org dct:title "W3C" ;
  foaf:isPrimaryTopicOf _:item .

No (matching) type => not skolemized.