# HG changeset patch # User mas01cr # Date 1255443986 0 # Node ID 404222029e2788d5a4bc033843c2bf2e929f5b4b # Parent 09af91f8803f5b66f5ee1b890100c876b2fe2ef1 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. diff -r 09af91f8803f -r 404222029e27 examples/runner-rdf/Makefile --- 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 diff -r 09af91f8803f -r 404222029e27 examples/runner-rdf/populate.c --- 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 #include +#include #include #include #include @@ -14,8 +15,7 @@ " PREFIX mo: " " PREFIX tl: " -" SELECT ?key ?value ?sample_rate ?window_length ?hop_size ?dimensions ?typetitle" -" FROM " +" 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");