[Fwd: Re: sparql-help needed]

Nice bit of SPARQL from Richard...

Dan

Forwarded message 1

Jürgen,

I had a stab at this, you can find my query below. I ran it against a  
version of the SKOS spec that was sent through the Jena RDFS reasoner.  
It won't work without a reasoner.

The query returns exactly what you want for skos:Concept.

If you change skos:Concept in the query to skos:ConceptScheme, it will  
return the properties you asked for plus those six:

skos:altSymbol
skos:prefSymbol
skos:primarySubject
skos:subject
skos:symbol

I'm not sure why you excluded them from your expected results, their  
range is either rdfs:Resource or unconstrainted, so they are all  
applicable to ConceptSchemes. I think you just missed them?

So, what's the deal with skos:narrower? It doesn't have a domain  
declared, but it's declared to be a subproperty of  
skos:semanticRelation, and that has skos:Concept as its domain. So all  
you have to do is write the query to also check the domains of  
superproperties.

Best,
Richard


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT DISTINCT ?p
FROM <skos-with-inference.rdf>
WHERE {

   # Find all properties
   ?p a rdf:Property .

   # Remove non-SKOS properties
   ?p rdfs:isDefinedBy <http://www.w3.org/2004/02/skos/core> .

   # Remove deprecated properties (those that have a replacement)
   OPTIONAL {
     ?p dct:isReplacedBy ?replacement .
   }
   FILTER (!BOUND(?replacement))

   # Try to find all classes in the domain of the property
   OPTIONAL {
     ?p rdfs:subPropertyOf ?superprop .
     ?superprop rdfs:domain ?domain .
     ?class rdfs:subClassOf ?domain .
   }

   # Only keep those with unconstrained domain, or who have our target
   # class in the domain
   FILTER (!BOUND(?domain) || ?class = skos:Concept)
}
ORDER BY ?p


On 16 May 2008, at 23:42, Jürgen Jakobitsch wrote:

>
> hello,
>
> as an application developer i'm getting to the point of thinking  
> that rdf - owl and sparql
> are absolutely not for production use in any way.
>
> currently i'm developing [ trying to @ least ] a skos application  
> that should enable
> an ordinary user [ not some kind of domain expert or programmer ] to  
> create full
> skos:Concept s in a web environment, now :
>
> @ some point during the workflow i come to the point where i have to  
> let the user choose
> the properties that should be applied to a skos:Concept, say a  
> prefLabel, an altLabel and so on.
>
> how can i sparql all properties for a skos:Concept to let user choose?
>
> 1. i could check for properties with a domain skos:Concept
>   - without a reasoner i just get semanticRelation and the like. not  
> even broader or narrower
>   - with a reasoner i get narrower and broader and the like but no  
> scopeNote, definition and so on, so i just could
> 2. add a link to propertieswithoutadomainclickhere and sparql for  
> properties that don't have a domain specified, but what
> 3. if i apply the same query [ and no i do not intend to write a  
> whole set of queries for each ontology ] to a skos:ConceptScheme?
> 4. well i get skos:narrower as property suggestion for a  
> skos:ConceptScheme and that's gonna lead a shoot first - check for  
> consistence later application, which i don't want to develop.
> 5. allways displaying all properties of an ontology is not an  
> option , too.
>
> so here's the challenge :
>
> write a [ 1 one uno une yek wahid ] sparql-query that displays about  
> the following properties when i click on
>
> skos:Concept :
>
> http://www.w3.org/2004/02/skos/core#changeNote
> http://www.w3.org/2004/02/skos/core#editorialNote
> http://www.w3.org/2004/02/skos/core#historyNote
> http://www.w3.org/2004/02/skos/core#example
> http://www.w3.org/2004/02/skos/core#scopeNote
> http://www.w3.org/2004/02/skos/core#definition
> http://www.w3.org/2004/02/skos/core#note
> http://www.w3.org/2004/02/skos/core#related
> http://www.w3.org/2004/02/skos/core#narrower
> http://www.w3.org/2004/02/skos/core#broader
> http://www.w3.org/2004/02/skos/core#semanticRelation
> http://www.w3.org/2004/02/skos/core#altSymbol
> http://www.w3.org/2004/02/skos/core#prefSymbol
> http://www.w3.org/2004/02/skos/core#symbol
> http://www.w3.org/2004/02/skos/core#hiddenLabel
> http://www.w3.org/2004/02/skos/core#altLabel
> http://www.w3.org/2004/02/skos/core#prefLabel
> http://www.w3.org/2004/02/skos/core#inScheme
> http://www.w3.org/2004/02/skos/core#isSubjectOf
> http://www.w3.org/2004/02/skos/core#subject
> http://www.w3.org/2004/02/skos/core#isPrimarySubjectOf
> http://www.w3.org/2004/02/skos/core#primarySubject
> http://www.w3.org/2004/02/skos/core#subjectIndicator
>
> and the following properties when i click on
>
> skos:ConceptScheme :
>
> http://www.w3.org/2004/02/skos/core#hasTopConcept
>
> http://www.w3.org/2004/02/skos/core#changeNote
> http://www.w3.org/2004/02/skos/core#editorialNote
> http://www.w3.org/2004/02/skos/core#historyNote
> http://www.w3.org/2004/02/skos/core#example
> http://www.w3.org/2004/02/skos/core#scopeNote
> http://www.w3.org/2004/02/skos/core#definition
> http://www.w3.org/2004/02/skos/core#note
> http://www.w3.org/2004/02/skos/core#hiddenLabel
> http://www.w3.org/2004/02/skos/core#altLabel
> http://www.w3.org/2004/02/skos/core#prefLabel
> ....
> but without the narrower : the question for me here is how can i  
> apply the (!bound(?Domain)) to say skos:scopeNote but remove  
> skos:narrower from the result set, which itself hasnt got a domain  
> specified.
>
>

Received on Monday, 19 May 2008 11:11:05 UTC