W3C home > Mailing lists > Public > public-rdf-ruby@w3.org > December 2013

Re: Querying a dataset with inconsistent properties

From: Jindřich Mynarz <mynarzjindrich@gmail.com>
Date: Fri, 20 Dec 2013 12:05:17 +0100
Message-ID: <CAE=8Bu_Z9rUieQ09_bhw+0q=hYB5cAJ3E0N+qY2OJMNbfexxnA@mail.gmail.com>
To: Misty De Meo <mistydemeo@gmail.com>
Cc: public-rdf-ruby@w3.org
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 (

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

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:

  [] a skos:Concept ;
    ?property [] .

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



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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:16 UTC