commentsToTurtle static method
Converts movie comments to TTL format using proper RDF triples.
Implementation
static String commentsToTurtle(Map<String, String> comments) {
final triples = <URIRef, Map<URIRef, dynamic>>{};
// Create the comments list resource.
final commentsResource = localNS.withAttr('comments');
triples[commentsResource] = {
rdfType: movieListType,
nameProperty: Literal('User Comments'),
};
// Add individual comment definitions.
for (final entry in comments.entries) {
final commentResource = localNS.withAttr('comment${entry.key}');
triples[commentResource] = {
rdfType: commentType,
movieId: Literal(entry.key, datatype: XSD.int),
text: Literal(_escapeString(entry.value)),
};
}
// Define namespace bindings - only bind our custom namespaces.
final bindNamespaces = {'': localNS};
return tripleMapToTurtle(triples, bindNamespaces: bindNamespaces);
}