get_candidate_values($pool_uri); $index = rand(0, count($values) - 1); if ( $this->select_value( $pool_uri, $values[$index], 100) ) { return $values[$index]; } } function get_candidate_values($pool_uri, $max = 5) { if ( !isset( $this->bigfootSparqlService) ) { $bigfoot = new Store(STORE_URI); $this->bigfootSparqlService = $bigfoot->get_sparql_service(); } $query="PREFIX p: CONSTRUCT {<$pool_uri> p:value ?v . } WHERE { <$pool_uri> p:value ?v . } LIMIT $max"; $triples = $this->bigfootSparqlService->graph_to_triple_list($query ); $candidates = array(); if ( is_array( $triples ) ) { foreach ($triples as $triple) { if ( $triple['p'] = 'http://purl.org/vocab/value-pools/schema#value' && $triple['o_type']=='literal') { array_push($candidates, $triple['o']); } } } return $candidates; } function select_value($pool_uri, $value, $pool_size) { if ( !isset( $this->bigfootMetabox) ) { $bigfoot = new Store(STORE_URI); $this->bigfootMetabox = $bigfoot->get_metabox(); } $changeset = ' pool Selecting key ' . $value . ' ' . ($pool_size + $value) . ' '; $response = $this->bigfootMetabox->apply_changeset_rdfxml( $changeset ); // echo "
";
    // echo htmlspecialchars(print_r($response, true));
    // echo "
"; return true; } } ?>