パッケージの詳細

@comunica/utils-expression-evaluator

comunica6.5kMIT4.2.0

A simple SPARQL expression evaluator

sparql, expression, rdf, evaluator

readme

Comunica Expression Evaluator

npm version

Previously called sparqlee - sparql expression evaluator. A simple spec-compliant SPARQL 1.1 expression evaluator package.

Learn more about the expression evaluator.

This module is part of the Comunica framework, and should only be used by developers that want to build their own query engine.

Click here if you just want to query with Comunica.

Install

$ yarn add @comunica/utils-expression-evaluator

Exposed classes

Development

Setup locally

  1. Install yarn and node.
  2. Run yarn install.
  3. Use these evident commands (or check package.json):
    • building once: yarn run build

Layout and control flow

SPARQL Algebra expression can be transformed to an internal representation (see AlgebraTransformer.ts). This will build objects (see expressions module) that contain all the logic and data for evaluation. After transformation, the evaluator will recursively evaluate all the expressions.

Testing

The testing environment is set up to do a lot of tests with little code. The files responsible for fluent behaviour reside in the test/util module. Most tests can be run by running the runTestTable method in utils. This method expects a TestTable. Multiple test are run over a TestTable (one for every line). A TestTable may contain aliases if the aliases are also provided (Some handy aliases reside in Aliases.ts). This means that when testing something like "3"^^xsd:integer equals "3"^^xsd:integer is "true"^^xsd:boolean. We would write a small table (for this example some more tests are added) and test it like this:

import { bool, merge, numeric } from './util/Aliases';
import { Notation } from './util/TruthTable';
import { runTestTable } from './util/utils';
runTestTable({
  testTable: `
       3i 3i = true
       3i -5i = false
       -0f 0f = true
       NaN  NaN = false
   `,
  arity: 2,
  operation: '=',
  aliases: merge(numeric, bool),
  notation: Notation.Infix,
});

More options can be provided and are explained with the type definition of the argument of runTestTable.

We can also provide an errorTable to the runTestTable method. This is used when we want to test if calling certain functions on certain arguments throws the error we want. An example is testing whether Unknown named operator error is thrown when we don't provide the implementation for an extension function.

import { bool, merge, numeric } from './util/Aliases';
import { Notation } from './util/TruthTable';
import { runTestTable } from './util/utils';
runTestTable({
  errorTable: `
       3i 3i = 'Unknown named operator'
       3i -5i = 'Unknown named operator'
       -0f 0f = 'Unknown named operator'
       NaN  NaN = 'Unknown named operator'
   `,
  arity: 2,
  operation: '<https://example.org/functions#equal>',
  aliases: merge(numeric, bool),
  notation: Notation.Infix,
});

When you don't care what the error is, you can just test for ''.

In case the tables are too restrictive for your test, and you need an evaluation. You should still use the generalEvaluate function from generalEvaluation.ts. This function will automatically run both async and sync when possible. This increases your tests' coverage.

更新履歴

Changelog

All notable changes to this project will be documented in this file.

v4.2.0 - 2025-04-29

Added

Changed

Fixed

v4.1.0 - 2025-02-11

v4.1.0 - 2025-02-11

Added

Changed

Fixed

v4.0.2 - 2024-10-16

Changed

Fixed

v4.0.1 - 2024-10-15

BREAKING CHANGES

The following breaking changes will only impact users of Node.js < 18 and users that develop custom components or engines with Comunica.

Added

Changed

Fixed

v3.3.0 - 2024-10-08

Added

Changed

Fixed

v3.2.3 - 2024-08-22

Fixed

v3.2.2 - 2024-08-19

Changed

Fixed

v3.2.1 - 2024-08-07

Added

Changed

Fixed

v3.2.0 - 2024-07-05

Added

Changed

Fixed

v3.1.2 - 2024-05-30

Fixed

Changed

v3.1.1 - 2024-05-11

Fixed

v3.1.0 - 2024-05-11

Added

Changed

Fixed

v3.0.3 - 2024-04-12

Changed

Fixed

v3.0.2 - 2024-04-10

Fixed

v3.0.1 - 2024-03-19

BREAKING CHANGES

Added

Fixed

Changed

v2.10.2 - 2024-01-09

Fixed

v2.10.1 - 2023-11-29

Fixed

v2.10.0 - 2023-10-27

Added

Changed

Fixed

v2.9.0 - 2023-09-07

Changed

Fixed

v2.8.3 - 2023-08-21

Changed

Fixed

v2.8.2 - 2023-08-10

Fixed

v2.8.1 - 2023-07-14

Fixed

v2.8.0 - 2023-07-04

Added

Changed

v2.7.1 - 2023-05-31

Changed

Fixed

v2.7.0 - 2023-05-24

Added

Changed

Fixed

v2.6.10 - 2023-03-10

Fixed

v2.6.9 - 2023-03-08

Changed

Fixed

v2.6.8 - 2023-03-06

Changed

Fixed

v2.6.7 - 2023-02-15

Added

v2.6.6 - 2023-02-08

Fixed

Changed

v2.6.5 - 2023-02-07

Fixed

v2.6.4 - 2023-02-02

Fixed

v2.6.3 - 2023-02-01

Fixed

v2.6.2 - 2023-01-31

Fixed

v2.6.1 - 2023-01-30

Fixed

v2.6.0 - 2023-01-26

Added

Changed

Fixed

v2.5.2 - 2022-11-18

Fixed

v2.5.1 - 2022-11-16

Fixed

v2.5.0 - 2022-11-09

Added

Changed

Fixed

v2.4.3 - 2022-09-06

Fixed

v2.4.2 - 2022-08-26

Fixed

v2.4.1 - 2022-08-24

Fixed

v2.4.0 - 2022-08-24

Added

Changed

Fixed

v2.3.0 - 2022-06-29

Added

Changed

Fixed

v2.2.1 - 2022-04-13

Fixed

v2.2.0 - 2022-04-12

Added

Changed

Fixed

v2.1.0 - 2022-03-09

Added

v2.0.6 - 2022-03-07

Fixed

v2.0.5 - 2022-03-04

Fixed

v2.0.4 - 2022-03-04

Fixed

v2.0.3 - 2022-03-02

Fixed

v2.0.2 - 2022-03-02

Fixed

v2.0.1 - 2022-03-02

BREAKING CHANGES

Added

Changed

v1.22.3 - 2021-10-19

Fixed

v1.22.2 - 2021-09-30

Changed

Fixed

v1.22.1 - 2021-09-22

Fixed

v1.22.0 - 2021-08-30

Added

Changed

Fixed

v1.21.3 - 2021-06-18

Fixed

v1.21.2 - 2021-06-14

Changed

v1.21.1 - 2021-04-27

Republish due to npm publishing failure of 1.21.0.

v1.21.0 - 2021-04-27

Added

Changed

Fixed

v1.20.0 - 2021-03-30

Added

Changed

Fixed

v1.19.2 - 2021-02-02

Changed

Fixed

v1.19.1 - 2021-01-22

Fixed

v1.19.0 - 2021-01-15

Changed

v1.18.1 - 2020-12-01

Fixed

v1.18.0 - 2020-11-02

Fixed

Added

Changed

v1.17.0 - 2020-09-25

Added

Changed

Fixed

v1.16.2 - 2020-08-24

Fixed

v1.16.1 - 2020-08-24

Fixed

v1.16.0 - 2020-08-24

Added

Fixed

Changed

v1.15.0 - 2020-08-13

Added

Changed

Fixed

v1.14.0 - 2020-07-24

Added

Changed

Fixed

v1.13.1 - 2020-06-11

Fixed

v1.13.0 - 2020-06-03

Fixed

Changed

v1.12.1 - 2020-04-27

Fixed

v1.12.0 - 2020-04-03

Changed

Added

Fixed

v1.11.1 - 2020-04-02

Added

Fixed

Changed

v1.11.0 - 2020-03-30

Added

Changed

Fixed

v1.10.0 - 2019-12-12

Added

Changed

Fixed

v1.9.4 - 2019-10-21

Changed

v1.9.3 - 2019-10-16

Added

Changed

Fixed

v1.9.2 - 2019-09-27

Added

Changed

Fixed

v1.9.1 - 2019-07-30

Fixed

v1.9.0 - 2019-07-29

Added

Fixed

Changed

v1.8.0 - 2019-06-13

Changed

v1.7.4 - 2019-05-29

Fixed

v1.7.3 - 2019-05-09

Fixed

v1.7.2 - 2019-05-03

Fixed

v1.7.1 - 2019-05-03

Fixed

Changed

v1.7.0 - 2019-04-11

Added

Fixed

v1.6.6 - 2019-04-03

Changed

Fixed

v1.6.5 - 2019-03-15

Added

Fixed

v1.6.4 - 2019-03-05

Fixed

v1.6.3 - 2019-02-27

Changed

v1.6.2 - 2019-02-26

Added

Changed

v1.6.1 - 2019-02-25

Fixed

v1.6.0 - 2019-02-22

Added

Changed

Fixed

v1.5.4 - 2019-01-31

Fixed

Changed

v1.5.3 - 2019-01-24

Fixed

v1.5.2 - 2019-01-17

Fixed

v1.5.1 - 2019-01-17

Fixed

v1.5.0 - 2019-01-02

Added

v1.4.6 - 2018-12-11

Fixed

v1.4.5 - 2018-12-11

Fixed

Changed

v1.4.4 - 2018-11-13

Fixed

v1.4.3 - 2018-11-09

Changed

v1.4.2 - 2018-11-05

Fixed

v1.4.1 - 2018-10-04

Fixed

v1.4.0 - 2018-10-03

Added

Fixed

1.3.0 - 2018-09-10

Added

1.2.2 - 2018-09-05

Fixes

1.2.1 - 2018-09-05

Fixes

1.2.0 - 2018-09-05

Added

Fixes

1.1.2 - 2018-06-26

Added

Fixes

1.1.1 - 2018-06-01

Fixes

1.1.0 - 2018-06-01

Added

Fixes

1.0.4 - 2018-03-22

Fixes

1.0.3 - 2018-03-22

Fixes

1.0.2 - 2018-03-22

Fixes

1.0.1 - 2018-03-21

Fixes

[1.0.0] - 2018-03-19

  • Initial release