How to use @comunica/actor-init-sparql-rdfjs - 3 common examples

To help you get started, we’ve selected a few @comunica/actor-init-sparql-rdfjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inrupt / wac-ldp / test-comunica.ts View on Github external
async function test () {
  // This can be any RDFJS source
  // In this example, we wrap an N3Store
  const store = new Store()
  store.addQuad(DataFactory.quad(
    DataFactory.namedNode('a'), DataFactory.namedNode('b'), DataFactory.namedNode('http://dbpedia.org/resource/Belgium')))
  store.addQuad(DataFactory.quad(
    DataFactory.namedNode('a'), DataFactory.namedNode('b'), DataFactory.namedNode('http://dbpedia.org/resource/Ghent')))

  // Create our engine, and query it.
  // If you intend to query multiple times, be sure to cache your engine for optimal performance.
  const myEngine = newEngine()
  const result: any = await myEngine.query('SELECT * { ?s ?p . ?s ?p ?o } LIMIT 100',
    { sources: [ { type: 'rdfjsSource', value: store } ] })
  result.bindingsStream.on('data', (data: any) => {
    console.log(data)
  })
}
void test()
github inrupt / wac-ldp / src / lib / operationHandlers / readBlobHandler.ts View on Github external
async function applyQuery (dataset: any, sparqlQuery: string): Promise {
  const store = new Store()
  dataset.forEach((quad: any) => {
    debug('quad', quad.toString())
    store.addQuad(quad)
  })
  const myEngine = newEngine()
  const result: any = await myEngine.query(sparqlQuery,
    { sources: [ { type: 'rdfjsSource', value: store } ] })
  // const sparqlResult = await myEngine.resultToString(result, 'application/json')
  // debug(sparqlResult)
  const bindings = await new Promise((resolve) => {
    const bindings: any = []
    result.bindingsStream.on('end', () => {
      resolve(bindings)
    })
    result.bindingsStream.on('data', (data: any) => {
      const binding: any = {}
      const obj = JSON.parse(JSON.stringify(data))
      debug(obj)
      for (const key in obj) {
        binding[removeLeadingQuestionMark(key)] = {
          type: obj[key].termType.toLowerCase(),
github inrupt / wac-ldp / test-comunica.js View on Github external
return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    store = new n3_1.Store();
                    store.addQuad(n3_1.DataFactory.quad(n3_1.DataFactory.namedNode('a'), n3_1.DataFactory.namedNode('b'), n3_1.DataFactory.namedNode('http://dbpedia.org/resource/Belgium')));
                    store.addQuad(n3_1.DataFactory.quad(n3_1.DataFactory.namedNode('a'), n3_1.DataFactory.namedNode('b'), n3_1.DataFactory.namedNode('http://dbpedia.org/resource/Ghent')));
                    myEngine = actor_init_sparql_rdfjs_1.newEngine();
                    return [4 /*yield*/, myEngine.query('SELECT * { ?s ?p . ?s ?p ?o } LIMIT 100', { sources: [{ type: 'rdfjsSource', value: store }] })];
                case 1:
                    result = _a.sent();
                    result.bindingsStream.on('data', function (data) {
                        console.log(data);
                    });
                    return [2 /*return*/];
            }
        });
    });

@comunica/actor-init-sparql-rdfjs

Deprecated: A SPARQL query engine for querying over RDF/JS sources

MIT
Latest version published 6 months ago

Package Health Score

75 / 100
Full package analysis

Popular @comunica/actor-init-sparql-rdfjs functions

Similar packages