PageSourceSearch

https://terrancelaw.github.io/iQuery/js/lookAheadKnowledgeBase.js

js terrancelaw.github.io collected 2026-10-03 10:05:41 UTC 14,578 bytes, 483 lines download raw bytes

1const LookAheadKnowledgeBase = {
2
3	// the specification itself is useless
4	// events should be ordered from most specific to least specific
5	// each current event can only be matched to one event spec in each knowledge base item
6
7	distributionComparison: {
8		name: 'Distribution Comparison', active: true,
9		specification: {
10			x: 'quantitative',
11			color: 'nominal',
12			filter: { attribute: '=color', selected: 2 },
13			showMe: 'density'
14		},
15		generateVisSpecMetadata: LAKBDistributionHandler.generateVisSpecMetadata,
16		events: [
17			{
18				attributeCount: { quantitative: 1, nominal: 1 },
19				handler: { 
20					knowledgeBaseID: 'distributionComparison',
21					eventModificationRules: [{ x: 'quantitative', color: 'nominal' }],
22					template: {
23						x: { type: 'quantitative', fixed: true, enumerated: false },
24						color: { type: 'nominal', fixed: true, enumerated: false },
25						filter: { attribute: '=color', selected: 2, fixed: false, enumerated: true },
26						showMe: { type: 'density', fixed: true, enumerated: false }
27					}
28				}
29			}, {
30				attributeCount: { quantitative: 1 },
31				handler: { 
32					knowledgeBaseID: 'distributionComparison',
33					eventModificationRules: [{ x: 'quantitative' }],
34					template: {
35						x: { type: 'quantitative', fixed: true, enumerated: false },
36						color: { type: 'nominal', fixed: false, enumerated: true },
37						filter: { attribute: '=color', selected: 2, fixed: false, enumerated: true },
38						showMe: { type: 'density', fixed: true, enumerated: false }
39					}
40				}
41			}, {
42				attributeCount: { nominal: 1 }, 
43				handler: { 
44					knowledgeBaseID: 'distributionComparison',
45					eventModificationRules: [{ color: 'nominal' }],
46					template: {
47						x: { type: 'quantitative', fixed: false, enumerated: true },
48						color: { type: 'nominal', fixed: true, enumerated: false },
49						filter: { attribute: '=color', selected: 2, fixed: false, enumerated: true },
50						showMe: { type: 'density', fixed: true, enumerated: false }
51					}
52				}
53			}
54		]
55	},
56	slopeComparison: {
57		name: 'Slope Comparison', active: true, 
58		specification: {
59			x: 'quantitative',
60			y: 'quantitative',
61			color: 'nominal',
62			showme: 'trend'
63		},
64		generateVisSpecMetadata: LAKBSlopeHandler.generateVisSpecMetadata,
65		events: [
66			{
67				attributeCount: { quantitative: 2 }, 
68				handler: { 
69					knowledgeBaseID: 'slopeComparison',
70					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
71					template: {
72						x: { type: 'quantitative', fixed: true, enumerated: false },
73						y: { type: 'quantitative', fixed: true, enumerated: false },
74						color: { type: 'nominal', fixed: false, enumerated: true },
75						showMe: { type: 'trend', fixed: true, enumerated: false }
76					}
77				}
78			}, {
79				attributeCount: { quantitative: 1 }, 
80				handler: {
81					knowledgeBaseID: 'slopeComparison',
82					eventModificationRules: [
83						{ x: 'quantitative' },
84						{ y: 'quantitative' } // get the best one
85					],
86					template: {
87						x: { type: 'quantitative', fixed: true, enumerated: true },
88						y: { type: 'quantitative', fixed: true, enumerated: true },
89						color: { type: 'nominal', fixed: false, enumerated: true },
90						showMe: { type: 'trend', fixed: true, enumerated: false }
91					}
92				}
93			}
94		]
95	},
96	trendDetection: {
97		name: 'Trend Detection', active: true,
98		specification: {
99			x: 'temporal',
100			y: { type: 'quantitative', aggregate: 'mean' }
101		},
102		generateVisSpecMetadata: LAKBTrendHandler.generateVisSpecMetadata,
103		events: [
104			{ 
105				attributeCount: { temporal: 1, quantitative: 1 }, 
106				handler: {
107					knowledgeBaseID: 'trendDetection',
108					eventModificationRules: [{ x: 'temporal', y: { type: 'quantitative', aggregate: 'mean' } }],
109					template: {
110						x: { type: 'temporal', fixed: true, enumerated: false }, // time unit get from event
111						y: { type: 'quantitative', aggregate: 'mean', fixed: true, enumerated: false }
112					}
113				}
114			}, { 
115				attributeCount: { temporal: 1 }, 
116				handler: {
117					knowledgeBaseID: 'trendDetection',
118					eventModificationRules: [{ x: 'temporal' }],
119					template: {
120						x: { type: 'temporal', fixed: true, enumerated: false }, // time unit get from event
121						y: { type: 'quantitative', aggregate: 'mean', fixed: false, enumerated: true }
122					}
123				}
124			}, { 
125				attributeCount: { quantitative: 1 }, 
126				handler: {
127					knowledgeBaseID: 'trendDetection',
128					eventModificationRules: [{ y: { type: 'quantitative', aggregate: 'mean' } }],
129					template: {
130						x: { type: 'temporal', timeUnit: 'year', fixed: false, enumerated: true },
131						y: { type: 'quantitative', aggregate: 'mean', fixed: true, enumerated: false }
132					}
133				}
134			}
135		]
136	},
137	correlation: {
138		name: 'Correlation', active: true,
139		specification: {
140			x: 'quantitative',
141			y: 'quantitative',
142			showme: 'trend'
143		},
144		generateVisSpecMetadata: LAKBCorrelationHandler.generateVisSpecMetadata,
145		events: [
146			{
147				attributeCount: { quantitative: 2 }, 
148				handler: { 
149					knowledgeBaseID: 'correlation',
150					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
151					template: {
152						x: { type: 'quantitative', fixed: true, enumerated: true },
153						y: { type: 'quantitative', fixed: true, enumerated: true },
154						showMe: { type: 'trend', fixed: true, enumerated: false }
155					}
156				}
157			}, {
158				attributeCount: { quantitative: 1 }, 
159				handler: { 
160					knowledgeBaseID: 'correlation',
161					eventModificationRules: [
162						{ x: 'quantitative' },
163						{ y: 'quantitative' } // get the best one
164					],
165					template: {
166						x: { type: 'quantitative', fixed: true, enumerated: true },
167						y: { type: 'quantitative', fixed: true, enumerated: true },
168						showMe: { type: 'trend', fixed: true, enumerated: false }
169					}
170				}
171			}
172		]
173	},
174
175	// scagnostics
176
177	outlying: {
178		name: 'Outlying Scagnostic', active: false, 
179		specification: {
180			x: 'quantitative',
181			y: 'quantitative'
182		},
183		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'outlying'); },
184		events: [
185			{
186				attributeCount: { quantitative: 2 }, 
187				handler: { 
188					knowledgeBaseID: 'outlying',
189					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
190					template: {
191						x: { type: 'quantitative', fixed: true, enumerated: true },
192						y: { type: 'quantitative', fixed: true, enumerated: true }
193					}
194				}
195			}, {
196				attributeCount: { quantitative: 1 }, 
197				handler: { 
198					knowledgeBaseID: 'outlying',
199					eventModificationRules: [
200						{ x: 'quantitative' },
201						{ y: 'quantitative' } // get the best one
202					],
203					template: {
204						x: { type: 'quantitative', fixed: true, enumerated: true },
205						y: { type: 'quantitative', fixed: true, enumerated: true }
206					}
207				}
208			}
209		]
210	},
211	skewed: {
212		name: 'Skewed Scagnostic', active: false, 
213		specification: {
214			x: 'quantitative',
215			y: 'quantitative'
216		},
217		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'skewed') },
218		events: [
219			{
220				attributeCount: { quantitative: 2 }, 
221				handler: { 
222					knowledgeBaseID: 'skewed',
223					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
224					template: {
225						x: { type: 'quantitative', fixed: true, enumerated: true },
226						y: { type: 'quantitative', fixed: true, enumerated: true }
227					}
228				}
229			}, {
230				attributeCount: { quantitative: 1 }, 
231				handler: { 
232					knowledgeBaseID: 'skewed',
233					eventModificationRules: [
234						{ x: 'quantitative' },
235						{ y: 'quantitative' } // get the best one
236					],
237					template: {
238						x: { type: 'quantitative', fixed: true, enumerated: true },
239						y: { type: 'quantitative', fixed: true, enumerated: true }
240					}
241				}
242			}
243		]
244	},
245	sparse: {
246		name: 'Sparse Scagnostic', active: false, 
247		specification: {
248			x: 'quantitative',
249			y: 'quantitative'
250		},
251		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'sparse') },
252		events: [
253			{
254				attributeCount: { quantitative: 2 }, 
255				handler: { 
256					knowledgeBaseID: 'sparse',
257					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
258					template: {
259						x: { type: 'quantitative', fixed: true, enumerated: true },
260						y: { type: 'quantitative', fixed: true, enumerated: true }
261					}
262				}
263			}, {
264				attributeCount: { quantitative: 1 }, 
265				handler: { 
266					knowledgeBaseID: 'sparse',
267					eventModificationRules: [
268						{ x: 'quantitative' },
269						{ y: 'quantitative' } // get the best one
270					],
271					template: {
272						x: { type: 'quantitative', fixed: true, enumerated: true },
273						y: { type: 'quantitative', fixed: true, enumerated: true }
274					}
275				}
276			}
277		]
278	},
279	clumpy: {
280		name: 'Clumpy Scagnostic', active: false, 
281		specification: {
282			x: 'quantitative',
283			y: 'quantitative'
284		},
285		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'clumpy') },
286		events: [
287			{
288				attributeCount: { quantitative: 2 }, 
289				handler: { 
290					knowledgeBaseID: 'clumpy',
291					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
292					template: {
293						x: { type: 'quantitative', fixed: true, enumerated: true },
294						y: { type: 'quantitative', fixed: true, enumerated: true }
295					}
296				}
297			}, {
298				attributeCount: { quantitative: 1 }, 
299				handler: { 
300					knowledgeBaseID: 'clumpy',
301					eventModificationRules: [
302						{ x: 'quantitative' },
303						{ y: 'quantitative' } // get the best one
304					],
305					template: {
306						x: { type: 'quantitative', fixed: true, enumerated: true },
307						y: { type: 'quantitative', fixed: true, enumerated: true }
308					}
309				}
310			}
311		]
312	},
313	striated: {
314		name: 'Striated Scagnostic', active: false,
315		specification: {
316			x: 'quantitative',
317			y: 'quantitative'
318		},
319		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'striated') },
320		events: [
321			{
322				attributeCount: { quantitative: 2 }, 
323				handler: { 
324					knowledgeBaseID: 'striated',
325					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
326					template: {
327						x: { type: 'quantitative', fixed: true, enumerated: true },
328						y: { type: 'quantitative', fixed: true, enumerated: true }
329					}
330				}
331			}, {
332				attributeCount: { quantitative: 1 }, 
333				handler: { 
334					knowledgeBaseID: 'striated',
335					eventModificationRules: [
336						{ x: 'quantitative' },
337						{ y: 'quantitative' } // get the best one
338					],
339					template: {
340						x: { type: 'quantitative', fixed: true, enumerated: true },
341						y: { type: 'quantitative', fixed: true, enumerated: true }
342					}
343				}
344			}
345		]
346	},
347	convex: {
348		name: 'Convex Scagnostic', active: false,
349		specification: {
350			x: 'quantitative',
351			y: 'quantitative'
352		},
353		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'convex') },
354		events: [
355			{
356				attributeCount: { quantitative: 2 }, 
357				handler: { 
358					knowledgeBaseID: 'convex',
359					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
360					template: {
361						x: { type: 'quantitative', fixed: true, enumerated: true },
362						y: { type: 'quantitative', fixed: true, enumerated: true }
363					}
364				}
365			}, {
366				attributeCount: { quantitative: 1 }, 
367				handler: { 
368					knowledgeBaseID: 'convex',
369					eventModificationRules: [
370						{ x: 'quantitative' },
371						{ y: 'quantitative' } // get the best one
372					],
373					template: {
374						x: { type: 'quantitative', fixed: true, enumerated: true },
375						y: { type: 'quantitative', fixed: true, enumerated: true }
376					}
377				}
378			}
379		]
380	},
381	skinny: {
382		name: 'Skinny Scagnostic', active: false,
383		specification: {
384			x: 'quantitative',
385			y: 'quantitative'
386		},
387		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'skinny') },
388		events: [
389			{
390				attributeCount: { quantitative: 2 }, 
391				handler: { 
392					knowledgeBaseID: 'skinny',
393					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
394					template: {
395						x: { type: 'quantitative', fixed: true, enumerated: true },
396						y: { type: 'quantitative', fixed: true, enumerated: true }
397					}
398				}
399			}, {
400				attributeCount: { quantitative: 1 }, 
401				handler: { 
402					knowledgeBaseID: 'skinny',
403					eventModificationRules: [
404						{ x: 'quantitative' },
405						{ y: 'quantitative' } // get the best one
406					],
407					template: {
408						x: { type: 'quantitative', fixed: true, enumerated: true },
409						y: { type: 'quantitative', fixed: true, enumerated: true }
410					}
411				}
412			}
413		]
414	},
415	stringy: {
416		name: 'Stringy Scagnostic', active: false,
417		specification: {
418			x: 'quantitative',
419			y: 'quantitative'
420		},
421		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'stringy') },
422		events: [
423			{
424				attributeCount: { quantitative: 2 }, 
425				handler: { 
426					knowledgeBaseID: 'stringy',
427					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
428					template: {
429						x: { type: 'quantitative', fixed: true, enumerated: true },
430						y: { type: 'quantitative', fixed: true, enumerated: true }
431					}
432				}
433			}, {
434				attributeCount: { quantitative: 1 }, 
435				handler: { 
436					knowledgeBaseID: 'stringy',
437					eventModificationRules: [
438						{ x: 'quantitative' },
439						{ y: 'quantitative' } // get the best one
440					],
441					template: {
442						x: { type: 'quantitative', fixed: true, enumerated: true },
443						y: { type: 'quantitative', fixed: true, enumerated: true }
444					}
445				}
446			}
447		]
448	},
449	monotonic: {
450		name: 'Monotonic Scagnostic', active: false,
451		specification: {
452			x: 'quantitative',
453			y: 'quantitative'
454		},
455		generateVisSpecMetadata: function(visSpec) { return LAKBScagnosticsHandler.generateVisSpecMetadata(visSpec, 'monotonic') },
456		events: [
457			{
458				attributeCount: { quantitative: 2 }, 
459				handler: { 
460					knowledgeBaseID: 'monotonic',
461					eventModificationRules: [{ x: 'quantitative', y: 'quantitative' }],
462					template: {
463						x: { type: 'quantitative', fixed: true, enumerated: true },
464						y: { type: 'quantitative', fixed: true, enumerated: true }
465					}
466				}
467			}, {
468				attributeCount: { quantitative: 1 }, 
469				handler: { 
470					knowledgeBaseID: 'monotonic',
471					eventModificationRules: [
472						{ x: 'quantitative' },
473						{ y: 'quantitative' } // get the best one
474					],
475					template: {
476						x: { type: 'quantitative', fixed: true, enumerated: true },
477						y: { type: 'quantitative', fixed: true, enumerated: true }
478					}
479				}
480			}
481		]
482	}
483}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.