Skip to content

Commit

Permalink
BREAKING CHANGE: Remove blogic option. Blogic is now always enabled…
Browse files Browse the repository at this point in the history
… by default. (#480)

BREAKING CHANGE: `blogic` option has been removed.
  • Loading branch information
jeswr authored Aug 1, 2023
1 parent a32bfcb commit c277d37
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const data = `

const result = await n3reasoner(data, undefined, {
output: 'derivations',
blogic: false,
outputType: 'string'
});
```
Expand All @@ -77,9 +76,6 @@ The `options` parameter can be used to configure the reasoning process. The foll
- `deductive_closure`: output deductive closure, a.k.a `--pass`
- `deductive_closure_plus_rules`: output deductive closure plus rules, a.k.a `--pass-all`
- `grounded_deductive_closure_plus_rules`: ground the rules and output deductive closure plus rules, a.k.a `--pass-all-ground`
- `blogic`: Whether to use the blogic or not. Used to support [RDF surfaces](https://w3c-cg.github.io/rdfsurfaces/).
- `true`: use blogic
- `false`: do not use blogic (default)
- `outputType`: The type of output (if different from the input)
- `string`: output as string
- `quads`: output as array of RDF/JS Quads
Expand Down
12 changes: 3 additions & 9 deletions __test_utils__/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,23 @@ export function universalTests() {

it('should reject n3reasoner on blogic and any output', async () => {
// @ts-expect-error
const res = n3reasoner(dataQuads, undefined, { output: 'dervations', blogic: true });
const res = n3reasoner(dataQuads, undefined, { output: 'dervations' });

expect(res).rejects.toThrowError()
});


it('should reject n3reasoner on query string and blogic', async () => {
const res = n3reasoner(dataQuads, '{?S ?P ?O} => {?S ?P ?O}', { blogic: true });
const res = n3reasoner(dataQuads, '{?S ?P ?O} => {?S ?P ?O}');

expect(res).rejects.toThrowError()
});
it('should execute the n3reasoner using blogic', async () => {
const resultStr: string = await n3reasoner(blogicData, undefined, { blogic: true });
const resultStr: string = await n3reasoner(blogicData);
const quads = (new Parser({ format: 'text/n3' })).parse(resultStr);
expect<Quad[]>(quads).toBeRdfIsomorphic(resultBlogicQuads);
});

it('should fail executing blogic using the n3reasoner without blogic enabled', async () => {
const resultStr: string = await n3reasoner(blogicData, undefined, { blogic: false });
const quads = (new Parser({ format: 'text/n3' })).parse(resultStr);
expect<Quad[]>(quads).not.toBeRdfIsomorphic(resultBlogicQuads);
});

it('should throw error when eye cannot process the query', async () => {
await expect(n3reasoner('invalid', 'invalid')).rejects.toThrowError('Error while executing query');
});
Expand Down
16 changes: 2 additions & 14 deletions lib/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import EYE_PVM from './eye';
import { queryOnce } from './query';

export type ICoreQueryOptions = {
blogic: true;
output?: undefined;
} | {
blogic?: false;
output?: 'derivations' | 'deductive_closure' | 'deductive_closure_plus_rules' | 'grounded_deductive_closure_plus_rules';
}

Expand Down Expand Up @@ -44,23 +40,17 @@ export function SwiplEye(options?: Partial<EmscriptenModule> | undefined) {
* @param queryString The query (in Notation3)
* @param options The reasoner options
* - output: What to output with implicit queries (default: undefined)
* - blogic: Whether to use blogic (default: false)
* @returns The same SWIPL module
*/
export function runQuery(
Module: SWIPLModule,
data: string,
queryString?: string,
{ blogic, output }: Options = {},
{ output }: Options = {},
): SWIPLModule {
const args: string[] = ['--nope', '--quiet', 'data.nq'];

if (blogic) {
if (output || queryString) {
throw new Error('Cannot use blogic with explicit output or query');
}
args.push('--blogic');
} else if (queryString) {
if (queryString) {
if (output) {
throw new Error('Cannot use explicit output with explicit query');
}
Expand Down Expand Up @@ -110,7 +100,6 @@ export type Query = Data | undefined
* @param query The query as RDF/JS quads
* @param options The reasoner options
* - output: What to output with implicit queries (default: undefined)
* - blogic: Whether to use blogic (default: false)
* - outputType: The type of output, either 'string' or 'quads' (default: type of input data)
* - SWIPL: The SWIPL module to use (default: bundled SWIPL)
* @returns The result of the query as RDF/JS quads
Expand Down Expand Up @@ -154,7 +143,6 @@ export async function executeBasicEyeQuery(swipl: typeof SWIPL, data: Data, quer
* @param query The query as RDF/JS quads
* @param options The reasoner options
* - output: What to output with implicit queries (default: undefined)
* - blogic: Whether to use blogic (default: false)
* - outputType: The type of output, either 'string' or 'quads' (default: type of input data)
* @returns The result of the query as RDF/JS quads
*/
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
},
"config": {
"eye": {
"name": "v4.10.2",
"url": "https://api.github.com/repos/eyereasoner/eye/releases/114309345"
"name": "v4.10.8",
"url": "https://api.github.com/repos/eyereasoner/eye/releases/114636496"
}
},
"dependencies": {
Expand Down

1 comment on commit c277d37

@jeswr
Copy link
Collaborator Author

@jeswr jeswr commented on c277d37 Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'EYE JS Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: c277d37 Previous: a32bfcb Ratio
Initialise SWIPL with EYE image 7.37 ops/sec (±12.68%) 9.08 ops/sec (±9.95%) 1.23
Run socrates query 6.73 ops/sec (±12.11%) 8.66 ops/sec (±9.17%) 1.29
Load data into a module 120630 ops/sec (±0.62%) 143090 ops/sec (±0.53%) 1.19
Load query into a module 149254 ops/sec (±0.56%) 165183 ops/sec (±0.34%) 1.11

This comment was automatically generated by workflow using github-action-benchmark.

CC: @jeswr

Please sign in to comment.