You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
constttl_read=require('@graphy/content.ttl.read');constdataset=require('@graphy/memory.dataset.fast');lety_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(letg_quadofy_dataset_a){console.log(g_quad.toString());}// or matchfor(letg_quadofy_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?
The text was updated successfully, but these errors were encountered: