changeset 616:3a61a4df6d53

* RDF importer: Features that are on different timeline URIs should go into separate models (_not_ just on separate signal URIs as there may not be any meaningful signal URIs) * FileSource: if a file is not found, try again assuming its name is encoded (not just in tolerant mode)
author Chris Cannam
date Thu, 15 Oct 2009 10:50:43 +0000
parents 521438145bd7
children 24f06d34ac99
files data/fileio/FileSource.cpp rdf/RDFImporter.cpp
diffstat 2 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp	Wed Oct 07 16:45:45 2009 +0000
+++ b/data/fileio/FileSource.cpp	Thu Oct 15 10:50:43 2009 +0000
@@ -99,9 +99,9 @@
     if (!isRemote() &&
         !isAvailable()) {
 #ifdef DEBUG_FILE_SOURCE
-        std::cerr << "FileSource::FileSource: Failed to open local file with URL \"" << m_url.toString().toStdString() << "; trying again with tolerant encoding" << std::endl;
+        std::cerr << "FileSource::FileSource: Failed to open local file with URL \"" << m_url.toString().toStdString() << "; trying again assuming filename was encoded" << std::endl;
 #endif
-        m_url = QUrl(fileOrUrl, QUrl::TolerantMode);
+        m_url = QUrl::fromEncoded(fileOrUrl.toAscii());
         init();
     }
 
--- a/rdf/RDFImporter.cpp	Wed Oct 07 16:45:45 2009 +0000
+++ b/rdf/RDFImporter.cpp	Thu Oct 15 10:50:43 2009 +0000
@@ -151,7 +151,8 @@
     getDataModelsAudio(models, reporter);
 
     if (m_sampleRate == 0) {
-        std::cerr << "RDFImporter::getDataModels: invalid sample rate from audio" << std::endl;
+        m_errorString = QString("Invalid audio data model (is audio file format supported?)");
+        std::cerr << m_errorString.toStdString() << std::endl;
         return models;
     }
 
@@ -216,7 +217,16 @@
         QString signal = results[i]["signal"].value;
         QString source = results[i]["source"].value;
 
+        std::cerr << "NOTE: Seeking signal source \"" << source.toStdString()
+                  << "\"..." << std::endl;
+
         FileSource *fs = new FileSource(source, reporter);
+        if (fs->isAvailable()) {
+            std::cerr << "NOTE: Source is available: Local filename is \""
+                      << fs->getLocalFilename().toStdString()
+                      << "\"..." << std::endl;
+        }
+            
 #ifdef NO_SV_GUI
         if (!fs->isAvailable()) {
             m_errorString = QString("Signal source \"%1\" is not available").arg(source);
@@ -225,6 +235,8 @@
         }
 #else
         if (!fs->isAvailable()) {
+            std::cerr << "NOTE: Signal source \"" << source.toStdString()
+                      << "\" is not available, using file finder..." << std::endl;
             FileFinder *ff = FileFinder::getInstance();
             if (ff) {
                 QString path = ff->find(FileFinder::AudioFile,
@@ -576,7 +588,7 @@
 
     QString queryString = prefixes + QString(
 
-        " SELECT ?signal ?timed_thing ?event_type ?value"
+        " SELECT ?signal ?timed_thing ?timeline ?event_type ?value"
         " FROM <%1>"
 
         " WHERE {"
@@ -584,8 +596,8 @@
         "   ?signal a mo:Signal ."
 
         "   ?signal mo:time ?interval ."
-        "   ?interval tl:onTimeLine ?tl ."
-        "   ?time tl:onTimeLine ?tl ."
+        "   ?interval tl:onTimeLine ?timeline ."
+        "   ?time tl:onTimeLine ?timeline ."
         "   ?timed_thing event:time ?time ."
         "   ?timed_thing a ?event_type ."
 
@@ -596,6 +608,10 @@
 
         ).arg(m_uristring);
 
+    //!!! NB we're using rather old terminology for these things, apparently:
+    // beginsAt -> start
+    // onTimeLine -> timeline
+
     QString timeQueryString = prefixes + QString(
         
         " SELECT ?time FROM <%1> "
@@ -674,7 +690,7 @@
       about it.  Then return only non-empty models.
     */
 
-    // Map from signal source to event type to dimensionality to
+    // Map from timeline uri to event type to dimensionality to
     // presence of duration to model ptr.  Whee!
     std::map<QString, std::map<QString, std::map<int, std::map<bool, Model *> > > >
         modelMap;
@@ -686,6 +702,7 @@
         }
 
         QString source = results[i]["signal"].value;
+        QString timeline = results[i]["timeline"].value;
         QString type = results[i]["event_type"].value;
         QString thinguri = results[i]["timed_thing"].value;
         
@@ -747,8 +764,8 @@
 
         Model *model = 0;
 
-        if (modelMap[source][type][dimensions].find(haveDuration) ==
-            modelMap[source][type][dimensions].end()) {
+        if (modelMap[timeline][type][dimensions].find(haveDuration) ==
+            modelMap[timeline][type][dimensions].end()) {
 
 /*
             std::cerr << "Creating new model: source = " << source.toStdString()
@@ -836,11 +853,11 @@
                 (s, titleQuery, "title").value;
             if (title != "") model->setObjectName(title);
 
-            modelMap[source][type][dimensions][haveDuration] = model;
+            modelMap[timeline][type][dimensions][haveDuration] = model;
             models.push_back(model);
         }
 
-        model = modelMap[source][type][dimensions][haveDuration];
+        model = modelMap[timeline][type][dimensions][haveDuration];
 
         if (model) {
             long ftime = RealTime::realTime2Frame(time, m_sampleRate);
@@ -1001,6 +1018,9 @@
         }
     }
 
+    std::cerr << "NOTE: RDFImporter::identifyDocumentType: haveAudio = "
+              << haveAudio << std::endl;
+
     value =
         SimpleSPARQLQuery::singleResultQuery
         (SimpleSPARQLQuery::QueryFromSingleSource,
@@ -1032,6 +1052,9 @@
         }
     }
 
+    std::cerr << "NOTE: RDFImporter::identifyDocumentType: haveAnnotations = "
+              << haveAnnotations << std::endl;
+
     SimpleSPARQLQuery::closeSingleSource(url);
 
     if (haveAudio) {