-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator.nools
207 lines (186 loc) · 5.29 KB
/
validator.nools
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
define Product {
f1 : '',
f2 : '',
f3 : '',
height: 0,
left: false,
right: false,
root: null,
constructor : function(f1, f2, f3){
this.f1 = f1;
this.f2 = f2;
this.f3 = f3;
this.height = 0;
this.left = false;
this.right = false;
this.root = null;
}
}
// First iteration
rule f1IsSmallerThen50 {
when {
p : Product p.f1 < 50 AND p.height === 0;
}
then {
console.log("Current node: f1 < 50 | Next left node: F2 < 40 ");
modify(p, function(){
p.root = "f1 < 50";
p.height = p.height + 1;
p.left = true;
});
}
}
// First iteration
rule f1IsBiggerThen50 {
when {
p : Product p.f1 > 50 AND p.height === 0;
}
then {
console.log("Current node: f1 < 50 | Next right node: F3 < 70 ");
modify(p, function(){
p.root = "f1 < 50";
p.height = p.height + 1;
p.right = true;
});
}
}
// Second iteration
rule f2IsSmallerThen40 {
when {
p : Product p.f2 < 40 AND p.height === 1 AND p.left === true AND p.root === "f1 < 50";
}
then {
console.log("Current node: f2 < 40 | Next left node: F1 < 20 ");
modify(p, function(){
p.root = "f2 < 40";
p.height = p.height + 1;
p.left = true;
p.right = false;
});
}
}
// Second iteration
rule f2IsBiggerThen40 {
when {
p : Product p.f2 > 40 AND p.height === 1 AND p.left === true AND p.root === "f1 < 50";
}
then {
console.log("Current node: f2 < 40 | Next right node: F3 < 30 ");
modify(p, function(){
p.root = "f2 < 40";
p.height = p.height + 1;
p.left = false;
p.right = true;
});
}
}
// Second iteration
rule f3IsSmallerThen70 {
when {
p : Product p.f3 < 70 AND p.height === 1 AND p.right === true AND p.root === "f1 < 50";
}
then {
console.log("Current node: f3 < 70 | Next left node: F2 < 10 ");
modify(p, function(){
p.root = "f3 < 70";
p.height = p.height + 1;
p.left = true;
p.right = false;
});
}
}
// Second iteration
rule f3IsBiggerThen70 {
when {
p : Product p.f3 > 70 AND p.height === 1 AND p.right === true AND p.root === "f1 < 50";
}
then {
console.log("Current node: f3 < 70 | Next right node: F1 < 80 ");
modify(p, function(){
p.root = "f3 < 70";
p.height = p.height + 1;
p.left = false;
p.right = true;
});
}
}
// Third iteration
rule f1IsSmallerThen20 {
when {
p : Product p.f1 < 20 AND p.height === 2 AND p.left === true AND p.root === "f2 < 40";
}
then {
console.log("Current node: f1 < 20 | Next left node: category A");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: A\n");
}
}
// Third iteration
rule f1IsBiggerThen20 {
when {
p : Product p.f1 > 20 AND p.height === 2 AND p.left === true AND p.root === "f2 < 40";
}
then {
console.log("Current node: f1 < 20 | Next right node: category B");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: B\n");
}
}
// Third iteration
rule f3IsSmallerThen30 {
when {
p : Product p.f3 < 30 AND p.height === 2 AND p.right === true AND p.root === "f2 < 40";
}
then {
console.log("Current node: f3 < 30 | Next left node: category C");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: C\n");
}
}
// Third iteration
rule f3IsBiggerThen30 {
when {
p : Product p.f3 > 30 AND p.height === 2 AND p.right === true AND p.root === "f2 < 40";
}
then {
console.log("Current node: f3 < 30 | Next right node: category D");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: D\n");
}
}
// Third iteration
rule f2IsSmallerThen10 {
when {
p : Product p.f2 < 10 AND p.height === 2 AND p.left === true AND p.root === "f3 < 70";
}
then {
console.log("Current node: f2 < 10 | Next left node: category A");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: A\n");
}
}
// Third iteration
rule f2IsBiggerThen10 {
when {
p : Product p.f2 > 10 AND p.height === 2 AND p.left === true AND p.root === "f3 < 70";
}
then {
console.log("Current node: f2 < 10 | Next left node: category B");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: B\n");
}
}
// Third iteration
rule f1IsSmallerThen80 {
when {
p : Product p.f1 < 80 AND p.height === 2 AND p.right === true AND p.root === "f3 < 70";
}
then {
console.log("Current node: f1 < 80 | Next left node: category C");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: C\n");
}
}
// Third iteration
rule f1IsBiggerThen80 {
when {
p : Product p.f1 > 80 AND p.height === 2 AND p.right === true AND p.root === "f3 < 70";
}
then {
console.log("Current node: f1 < 80 | Next left node: category D");
console.log("For (", p.f1 ,",", p.f2,",", p.f3,") we predicted category: D\n");
}
}