UNPKG

eyereasoner

Version:

Distributing the [EYE](https://github.com/eyereasoner/eye) reasoner for browser and node using WebAssembly.

108 lines (107 loc) 5.71 kB
import { Quad } from '@rdfjs/types'; import SWIPL, { type SWIPLModule } from 'swipl-wasm/dist/swipl/swipl-bundle-no-data'; export type ICoreQueryOptions = { output?: 'derivations' | 'deductive_closure' | 'deductive_closure_plus_rules' | 'grounded_deductive_closure_plus_rules' | 'none'; }; export type Options = ICoreQueryOptions & { outputType?: 'string' | 'quads'; SWIPL?: typeof SWIPL; cb?: (res: string) => Promise<string>; }; type IOptions = Options & { imageLoader?(swipl: typeof SWIPL): (options?: Partial<EmscriptenModule> | undefined) => Promise<SWIPLModule>; }; export declare function loadImage(image: string): (swipl: typeof SWIPL) => (options?: Partial<EmscriptenModule> | undefined) => Promise<SWIPL.SWIPLModule>; export declare const loadEyeImage: (swipl: typeof SWIPL) => (options?: Partial<EmscriptenModule> | undefined) => Promise<SWIPL.SWIPLModule>; /** * Creates default SWIPL image loaded with EYE */ export declare function SwiplEye(options?: Partial<EmscriptenModule> | undefined): Promise<SWIPL.SWIPLModule>; /** * Execute a query over a given data file * @param Module A SWIPL Module * @param data The data for the query (in Notation3) * @param queryString The query (in Notation3) * @param options The reasoner options * - output: What to output with implicit queries (default: undefined) * - cb: An EXPERIMENTAL callback to be used for question/answering (default: undefined) * @returns The same SWIPL module */ export declare function runQuery(Module: SWIPLModule, data: string[], queryString: string | undefined, options: Options & { cb?: undefined; }, noOptions?: boolean): SWIPLModule; export declare function runQuery(Module: SWIPLModule, data: string[], queryString?: string, options?: Options, // eslint-disable-line default-param-last noOptions?: boolean): SWIPLModule | Promise<SWIPLModule>; export type Data = Quad[] | string; export type InputData = Data | [string, ...string[]]; export type Query = Data | undefined; /** * Executes a basic query using the EYE Reasoner and default build of SWIPL * @param data The data for the query as RDF/JS quads * @param query The query as RDF/JS quads * @param options The reasoner options * - output: What to output with implicit queries (default: undefined) * - 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 a string or RDF/JS quads */ export declare function executeBasicEyeQuery(swipl: typeof SWIPL, data: InputData, query: Query, options: { outputType: 'string'; } & IOptions): Promise<string>; export declare function executeBasicEyeQuery(swipl: typeof SWIPL, data: InputData, query: Query, options: { outputType: 'quads'; } & IOptions): Promise<Quad[]>; export declare function executeBasicEyeQuery(swipl: typeof SWIPL, data: Quad[], query?: Query, options?: { outputType?: undefined; } & IOptions): Promise<Quad[]>; export declare function executeBasicEyeQuery(swipl: typeof SWIPL, data: string | [string, ...string[]], query?: Query, options?: { outputType?: undefined; } & IOptions): Promise<string>; export declare function executeBasicEyeQuery(swipl: typeof SWIPL, data: InputData, query?: Query, options?: IOptions): Promise<Quad[] | string>; /** * Executes a basic query using the EYE Reasoner and default build of SWIPL * @param swipl The base SWIPL module to use * @param data The data for the query as RDF/JS quads * @param query The query as RDF/JS quads * @param options The reasoner options * - output: What to output with implicit queries (default: undefined) * - outputType: The type of output, either 'string' or 'quads' (default: type of input data) * @returns The result of the query as a string or RDF/JS quads */ export declare function n3reasoner(data: InputData, query: Query, options: { outputType: 'string'; } & Options): Promise<string>; export declare function n3reasoner(data: InputData, query: Query, options: { outputType: 'quads'; } & Options): Promise<Quad[]>; export declare function n3reasoner(data: Quad[], query?: Query, options?: { outputType?: undefined; } & Options): Promise<Quad[]>; export declare function n3reasoner(data: string | [string, ...string[]], query?: Query, options?: { outputType?: undefined; } & Options): Promise<string>; export declare function n3reasoner(data: InputData, query?: Query, options?: Options): Promise<Quad[] | string>; /** * Executes a basic lingua query using the SEE Reasoner and default build of SWIPL * @param swipl The base SWIPL module to use * @param data The data for the query as RDF/JS quads * @param query The query as RDF/JS quads * @param options The reasoner options * - output: What to output with implicit queries (default: undefined) * - outputType: The type of output, either 'string' or 'quads' (default: type of input data) * @returns The result of the query as a string or RDF/JS quads */ export declare function linguareasoner(data: InputData, query: Query, options: { outputType: 'string'; } & Options): Promise<string>; export declare function linguareasoner(data: InputData, query: Query, options: { outputType: 'quads'; } & Options): Promise<Quad[]>; export declare function linguareasoner(data: Quad[], query?: Query, options?: { outputType?: undefined; } & Options): Promise<Quad[]>; export declare function linguareasoner(data: string | [string, ...string[]], query?: Query, options?: { outputType?: undefined; } & Options): Promise<string>; export declare function linguareasoner(data: InputData, query?: Query, options?: Options): Promise<Quad[] | string>; export {};