diff rdf/RDFImporter.cpp @ 589:a03aafaacb5a

* Make SV capable of importing the signal/audiofile structure now written out by Sonic Annotator
author Chris Cannam
date Thu, 14 May 2009 14:33:40 +0000
parents d04b8674b710
children 3a61a4df6d53
line wrap: on
line diff
--- a/rdf/RDFImporter.cpp	Wed May 13 13:30:08 2009 +0000
+++ b/rdf/RDFImporter.cpp	Thu May 14 14:33:40 2009 +0000
@@ -151,7 +151,7 @@
     getDataModelsAudio(models, reporter);
 
     if (m_sampleRate == 0) {
-        std::cerr << "RDFImporter::getDataModels: invalid sample rate" << std::endl;
+        std::cerr << "RDFImporter::getDataModels: invalid sample rate from audio" << std::endl;
         return models;
     }
 
@@ -182,18 +182,35 @@
 RDFImporterImpl::getDataModelsAudio(std::vector<Model *> &models,
                                     ProgressReporter *reporter)
 {
-    SimpleSPARQLQuery query = SimpleSPARQLQuery
+    SimpleSPARQLQuery query
         (SimpleSPARQLQuery::QueryFromSingleSource,
          QString
          (
              " PREFIX mo: <http://purl.org/ontology/mo/> "
              " SELECT ?signal ?source FROM <%1> "
-             " WHERE { ?signal a mo:Signal ; mo:available_as ?source } "
+             " WHERE { ?source a mo:AudioFile . "
+             "         ?signal a mo:Signal . "
+             "         ?source mo:encodes ?signal } "
              )
          .arg(m_uristring));
 
     SimpleSPARQLQuery::ResultList results = query.execute();
 
+    if (results.empty()) {
+
+        SimpleSPARQLQuery query2
+            (SimpleSPARQLQuery::QueryFromSingleSource,
+             QString
+             (
+                 " PREFIX mo: <http://purl.org/ontology/mo/> "
+                 " SELECT ?signal ?source FROM <%1> "
+                 " WHERE { ?signal a mo:Signal ; mo:available_as ?source } "
+                 )
+             .arg(m_uristring));
+        
+        results = query.execute();
+    }
+
     for (int i = 0; i < results.size(); ++i) {
 
         QString signal = results[i]["signal"].value;
@@ -254,7 +271,7 @@
         reporter->setMessage(RDFImporter::tr("Importing dense signal data from RDF..."));
     }
 
-    SimpleSPARQLQuery query = SimpleSPARQLQuery
+    SimpleSPARQLQuery query
         (SimpleSPARQLQuery::QueryFromSingleSource,
          QString
          (