Add files via upload

This commit is contained in:
Dmitry 2025-03-14 16:10:24 +03:00 committed by GitHub
parent bf3ad52a5b
commit 25cf0955a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 153 additions and 0 deletions

View file

@ -0,0 +1,7 @@
@prefix : <http://example.org/> .
:gp1 {
:p1.1 :hasNext :p1.2 .
:p1.2 :hasNext :p1.3 .
:p1.3 :hasNext :p1.4 .
}

View file

@ -0,0 +1,73 @@
// const QueryEngine = require('@comunica/query-sparql-file').QueryEngine;
import { QueryEngine } from '@comunica/query-sparql-file';
const myEngine = new QueryEngine();
const bindingsStream = await myEngine.queryBindings(`
SELECT ?s ?p ?o ?g
WHERE {
GRAPH ?g {
?s ?p <http://example.org/p1.3>.
?s ?p ?o
}
} LIMIT 7`, {
sources: ['proc1.trig'],
});
// ?s ?p <http://example.org/p1.3>.
// ?s ?p <http://example.org/object3>.
// ?s ?p ?o .
// FILTER(?o = <http://example.org/object3>)
// sources: ['file.ttl', 'file2.ttl'], // sources: ['file.ttl'], Äîáàâëåí âòîðîé ôàéë file2.ttl
// ?s ?p ?o
// ?s ?p <http://dbpedia.org/resource/Belgium>.
// Consume results as a stream (best performance)
bindingsStream.on('data', (binding) => {
console.log(binding.toString()); // Quick way to print bindings for testing
console.log(binding.has('s')); // Will be true
// Obtaining values
console.log(binding.get('s').value);
console.log(binding.get('s').termType);
console.log(binding.get('p').value);
console.log(binding.get('o').value); // Òåïåðü ýòî áóäåò ðàáîòàòü
console.log(binding.get('g').value); // Äëÿ TriG
});
bindingsStream.on('end', () => {
// The data-listener will not be called anymore once we get here.
});
bindingsStream.on('error', (error) => {
console.error(error);
});
// Consume results as async iterable (easier)
for await (const binding of bindingsStream) {
console.log(binding.toString());
}
/*
// Consume results as an array (easier)
// console.log(bindings[0].get('s').value);
// TypeError: Cannot read properties of undefined (reading 'get')
const bindings = await bindingsStream.toArray();
console.log(bindings[0].get('s').value);
console.log(bindings[0].get('s').termType);
*/
/*
const bindingsStream = await myEngine.queryBindings(`
SELECT ?s ?p ?o
WHERE {
GRAPH ?g {
?s ?p ?o
}
} LIMIT 7`, {
sources: ['proc1.trig'],
});
*/

View file

@ -0,0 +1,73 @@
// const QueryEngine = require('@comunica/query-sparql-file').QueryEngine;
import { QueryEngine } from '@comunica/query-sparql-file';
const myEngine = new QueryEngine();
const bindingsStream = await myEngine.queryBindings(`
SELECT ?s ?p ?o ?g
WHERE {
GRAPH ?g {
?s ?p ?o
}
} LIMIT 7`, {
sources: ['proc1.trig'],
});
// ?s ?p <http://example.org/p1.3>.
// ?s ?p <http://example.org/object3>.
// ?s ?p ?o .
// FILTER(?o = <http://example.org/object3>)
// sources: ['file.ttl', 'file2.ttl'], // sources: ['file.ttl'], Äîáàâëåí âòîðîé ôàéë file2.ttl
// ?s ?p ?o
// ?s ?p <http://dbpedia.org/resource/Belgium>.
// Consume results as a stream (best performance)
bindingsStream.on('data', (binding) => {
console.log(binding.toString()); // Quick way to print bindings for testing
console.log(binding.has('s')); // Will be true
// Obtaining values
console.log(binding.get('s').value);
console.log(binding.get('s').termType);
console.log(binding.get('p').value);
console.log(binding.get('o').value); // Òåïåðü ýòî áóäåò ðàáîòàòü
console.log(binding.get('g').value); // Äëÿ TriG
});
bindingsStream.on('end', () => {
// The data-listener will not be called anymore once we get here.
});
bindingsStream.on('error', (error) => {
console.error(error);
});
// Consume results as async iterable (easier)
for await (const binding of bindingsStream) {
console.log(binding.toString());
}
/*
// Consume results as an array (easier)
// console.log(bindings[0].get('s').value);
// TypeError: Cannot read properties of undefined (reading 'get')
const bindings = await bindingsStream.toArray();
console.log(bindings[0].get('s').value);
console.log(bindings[0].get('s').termType);
*/
/*
const bindingsStream = await myEngine.queryBindings(`
SELECT ?s ?p ?o
WHERE {
GRAPH ?g {
?s ?p ?o
}
} LIMIT 7`, {
sources: ['proc1.trig'],
});
*/