ekms 8.0.0-beta.10 → 8.0.0-beta.12
Sign up to get free protection for your applications and to get access to all the features.
- package/common/crew.instance.json +288 -0
- package/common/edible.instance.json +2 -2
- package/common/fastfood.instance.json +121 -157
- package/common/numbers.js +2 -2
- package/common/ordering.instance.json +68 -0
- package/common/percentages.instance.json +2 -0
- package/common/percentages.js +57 -0
- package/common/percentages.test.json +751 -0
- package/common/reports.instance.json +1 -1
- package/common/sdefaults.js +10 -0
- package/main.js +2 -0
- package/package.json +6 -2
package/common/numbers.js
CHANGED
@@ -2,6 +2,7 @@ const { Config, knowledgeModule, where } = require('./runtime').theprogrammablem
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const numbers_tests = require('./numbers.test.json')
|
4
4
|
const gdefaults = require('./gdefaults')
|
5
|
+
const sdefaults = require('./sdefaults')
|
5
6
|
|
6
7
|
/*
|
7
8
|
TODO
|
@@ -21,7 +22,6 @@ let configStruct = {
|
|
21
22
|
version: '3',
|
22
23
|
words: {
|
23
24
|
"literals": {
|
24
|
-
// start with a space for regular expressions
|
25
25
|
"one": [{"id": "number", "initial": "{ value: 1, instance:true }" }],
|
26
26
|
"ones": [{"id": "number", "initial": "{ value: 1, number: 'many', instance:true }" }],
|
27
27
|
"two": [{"id": "number", "initial": "{ value: 2 , instance:true}" }],
|
@@ -85,7 +85,7 @@ let configStruct = {
|
|
85
85
|
|
86
86
|
const createConfig = () => {
|
87
87
|
const config = new Config(configStruct, module)
|
88
|
-
config.add(gdefaults())
|
88
|
+
config.add(gdefaults(), sdefaults())
|
89
89
|
return config
|
90
90
|
}
|
91
91
|
|
@@ -1977,6 +1977,40 @@
|
|
1977
1977
|
0
|
1978
1978
|
]
|
1979
1979
|
],
|
1980
|
+
[
|
1981
|
+
[
|
1982
|
+
"if",
|
1983
|
+
0
|
1984
|
+
],
|
1985
|
+
[
|
1986
|
+
"like",
|
1987
|
+
0
|
1988
|
+
],
|
1989
|
+
[
|
1990
|
+
"love",
|
1991
|
+
0
|
1992
|
+
],
|
1993
|
+
[
|
1994
|
+
"orList",
|
1995
|
+
0
|
1996
|
+
],
|
1997
|
+
[
|
1998
|
+
"then",
|
1999
|
+
0
|
2000
|
+
],
|
2001
|
+
[
|
2002
|
+
"unknown",
|
2003
|
+
0
|
2004
|
+
],
|
2005
|
+
[
|
2006
|
+
"unknown",
|
2007
|
+
1
|
2008
|
+
],
|
2009
|
+
[
|
2010
|
+
"want",
|
2011
|
+
0
|
2012
|
+
]
|
2013
|
+
],
|
1980
2014
|
[
|
1981
2015
|
[
|
1982
2016
|
"if",
|
@@ -2338,6 +2372,40 @@
|
|
2338
2372
|
0
|
2339
2373
|
]
|
2340
2374
|
],
|
2375
|
+
[
|
2376
|
+
[
|
2377
|
+
"if",
|
2378
|
+
0
|
2379
|
+
],
|
2380
|
+
[
|
2381
|
+
"like",
|
2382
|
+
0
|
2383
|
+
],
|
2384
|
+
[
|
2385
|
+
"love",
|
2386
|
+
0
|
2387
|
+
],
|
2388
|
+
[
|
2389
|
+
"orList",
|
2390
|
+
0
|
2391
|
+
],
|
2392
|
+
[
|
2393
|
+
"then",
|
2394
|
+
0
|
2395
|
+
],
|
2396
|
+
[
|
2397
|
+
"unknown",
|
2398
|
+
0
|
2399
|
+
],
|
2400
|
+
[
|
2401
|
+
"unknown",
|
2402
|
+
1
|
2403
|
+
],
|
2404
|
+
[
|
2405
|
+
"want",
|
2406
|
+
0
|
2407
|
+
]
|
2408
|
+
],
|
2341
2409
|
[
|
2342
2410
|
[
|
2343
2411
|
"if",
|
@@ -0,0 +1,57 @@
|
|
1
|
+
const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
|
2
|
+
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const percentages_tests = require('./percentages.test.json')
|
4
|
+
const numbers = require('./numbers')
|
5
|
+
|
6
|
+
let configStruct = {
|
7
|
+
name: 'percentages',
|
8
|
+
operators: [
|
9
|
+
"((number/*) [percent])",
|
10
|
+
"((percent/1) [percentageOf|of] (number/*))",
|
11
|
+
],
|
12
|
+
bridges: [
|
13
|
+
{
|
14
|
+
id: "percent",
|
15
|
+
words: ['percent', '%'],
|
16
|
+
bridge: "{ ...next(operator), modifiers: ['scale'], scale: before[0] }",
|
17
|
+
generatorp: ({context}) => context.text,
|
18
|
+
},
|
19
|
+
{
|
20
|
+
id: "percentageOf",
|
21
|
+
words: ['percent', '%'],
|
22
|
+
bridge: "{ ...next(operator), percentage: before[0], isResponse: true, semanticIsEvaluate: true, value: after[0] }",
|
23
|
+
evaluator: ({context, e}) => {
|
24
|
+
const scale = context.percentage.scale
|
25
|
+
const number = e(context.value)
|
26
|
+
const percentage = number.value * scale.value / 100
|
27
|
+
const result = { ...number, value: percentage, word: null, text: null }
|
28
|
+
context.evalue = result
|
29
|
+
context.isReponse = true
|
30
|
+
context.paraphrase = false
|
31
|
+
},
|
32
|
+
generatorp: ({context}) => context.text,
|
33
|
+
},
|
34
|
+
],
|
35
|
+
debug: false,
|
36
|
+
version: '3',
|
37
|
+
};
|
38
|
+
|
39
|
+
const createConfig = () => {
|
40
|
+
const config = new Config(configStruct, module)
|
41
|
+
config.add(numbers())
|
42
|
+
return config
|
43
|
+
}
|
44
|
+
|
45
|
+
knowledgeModule( {
|
46
|
+
module,
|
47
|
+
createConfig,
|
48
|
+
description: 'talking about percentages',
|
49
|
+
test: {
|
50
|
+
name: './percentages.test.json',
|
51
|
+
contents: percentages_tests,
|
52
|
+
checks: {
|
53
|
+
context: [...defaultContextCheck, { property: 'scale', filter: ['marker', 'word', 'value'] }],
|
54
|
+
},
|
55
|
+
|
56
|
+
},
|
57
|
+
})
|