From 86eea5e7e506f4c356bb1d8d125b5c3cdfb4102f Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Fri, 8 Nov 2013 15:15:04 -0600 Subject: [PATCH] v0.2.1 * Added support for js expression in the `from` node addressing issue [#86](https://github.com/C2FO/nools/issues/86) * Enhanced `JoinReferenceNode` performance in the default assert case where there are no `references` to left or right context. * Added ability to use `or` and `not` in tandem to check for the non-existence of multiple facts. [#85](https://github.com/C2FO/nools/issues/85) * Fixed issue with `from` node where an undefined property would be tested. [#89](https://github.com/C2FO/nools/issues/89) * You can now define a custom resolution strategy. * Compiling nools files now supports the from modifier. * Documentation updates * Updates about from node support with js values. * New documentation about using `or` and `not` constratints together. * Updated `or` documentation to include a three constraint example. --- Gruntfile.js | 2 +- benchmark/waltzDb/benchmark.js | 5 +- benchmark/waltzDb/waltzDb.nools | 5 +- docs/History.html | 15 + docs/examples/browser/rules/waltzDb.nools | 1063 ++++++ docs/examples/browser/src/watlzdbData.js | 3429 +++++++++++++++++++ docs/examples/browser/waltzDb.html | 143 + docs/index.html | 171 +- docs/nools.js | 16 +- examples/browser/rules/waltzDb.nools | 1063 ++++++ examples/browser/src/watlzdbData.js | 3429 +++++++++++++++++++ examples/browser/waltzDb.html | 143 + history.md | 14 + lib/agenda.js | 11 +- lib/compile/index.js | 60 +- lib/compile/transpile.js | 43 +- lib/constraint.js | 11 +- lib/constraintMatcher.js | 14 +- lib/extended.js | 39 +- lib/flow.js | 6 +- lib/flowContainer.js | 10 +- lib/nodes/alphaNode.js | 1 + lib/nodes/equalityNode.js | 7 +- lib/nodes/fromNode.js | 23 +- lib/nodes/fromNotNode.js | 20 +- lib/nodes/joinNode.js | 6 +- lib/nodes/joinReferenceNode.js | 58 +- lib/nodes/notNode.js | 67 +- lib/nodes/typeNode.js | 6 +- lib/parser/nools/tokens.js | 37 +- lib/pattern.js | 12 +- lib/rule.js | 11 +- nools.js | 448 ++- nools.min.js | 16 +- package.json | 2 +- readme.md | 238 +- test/flow.compiled.test.js | 45 +- test/flow.dsl.test.js | 42 +- test/flow.test.js | 155 +- test/issues.test.js | 123 +- test/noolsParser.test.js | 48 + test/rules.test.js | 32 +- test/rules/orRule-notConditions-compiled.js | 19 + test/rules/orRule-notConditions.nools | 19 + 44 files changed, 10705 insertions(+), 422 deletions(-) create mode 100644 docs/examples/browser/rules/waltzDb.nools create mode 100644 docs/examples/browser/src/watlzdbData.js create mode 100644 docs/examples/browser/waltzDb.html create mode 100644 examples/browser/rules/waltzDb.nools create mode 100644 examples/browser/src/watlzdbData.js create mode 100644 examples/browser/waltzDb.html create mode 100644 test/rules/orRule-notConditions-compiled.js create mode 100644 test/rules/orRule-notConditions.nools diff --git a/Gruntfile.js b/Gruntfile.js index 3fe34cf..04352ad 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -30,7 +30,7 @@ module.exports = function (grunt) { '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' + ' Licensed <%= pkg.license %> */\n', - report: 'gzip' + report: 'min' }, min: { files: { diff --git a/benchmark/waltzDb/benchmark.js b/benchmark/waltzDb/benchmark.js index 47e2f14..2546e99 100644 --- a/benchmark/waltzDb/benchmark.js +++ b/benchmark/waltzDb/benchmark.js @@ -2,8 +2,9 @@ var data = require("./data"), nools = require("../../index"); -var flow = nools.compile(__dirname + "/waltzDb.nools"); -var items = data.load(flow).waltzdb8; +var flow = nools.compile(__dirname + "/waltzDb.nools") + .conflictResolution(["salience", "factRecency", "activationRecency"]); +var items = data.load(flow).waltzdb4; var session = flow.getSession.apply(flow, items); session.assert(new (flow.getDefined("stage"))({value: "DUPLICATE"})); var start = new Date(); diff --git a/benchmark/waltzDb/waltzDb.nools b/benchmark/waltzDb/waltzDb.nools index e0607fd..f5a2dc4 100644 --- a/benchmark/waltzDb/waltzDb.nools +++ b/benchmark/waltzDb/waltzDb.nools @@ -78,8 +78,7 @@ function getAngle(p1, p2){ return PI/2; else if (deltaY < 0) return -PI/2; - } - else if (deltaY == 0) { + }else if (deltaY == 0) { if (deltaX > 0) return 0.0; else if (deltaX < 0) @@ -721,9 +720,9 @@ rule start_visit_2_junction { junction : Junction junction.type == '2j' && junction.visited == 'no' {basePoint : basePoint, p1 : p1, p2 : p2}; } then { + modify(junction, function(){ this.visited = "now";}); modify(stage, function(){ this.value = 'VISITING_2J';}); console.log( "VISITING_2J" ); - modify(junction, function(){ this.visited = "now";}); } } diff --git a/docs/History.html b/docs/History.html index de60546..b615e93 100644 --- a/docs/History.html +++ b/docs/History.html @@ -178,6 +178,21 @@ +

0.2.1

+

0.2.0 / 2013-10-14

  • Defining Rules