Re: Querying a dataset with inconsistent properties

Hi Misty,

the solution would be to make each of the graph patterns optional (
http://www.w3.org/TR/sparql11-query/#optionals), which can be specified as
a param of the pattern method (
http://rubydoc.info/github/ruby-rdf/rdf/RDF/Query:pattern):

RDF::Query.new do
  pattern [:concept, RDF.type, RDF::SKOS.Concept]
  pattern [:concept, RDF::SKOS.prefLabel, :prefLabel]
  pattern [:concept, RDF::SKOS.altLabel, :altLabel], optional: true
  pattern [:concept, RDF::SKOS.broader, :broader], optional: true
  pattern [:concept, RDF::SKOS.related, :related], optional: true
  pattern [:concept, RDF::SKOS.scopeNote, :scopeNote], optional: true
end

If you don't want to enumerate all the optional properties a skos:Concept
might have, then you can retrieve them via SPARQL as well:

SELECT DISTINCT ?property
WHERE {
  [] a skos:Concept ;
    ?property [] .
}

Then you can use the results to generate the above-mentioned query.

Best,

Jindřich


On Fri, Dec 20, 2013 at 5:08 AM, Misty De Meo <mistydemeo@gmail.com> wrote:

> Hi,
>
> I'm constructing a query to fetch SKOS concepts from a set of
> concepts. I'm looking to return each concept with all of its
> statements, e.g. prefLabel, altLabel, etc. I was using the following
> query, specifying the symbol mapping:
>
> RDF::Query.new concept: {
>   RDF.type => RDF::SKOS.Concept,
>   RDF::SKOS.prefLabel => :prefLabel,
>   RDF::SKOS.altLabel => :altLabel,
>   RDF::SKOS.broader => :broader,
>   RDF::SKOS.related => :related,
>   RDF::SKOS.scopeNote => :scopeNote
> }
>
> However, this only returns concepts which have *each* of those
> properties - it ignores, for example, concepts which have no `related`
> predicates. What would be the best query to use to fetch all concepts
> and their properties?
>
> Best,
> Misty De Meo
>
>
>

Received on Friday, 20 December 2013 11:06:08 UTC