-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add data generator file (#442)
* chore: add data generator file * chore: fix lint errors * Update .gitignore
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ docs | |
lib | ||
node_modules | ||
coverage | ||
perf/data/*.trig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const N3 = require('../../lib'); | ||
|
||
const { quad, namedNode, literal } = N3.DataFactory; | ||
const dim = 30; | ||
|
||
const writer = new N3.StreamWriter(); | ||
|
||
// eslint-disable-next-line | ||
fs.rmSync(path.join(__dirname, 'data.trig'), { force: true }); | ||
const outputStream = fs.createWriteStream(path.join(__dirname, 'data.trig')); | ||
writer.pipe(outputStream); | ||
|
||
const prefix = 'http://example.org/#'; | ||
for (let i = 0; i < dim; i++) { | ||
for (let j = 0; j < dim; j++) { | ||
for (let k = 0; k < dim; k++) { | ||
for (let l = 0; l < dim; l++) { | ||
writer.write(quad( | ||
namedNode(prefix + i), namedNode(prefix + j), (k % 2 === 0 ? namedNode : literal)(prefix + k), namedNode(prefix + l), | ||
)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
writer.end(); |