comunica / comunica-feature-link-traversal

📬 Comunica packages for link traversal-based query execution
Other
8 stars 11 forks source link

Use type inference for type index traversal #49

Open rubensworks opened 2 years ago

rubensworks commented 2 years ago

Issue type:


Description:

The following query makes use of the Solid type index to detect that is should follow (and prioritize) a link to the bookmarks file:

https://comunica.github.io/comunica-feature-link-traversal-web-clients/builds/solid-default/#transientDatasources=https%3A%2F%2Frubensworks.solidcommunity.net%2Fprofile%2Fcard&query=PREFIX%20bookm%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2002%2F01%2Fbookmark%23%3E%0ASELECT%20*%20WHERE%20%7B%0A%20%20%3Fbookmark%20a%20bookm%3ABookmark%3B%0A%20%20%20%20bookm%3AhasTopic%20%3Ftopic.%0A%7D

Currently, our actor implementation depends on the presence of the ?bookmark a bookm:Bookmark pattern before it is able to detect that the type index entry for the class bookm:Bookmark should be used.

Since the query also contains the pattern ?bookmark bookm:hasTopic ?topic, it should be possible to implicitly infer this ?bookmark a bookm:Bookmark triple, since the bookm:hasTopic predicate implies that the subject is of type bookm:Bookmark.

So concretely, it should be possible to execute

PREFIX bookm: <http://www.w3.org/2002/01/bookmark#>
SELECT * WHERE {
  ?bookmark bookm:hasTopic ?topic.
}

and get the same results as we currently do with

PREFIX bookm: <http://www.w3.org/2002/01/bookmark#>
SELECT * WHERE {
  ?bookmark a bookm:Bookmark;
    bookm:hasTopic ?topic.
}

Additionally, rdfs:subClassOf should also be considered, both via predicates, and via explicit types in the query. For example, if bookm:Bookmark rdfs:subClassOf ex:Thing, and we have a type index entry for ex:Thing, then the usage of the bookm:hasTopic predicate should also result in the ex:Thing type index entry to be considered.

github-actions[bot] commented 2 years ago

Thanks for the suggestion!

rubensworks commented 11 months ago

This has been implemented in https://github.com/comunica/comunica-feature-link-traversal/tree/master/packages/actor-extract-links-solid-type-index, but has not been evaluated yet.