Mercurial > hg > audiodb
changeset 644:404222029e27
Grab bag of populate.c improvements
no need for fileUri (and in fact it was wrong for files with %s in them); use
librdf_new_uri_from_filename.
Use the basename of the audio filename as the key, just for my own sanity.
People who want file://///// everywhere can write their own populate.c.
author | mas01cr |
---|---|
date | Tue, 13 Oct 2009 14:26:26 +0000 |
parents | 09af91f8803f |
children | 397e94f6db44 |
files | examples/runner-rdf/Makefile examples/runner-rdf/populate.c |
diffstat | 2 files changed, 7 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/runner-rdf/Makefile Tue Oct 13 14:26:24 2009 +0000 +++ b/examples/runner-rdf/Makefile Tue Oct 13 14:26:26 2009 +0000 @@ -1,7 +1,7 @@ all: populate populate: populate.c - gcc -o populate -std=c99 -lrdf -laudioDB -L../.. -I../.. -Wl,-rpath $(shell pwd)/../.. $< + gcc -o populate -std=c99 -D_GNU_SOURCE -lrdf -laudioDB -L../.. -I../.. -Wl,-rpath $(shell pwd)/../.. $< clean: -rm populate keyplot.adb
--- a/examples/runner-rdf/populate.c Tue Oct 13 14:26:24 2009 +0000 +++ b/examples/runner-rdf/populate.c Tue Oct 13 14:26:26 2009 +0000 @@ -1,5 +1,6 @@ #include <sys/types.h> #include <sys/stat.h> +#include <libgen.h> #include <unistd.h> #include <librdf.h> #include <fcntl.h> @@ -14,8 +15,7 @@ " PREFIX mo: <http://purl.org/ontology/mo/>" " PREFIX tl: <http://purl.org/NET/c4dm/timeline.owl#>" -" SELECT ?key ?value ?sample_rate ?window_length ?hop_size ?dimensions ?typetitle" -" FROM <file:///home/csr21/tmp/rdf/test2.n3> " +" SELECT ?key ?value ?sample_rate ?window_length ?hop_size ?dimensions" " WHERE { " " ?key a mo:AudioFile . " @@ -37,8 +37,6 @@ " af:value ?value . " " ?feature af:dimensions ?dimensions ." -" ?feature_signal_type dc:title ?typetitle " - " } " ; @@ -89,16 +87,10 @@ if (!(model = librdf_new_model(world, storage, NULL))) goto librdf_error; - - char *fileUri = malloc(sizeof(char)*(strlen(n3file)+6)); - sprintf(fileUri, "file:%s\0", n3file); - librdf_uri *uri; - if (!(uri = librdf_new_uri(world, fileUri))) + if (!(uri = librdf_new_uri_from_filename(world, n3file))) goto librdf_error; - free(fileUri); - librdf_parser *parser; if (!(parser = librdf_new_parser(world, "guess", NULL, NULL))) goto librdf_error; @@ -169,14 +161,12 @@ int dimension = 0; sscanf(dimensions, "%d", &dimension); datum.dim = dimension; - - node = librdf_query_results_get_binding_value_by_name(results, "typetitle"); - printf("Insert feature of type %s\n", librdf_node_get_literal_value(node)); - + // Grab key and value node = librdf_query_results_get_binding_value_by_name(results, "key"); - datum.key = librdf_uri_as_string(librdf_node_get_uri(node)); + char *key = strdup(librdf_uri_to_filename(librdf_node_get_uri(node))); + datum.key = basename(key); size_t nelements = 0; node = librdf_query_results_get_binding_value_by_name(results, "value");