Hi Andy,

Thank you very much for your suggestions, that makes it a lot more elegant (and 
with the BIND variable consistently some milliseconds faster). I've added the 
code as a comment in order to make it useful for others who stop by.

Cheers, Joachim

-----Ursprüngliche Nachricht-----
Von: Andy Seaborne [mailto:a...@apache.org] 
Gesendet: Samstag, 10. August 2013 16:01
An: users@jena.apache.org
Betreff: Re: Case study for Jena Text: Thesaurus-augmented search

On 09/08/13 09:12, Neubert Joachim wrote:
> I just published a blog post:
>
> http://zbw.eu/labs/en/blog/thesaurus-augmented-search-with-jena-text
>

Nice.

I think you can rewrite to avoid multiple text:query using a temporary variable 
?x, say, and BIND:

...
?x text:query ('telework' 2)
{ BIND ( ?x AS ?concept ) }
UNION { ?x skos:exactMatch ?concept }
UNION { BIND ( ?x AS ?concept )  ?concept skos:narrower ?narrower } UNION { ?x 
skos:narrower ?concept } UNION { BIND ( ?x AS ?concept )  skos:related ?related 
} UNION { ?x skos:related ?concept } ...

but if you observe it making no difference, it could be that internal Lucene 
caching means repeat use of the same query is fast.


Is ?altLabel intended, it's in the SELECT but not in the query.  If it's 
?label every where you could use more property paths:

# To specifically get ?prefLabel
{ ?concept skos:prefLabel ?prefLabel }
UNION
{ ?concept (skos:prefLabel |
             skos:altLabel |
             skos:hiddenLabel ) ?label . }
UNION { ?concept skos:exactMatch / (skos:prefLabel |
                                     skos:altLabel |
                                     skos:hiddenLabel ) ?label .

because | in property paths is the same as a UNION.

In the extreme: ? is "zero or one of" so ....

?concept skos:exactMatch? /
            (skos:prefLabel |
             skos:altLabel |
             skos:hiddenLabel ) ?label .

but there comes a point where just because you can, does not mean that 
you should :-)

        Andy

Reply via email to