Skip to content

Instantly share code, notes, and snippets.

@jctoledo
Created September 26, 2013 17:17
Show Gist options
  • Save jctoledo/6717383 to your computer and use it in GitHub Desktop.
Save jctoledo/6717383 to your computer and use it in GitHub Desktop.
<?php
function write_predicate_object_counts($fh, $pred_obj_counts){
GLOBAL $dataset_uri;
GLOBAL $options;
if($pred_obj_counts !== null){
foreach($pred_obj_counts as $pred => $count){
#create a resource for the property partition
$partition_res = "http://bio2rdf.org/dataset_resource:".md5($options['url']).md5($options['url'].$pred.$count."predicate_object_count");
#add the dataset type
fwrite($fh, Quad($partition_res, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://rdfs.org/ns/void#Dataset"));
fwrite($fh, Quad($partition_res, "http://rdfs.org/ns/void#property", $pred));
fwrite($fh, QuadLiteral($partition_res, "http://rdfs.org/ns/void#entities", $count));
#now connect it back to the void:dataset
fwrite($fh, Quad($dataset_uri, "http://rdfs.org/ns/void#propertyPartition", $partition_res));
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment