Open pwin opened 4 years ago
Thanks for asking, there is now the graphy-js/community chat room on gitter. I should add a badge to the README.
As for your question, you don't need to use createStream
, graphy will do this for you. Just pass the string directly to the ttl_read
function and pipe it onto the dataset. Then you can iterate the dataset or use Dataset#match
method to fetch predicates and objects belonging to a certain subject, etc.
const ttl_read = require('@graphy/content.ttl.read');
const dataset = require('@graphy/memory.dataset.fast');
let y_dataset_a = dataset();
ttl_read(value)
.pipe(y_dataset_a)
.on('finish', () => {
// dataset is now ready in memory, you can iterate using [Symbol.iterator]
for(let g_quad of y_dataset_a) {
console.log(g_quad.toString());
}
// or match
for(let g_quad of y_dataset_a.match(factory.namedNode('http://eg.org/subject/A'))) {
// ...
}
});
Hi. I've a general question and wonder if there's a forum for these questions?
My question is, I am trying to create a dataset from a turtle string "value" in an editor pane using the following
` function createStream (s) { const resumer = require('resumer'); var stream = resumer(); stream.queue(s); return stream; } function ingestTurtle(value){ const ttl_read = require('@graphy/content.ttl.read'); const dataset = require('@graphy/memory.dataset.fast');
let y_input_a = dataset(); createStream(value) .pipe(ttl_read()) .pipe(y_input_a);
}`
Is this a correct interpretation of the code? If so, how can I iterate through the subjects and how in can I then find the predicates and objects for each subject?