-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
30 lines (28 loc) · 988 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Rule, Rete } from './rete';
let testRules: Array<Rule> = [
{
LHS: [{identifier: "<a>", attribute: "age", value: "20"}, {identifier: "a", attribute: "sex", value: "man"}],
RHS: function() {
console.log('r1');
}
},
{
LHS: [{identifier: "a", attribute: "age", value: "20"}, {identifier: "a", attribute: "sex", value: "woman"}],
RHS: function() {
console.log('r2');
}
},
{
LHS: [{identifier: "a", attribute: "sex", value: "woman"}, {identifier: "a", attribute: "age", value: "20"}, {identifier: "a", attribute: "age", value: "6"}],
RHS: function() {
console.log('r3');
}
}
]
const rete = new Rete(testRules);
rete.addFact({identifier: "a", attribute: "age", value: "20"});
rete.addFact({identifier: "a", attribute: "sex", value: "woman"});
rete.addFact({identifier: "a", attribute: "age", value: "6"});
rete.addFact({identifier: "a", attribute: "sex", value: "man"});
// console.log(rete);
// rete.traverseRete();