Thanks a lot, your query do give me a random set, but It don't work
exactly like I would like to. I will reformulate my Sparql example:
select
?protein ?go
where
{
?protein rdf:type <http://biology.com/Protein> .
bif:random(?protein, 100) .
?protein <http://biology.com/geneOntology> ?go .
}
I don't know at first how much ?protein I have in my triplestore, but
I know its a lot. Each ?protein have a different number of
<http://biology.com/geneOntology> relation in it (between 2 and 10 for
example). I would like to avoid the "limit" statement because I would
like a constant number of ?protein (100 in the example) in each
random set and the final amount of rows will be bigger than the number
of ?protein, but I don't know by how much (from my example, it would
be between 200 and 1000 rows).
So I might use Kingsley proposal to build a procedure to fine tune the
answer you gave me.
Is there a place where bif version of rnd is explain? The one here
http://docs.openlinksw.com/virtuoso/fn_rnd.html in the Virtuoso
function guide give me a random number between 0 and n-1 . But the way
you use it has a "parameters" of ASC look different.
Thanks,
Marc-Alexandre
2010/1/21 Nathan <[email protected]>:
> Marc-Alexandre Nolin wrote:
>> Hello,
>>
>> When I do the following query:
>>
>> select distinct
>> ?s
>> where
>> {
>> ?s rdf:type <http://biology.com/Protein> .
>> }
>> limit 100
>>
>> Lets say I have 20000 objects of type protein in the triplestore. I
>> will receive a results containing 100 rows of 100 distinct proteins.
>> If I run the same query again, I will receive the same 100 distinct
>> proteins.
>>
>> Is there a way to receive a RANDOM set 100 proteins everytime I run
>> the query? I bet its not possible in Sparql itself, but could it be
>> with the Virtuoso toolset of bif:_something_ ? If its not there, how
>> can I expand the bif toolset ?
>>
>> For example, it could be a query like this:
>>
>> select distinct
>> ?s
>> where
>> {
>> ?s rdf:type <http://biology.com/Protein> .
>> bif:random(?s, 100) .
>> }
>>
>> USE : bif:random(<variable you want a random set>, <the amount you want>)
>>
>> Implemented that way, I could expand the query with other attribute.
>>
>> select distinct
>> ?s
>> where
>> {
>> ?s rdf:type <http://biology.com/Protein> .
>> bif:random(?s, 100) .
>> ?s <http://biology.com/chromosomeNumber> ?cn .
>> filter(?cn == 10) .
>> }
>>
>> Thanks,
>>
>> Marc-Alexandre Nolin
>>
>
> bif:rnd() is what you need afaik - you could try:
>
> select ?s where { ?s rdf:type <http://biology.com/Protein> ;
> <http://biology.com/chromosomeNumber> ?cn } order by asc(
> bif:rnd(2000000000, ?s) ) limit 100 ;
>
> regards!
>