Mercurial > hg > svcore
comparison rdf/RDFFeatureWriter.cpp @ 510:af7b6e55895b
* Ensure text models are exported with text properties in RDF, and
imported back into text models again (instead of time/value models)
author | Chris Cannam |
---|---|
date | Mon, 08 Dec 2008 11:53:10 +0000 |
parents | 1b8c748fd7ea |
children | e7a39c45a7a4 |
comparison
equal
deleted
inserted
replaced
509:6066bde1c126 | 510:af7b6e55895b |
---|---|
82 void | 82 void |
83 RDFFeatureWriter::setTrackMetadata(QString trackId, | 83 RDFFeatureWriter::setTrackMetadata(QString trackId, |
84 TrackMetadata metadata) | 84 TrackMetadata metadata) |
85 { | 85 { |
86 m_metadata[trackId] = metadata; | 86 m_metadata[trackId] = metadata; |
87 } | |
88 | |
89 void | |
90 RDFFeatureWriter::setFixedEventTypeURI(QString uri) | |
91 { | |
92 m_fixedEventTypeURI = uri; | |
87 } | 93 } |
88 | 94 |
89 void | 95 void |
90 RDFFeatureWriter::write(QString trackId, | 96 RDFFeatureWriter::write(QString trackId, |
91 const Transform &transform, | 97 const Transform &transform, |
355 stream << endl | 361 stream << endl |
356 << RDFTransformFactory::writeTransformToRDF(transform, transformUri) | 362 << RDFTransformFactory::writeTransformToRDF(transform, transformUri) |
357 << endl; | 363 << endl; |
358 } | 364 } |
359 | 365 |
360 if (needEventType) { | 366 if (needEventType && m_fixedEventTypeURI == "") { |
361 | 367 |
362 QString uri; | 368 QString uri; |
363 if (m_syntheticEventTypeURIs.find(transform) != | 369 if (m_syntheticEventTypeURIs.find(transform) != |
364 m_syntheticEventTypeURIs.end()) { | 370 m_syntheticEventTypeURIs.end()) { |
365 uri = m_syntheticEventTypeURIs[transform]; | 371 uri = m_syntheticEventTypeURIs[transform]; |
418 const Plugin::Feature &feature = featureList[i]; | 424 const Plugin::Feature &feature = featureList[i]; |
419 uint64_t featureNumber = m_count++; | 425 uint64_t featureNumber = m_count++; |
420 | 426 |
421 stream << ":event_" << featureNumber << " a "; | 427 stream << ":event_" << featureNumber << " a "; |
422 | 428 |
423 QString eventTypeURI = desc.getOutputEventTypeURI(outputId); | 429 if (m_fixedEventTypeURI != "") { |
424 if (plain || eventTypeURI == "") { | 430 stream << m_fixedEventTypeURI << " ;\n"; |
425 if (m_syntheticEventTypeURIs.find(transform) != | 431 } else { |
426 m_syntheticEventTypeURIs.end()) { | 432 QString eventTypeURI = desc.getOutputEventTypeURI(outputId); |
427 stream << m_syntheticEventTypeURIs[transform] << " ;\n"; | 433 if (plain || eventTypeURI == "") { |
434 if (m_syntheticEventTypeURIs.find(transform) != | |
435 m_syntheticEventTypeURIs.end()) { | |
436 stream << m_syntheticEventTypeURIs[transform] << " ;\n"; | |
437 } else { | |
438 stream << ":event_type_" << outputId << " ;\n"; | |
439 } | |
428 } else { | 440 } else { |
429 stream << ":event_type_" << outputId << " ;\n"; | 441 stream << "<" << eventTypeURI << "> ;\n"; |
430 } | 442 } |
431 } else { | |
432 stream << "<" << eventTypeURI << "> ;\n"; | |
433 } | 443 } |
434 | 444 |
435 QString timestamp = feature.timestamp.toString().c_str(); | 445 QString timestamp = feature.timestamp.toString().c_str(); |
436 timestamp.replace(QRegExp("^ +"), ""); | 446 timestamp.replace(QRegExp("^ +"), ""); |
437 | 447 |
463 stream << " vamp:computed_by " << m_transformURIs[transform] << " "; | 473 stream << " vamp:computed_by " << m_transformURIs[transform] << " "; |
464 } | 474 } |
465 | 475 |
466 if (feature.label.length() > 0) { | 476 if (feature.label.length() > 0) { |
467 stream << ";\n"; | 477 stream << ";\n"; |
468 stream << " rdfs:label \"" << feature.label.c_str() << "\" "; | 478 stream << " rdfs:label \"\"\"" << feature.label.c_str() << "\"\"\" "; |
469 } | 479 } |
470 | 480 |
471 if (!feature.values.empty()) { | 481 if (!feature.values.empty()) { |
472 stream << ";\n"; | 482 stream << ";\n"; |
473 //!!! named bins? | 483 //!!! named bins? |