Skip to content

Instantly share code, notes, and snippets.

@jctoledo
Last active December 24, 2015 00:19
Show Gist options
  • Save jctoledo/6715580 to your computer and use it in GitHub Desktop.
Save jctoledo/6715580 to your computer and use it in GitHub Desktop.
<?php
function write_type_counts($fh, $type_counts){
GLOBAL $options;
GLOBAL $dataset_uri;
if($type_counts !== null){
foreach($type_counts as $type => $count){
#now create a resource for the class partition
$partition_res = "http://bio2rdf.org/dataset_resource:".md5($options['url']).md5($options['url'].$type.$count."type_count");
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#class", $type));
fwrite($fh, QuadLiteral($partition_res, "http://rdfs.org/ns/void#entities", $count));
#now connect it back to the corresponding void:dataset
fwrite($fh, Quad($dataset_uri, "http://rdfs.org/ns/void#classPartition", $partition_res));
}//foreach
}//if
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment