Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Remove blogic option. Blogic is now always enabled by default. #480

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading