How to use the n3.Store function in n3

To help you get started, we’ve selected a few n3 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 DefinitelyTyped / DefinitelyTyped / types / n3 / n3-tests.ts View on Github external
const quadStream: RDF.Stream = store.match(N3.DataFactory.namedNode('http://ex.org/Mickey'));

    interface N3QuadGeneralized extends N3.BaseQuad {
      subject: N3.Quad_Subject | N3.BlankNode | N3.Literal;
      predicate: N3.Quad_Predicate | N3.BlankNode | N3.Literal;
      object: N3.Quad_Object | N3.BlankNode | N3.Literal;
      graph: N3.Quad_Graph | N3.BlankNode | N3.Literal;
    }
    interface RDFQuadGeneralized extends RDF.BaseQuad {
      subject: RDF.Quad_Subject | RDF.BlankNode | RDF.Literal;
      predicate: RDF.Quad_Predicate | RDF.BlankNode | RDF.Literal;
      object: RDF.Quad_Object | RDF.BlankNode | RDF.Literal;
      graph: RDF.Quad_Graph | RDF.BlankNode | RDF.Literal;
    }
    const storeGeneralized = new N3.Store();
    // storeGeneralized.
    storeGeneralized.addQuad(N3.DataFactory.namedNode('http://ex.org/Pluto'), N3.DataFactory.blankNode(), N3.DataFactory.namedNode('http://ex.org/Dog'));
}
github LinkedDataFragments / Server.js / lib / datasources / SummaryDatasource.js View on Github external
SummaryDatasource.prototype._initialize = function (done) {
  this._tripleStore = new N3.Store();
  // var parser = new N3.Parser();
  // var self = this;
  
  // If summaryDir does not exist, create it
  if (!fs.existsSync(this._summariesFolder)) {
    fs.mkdirSync(this._summariesFolder, { recursive: true });
  }

  // Initialize watcher.
  var watcher = chokidar.watch(this._summariesFolder, {
    ignored: /(^|[\/\\])\../,
    persistent: true
  });

  console.log(`Watching  ${this._summariesFolder}`)
  watcher.on('add', (summaryFile) => this._storeFile(summaryFile, err => console.log(err)));
github shexSpec / shex.js / packages / shex-loader / shex-loader.js View on Github external
function LoadPromise (shex, json, turtle, jsonld, schemaOptions = {}, dataOptions = {}) {
  var returns = {
    schema: ShExUtil.emptySchema(),
    data: new N3.Store(),
    schemaMeta: [],
    dataMeta: []
  };
  var promises = [];
  var schemasSeen = shex.concat(json).map(p => {
    // might be already loaded objects with a url property.
    return typeof p === "object" ? p.url : p;
  });
  var transform = null;
  if (schemaOptions && "iriTransform" in schemaOptions) {
    transform = schemaOptions.iriTransform;
    delete schemaOptions.iriTransform;
  }

  var allLoaded = DynamicPromise();
  function loadImports (schema) {
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*/];
            }
        });
    });
github Callidon / sparql-engine / tests / utils.js View on Github external
constructor() {
    super()
    this._store = Store()
    this._parser = Parser()
  }
github solid / query-ldflex / src / index.js View on Github external
(async function() {
  console.time('query')
  for (var i = 0; i < 500; i++) {
    const result = await ComunicaEngine.query(sparql, {
      source: { value: new Store(), type: 'rdfjsSource' },
    });
    const bindings = result.bindingsStream;
    await readBindings(bindings);
  }
  console.timeEnd('query')
}())
github OpenSocial / activitystreams.js / src / reasoner.js View on Github external
function Reasoner() {
  if (!(this instanceof Reasoner))
    return new Reasoner();
  utils.defineHidden(this, '_store', new N3.Store());
  _init(this);
}
Reasoner.prototype.use_stream =
github jeff-zucker / solid-file-client / src / utils / rdf-query.js View on Github external
constructor (fetch) {
    this._fetch = fetch
    this.parser = new N3.Parser()
    this.store = new N3.Store()
    /** @type {Object.} */
    this.cache = {}
    this.prefix = {}
  }
github Callidon / sparql-engine / examples / n3.js View on Github external
constructor () {
    super()
    this._store = Store()
  }
github LinkedDataFragments / Server.js / lib / datasources / MemoryDatasource.js View on Github external
MemoryDatasource.prototype._initialize = function (done) {
  var tripleStore = this._tripleStore = new N3Store();
  this._getAllTriples(function (s, p, o, g) { tripleStore.addTriple(s, p, o, g); }, done);
};