W3C home > Mailing lists > Public > semantic-web@w3.org > September 2007

Re: How to eliminate bnode from N3QL query result

From: Alan Ruttenberg <alanruttenberg@gmail.com>
Date: Mon, 10 Sep 2007 03:32:02 -0400
Message-Id: <CB93E9DB-96D0-4664-8970-07F179D4D34F@gmail.com>
To: helen.chen@agfa.com, Semantic Web <semantic-web@w3.org>

BTW, if you need just the rdf subclass statements that are the result  
of that query for use in some system you could use the query:

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

construct {?a rdfs:subClassOf ?b}
from <http://purl.org/commons/galen/>
    where {?a rdfs:subClassOf ?b filter (!isBlank(?a) && !isBlank(?b))}

This can be packaged up as a URL and you can get the resultant rdf  
with a http get. For your convenience, I've made a tinyurl for the  
query: http://tinyurl.com/23zalo

-Alan


On Sep 8, 2007, at 9:48 PM, Alan Ruttenberg wrote:

> Hi Helen,
>
> Not sure about N3QL but it can be done in SPARQL, e.g.
>
> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>
> select *
> from <http://purl.org/commons/galen/>
>    where {?a rdfs:subClassOf ?b filter (!isBlank(?a) && !isBlank(?b))}
>
> You can try this against the Neurocommons triple store here:
>
> http://hcls1.csail.mit.edu:8890/nsparql/
>
> Use count(*) instead of * to see how many results you get with or  
> without the filter.
>
> Only the raw owl is loaded. There is no inference.
>
> My only thought about N3QL was to write a rule that added a type  
> assertion when something is a class but not a restriction (say  
> "namedClass") and then do the query against that class.
>
> -Alan
>
>
> On Sep 8, 2007, at 7:37 AM, helen.chen@agfa.com wrote:
>
>>
>> Dear List
>>
>> I am using N3QL to get anatomic structures and relationship from  
>> an ontology.
>>
>> When query for subclasses of a concept, some bnodes are returned,  
>> as a result of restriction on that class, for example:
>>
>> In the ontology:
>> ---------------------------------------
>> :Hip  a       owl:Class ;
>>       rdfs:subClassOf :BodyJunctionalBodyPart ;
>>       rdfs:subClassOf
>>               [ a       owl:Restriction ;
>>                 owl:onProperty :hasBetaConnection ;
>>                 owl:someValuesFrom :Thigh
>>               ] .
>> ----------------------
>>
>> So a query
>>
>> [] select {?A ?B}
>>    where {?A rdfs:subClassOf ?B}.
>>
>> will give results
>>
>> :Hip    :BodyJunctionalBodyPart
>> :Hip    var:_123456 (bnode).
>>
>> Is there a way to eliminate the bnodes in the query result, i.e by  
>> using a filter clause maybe?
>>
>> Thanks for your help.
>>
>> Helen
>
Received on Monday, 10 September 2007 07:32:48 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 07:41:59 UTC