eyereasoner 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/transformers.js +2 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Distributing the [EYE](https://github.com/josd/eye) reasoner for browser and nod
|
|
|
8
8
|
[](https://github.com/semantic-release/semantic-release)
|
|
9
9
|
|
|
10
10
|
## Usage
|
|
11
|
-
|
|
11
|
+
<!--
|
|
12
12
|
The simplest way to use this package is to execute a query over a dataset and get the results
|
|
13
13
|
|
|
14
14
|
```ts
|
|
@@ -26,16 +26,35 @@ Here the inputs and outputs are both arrays of RDF/JS Quads
|
|
|
26
26
|
## Advanced usage
|
|
27
27
|
|
|
28
28
|
To have more granular control one can also use this module as follows
|
|
29
|
+
-->
|
|
30
|
+
|
|
31
|
+
An example usage of the module is as follows
|
|
29
32
|
|
|
30
33
|
```ts
|
|
31
|
-
import { SWIPL, loadEye } from 'eyereasoner';
|
|
34
|
+
import { SWIPL, loadEye, queryOnce } from 'eyereasoner';
|
|
35
|
+
|
|
36
|
+
const query = `
|
|
37
|
+
@prefix : <http://example.org/socrates#>.
|
|
38
|
+
|
|
39
|
+
{:Socrates a ?WHAT} => {:Socrates a ?WHAT}.
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
const data = `
|
|
43
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
|
44
|
+
@prefix : <http://example.org/socrates#>.
|
|
45
|
+
|
|
46
|
+
:Socrates a :Human.
|
|
47
|
+
:Human rdfs:subClassOf :Mortal.
|
|
48
|
+
|
|
49
|
+
{?A rdfs:subClassOf ?B. ?S a ?A} => {?S a ?B}.
|
|
50
|
+
`
|
|
32
51
|
|
|
33
52
|
async function main() {
|
|
34
53
|
// Instantiate a new SWIPL module and log any results it produces to the console
|
|
35
54
|
const Module = await SWIPL({ print: (str: string) => { console.log(str) }, arguments: ['-q'] });
|
|
36
55
|
|
|
37
56
|
// Load EYE into the SWIPL Module and run consule("eye.pl").
|
|
38
|
-
loadEye(
|
|
57
|
+
loadEye(Module)
|
|
39
58
|
|
|
40
59
|
// Load the the strings data and query as files data.n3 and query.n3 into the module
|
|
41
60
|
Module.FS.writeFile('data.n3', data);
|
|
@@ -44,6 +63,9 @@ async function main() {
|
|
|
44
63
|
// Execute main(['--quiet', './data.n3', '--query', './query.n3']).
|
|
45
64
|
queryOnce(Module, 'main', ['--quiet', './data.n3', '--query', './query.n3']);
|
|
46
65
|
}
|
|
66
|
+
|
|
67
|
+
main();
|
|
68
|
+
|
|
47
69
|
```
|
|
48
70
|
|
|
49
71
|
## License
|
package/dist/transformers.js
CHANGED
|
@@ -92,8 +92,8 @@ exports.executeBasicEyeQuery = executeBasicEyeQuery;
|
|
|
92
92
|
*/
|
|
93
93
|
function executeBasicEyeQueryQuads(swipl, data, queryString) {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const parser = new n3_1.Parser();
|
|
96
|
-
const writer = new n3_1.Writer();
|
|
95
|
+
const parser = new n3_1.Parser({ format: 'text/n3' });
|
|
96
|
+
const writer = new n3_1.Writer({ format: 'text/n3' });
|
|
97
97
|
return parser.parse(yield executeBasicEyeQuery(swipl, writer.quadsToString(data), writer.quadsToString(queryString)));
|
|
98
98
|
});
|
|
99
99
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eyereasoner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Distributing the [EYE](https://github.com/josd/eye) reasoner for browser and node using WebAssembly.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.js",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
61
61
|
"eslint-plugin-import": "^2.26.0",
|
|
62
62
|
"jest": "^29.3.1",
|
|
63
|
+
"jest-rdf": "^1.7.1",
|
|
63
64
|
"pre-commit": "^1.2.2",
|
|
64
65
|
"rollup": "^3.8.1",
|
|
65
66
|
"rollup-plugin-string": "^3.0.0",
|