Re: How to eliminate bnode from N3QL query result

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 Sunday, 9 September 2007 01:48:55 UTC