mirror of
https://github.com/bpmbpm/doc.git
synced 2026-04-28 11:30:42 +00:00
Add files via upload
This commit is contained in:
parent
bf3ad52a5b
commit
25cf0955a8
3 changed files with 153 additions and 0 deletions
7
test/comunica/sparql_file/proc1.trig
Normal file
7
test/comunica/sparql_file/proc1.trig
Normal 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 .
|
||||
}
|
||||
73
test/comunica/sparql_file/sparql-file_local_trig.mjs
Normal file
73
test/comunica/sparql_file/sparql-file_local_trig.mjs
Normal 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'],
|
||||
});
|
||||
*/
|
||||
73
test/comunica/sparql_file/sparql-file_local_trig_all.mjs
Normal file
73
test/comunica/sparql_file/sparql-file_local_trig_all.mjs
Normal 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'],
|
||||
});
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue