Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
config
.gitignore
.npmignore
README.md
index-browser.ts
index.ts
package.json
tsconfig.json
tslint.json
webpack.config.js

README.md

Comunica SPARQL RDFJS Init Actor

npm version

A comunica SPARQL RDFJS Init Actor that can query RDFJS sources that implement the Source interface.

This module is part of the Comunica framework.

Install

$ yarn add @comunica/actor-init-sparql-rdfjs

Usage

const newEngine = require('@comunica/actor-init-sparql-rdfjs').newEngine;
const N3Store = require('n3').Store;
const DataFactory = require('n3').DataFactory;

// This can be any RDFJS source
// In this example, we wrap an N3Store
const store = new N3Store();
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')));
const source = {
  match: function(s, p, o, g) {
    return require('streamify-array')(store.getQuads(s, p, o, g));
  }
};

// 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 = await myEngine.query('SELECT * { ?s ?p <http://dbpedia.org/resource/Belgium>. ?s ?p ?o } LIMIT 100',
  { sources: [ { type: 'rdfjsSource', value: source } ] });
result.bindingsStream.on('data', (data) => {
  // Each data object contains a mapping from variables to RDFJS terms.
  console.log(data.get('?s'));
  console.log(data.get('?p'));
  console.log(data.get('?o'));
});
You can’t perform that action at this time.