ekms 8.0.0-beta.5 → 8.0.0-beta.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/common/animals.instance.json +2855 -1363
  2. package/common/animals.js +17 -20
  3. package/common/articles.js +103 -0
  4. package/common/articles.test.json +310 -0
  5. package/common/avatar.js +5 -9
  6. package/common/characters.js +22 -28
  7. package/common/colors.instance.json +6978 -3493
  8. package/common/colors.js +4 -8
  9. package/common/colors.test.json +345 -780
  10. package/common/comparable.js +5 -22
  11. package/common/concept.js +120 -118
  12. package/common/countable.js +18 -12
  13. package/common/countable.test.json +1050 -0
  14. package/common/crew.instance.json +13032 -6570
  15. package/common/crew.js +36 -41
  16. package/common/crew.test.json +714 -452
  17. package/common/currency.js +27 -45
  18. package/common/dialogues.js +158 -282
  19. package/common/dimension.instance.json +273 -272
  20. package/common/dimension.js +16 -22
  21. package/common/dimension.test.json +446 -1640
  22. package/common/edible.instance.json +19911 -9877
  23. package/common/edible.js +3 -8
  24. package/common/emotions.instance.json +146 -128
  25. package/common/emotions.js +35 -38
  26. package/common/evaluate.instance.json +2 -0
  27. package/common/evaluate.js +49 -0
  28. package/common/evaluate.test.json +574 -0
  29. package/common/events.js +9 -13
  30. package/common/fastfood.instance.json +221141 -111240
  31. package/common/fastfood.js +70 -80
  32. package/common/formulas.instance.json +251 -265
  33. package/common/formulas.js +17 -24
  34. package/common/gdefaults.js +24 -26
  35. package/common/help.js +7 -12
  36. package/common/help.test.json +22 -22
  37. package/common/helpers/concept.js +9 -6
  38. package/common/helpers/dialogues.js +2 -3
  39. package/common/helpers/properties.js +52 -58
  40. package/common/helpers.js +1 -1
  41. package/common/hierarchy.js +16 -24
  42. package/common/javascript.js +11 -18
  43. package/common/kirk.instance.json +583 -289
  44. package/common/kirk.js +5 -8
  45. package/common/length.instance.json +5530 -4754
  46. package/common/length.js +4 -8
  47. package/common/listener.js +48 -0
  48. package/common/listener.test.json +104 -0
  49. package/common/math.instance.json +192 -1184
  50. package/common/math.js +15 -19
  51. package/common/meta.js +23 -47
  52. package/common/nameable.instance.json +2 -0
  53. package/common/nameable.js +135 -0
  54. package/common/nameable.test.json +2121 -0
  55. package/common/negation.instance.json +2 -0
  56. package/common/negation.js +38 -0
  57. package/common/negation.test.json +308 -0
  58. package/common/numbers.js +6 -10
  59. package/common/ordering.instance.json +340 -160
  60. package/common/ordering.js +80 -86
  61. package/common/people.instance.json +2066 -1014
  62. package/common/people.js +8 -13
  63. package/common/percentages.instance.json +2 -0
  64. package/common/percentages.js +53 -0
  65. package/common/percentages.test.json +751 -0
  66. package/common/pipboy.instance.json +7999 -6269
  67. package/common/pipboy.js +32 -43
  68. package/common/pokemon.instance.json +4207 -2069
  69. package/common/pokemon.js +7 -20
  70. package/common/pos.js +4 -5
  71. package/common/pressure.instance.json +1341 -1189
  72. package/common/pressure.js +4 -8
  73. package/common/properties.instance.json +130 -60
  74. package/common/properties.js +56 -133
  75. package/common/punctuation.js +6 -6
  76. package/common/reports.instance.json +595 -557
  77. package/common/reports.js +64 -89
  78. package/common/scorekeeper.js +18 -30
  79. package/common/sdefaults.js +16 -7
  80. package/common/sizeable.js +5 -9
  81. package/common/spock.instance.json +583 -289
  82. package/common/spock.js +5 -8
  83. package/common/stgame.js +19 -19
  84. package/common/stm.js +163 -26
  85. package/common/stm.test.json +1734 -1
  86. package/common/tell.js +14 -18
  87. package/common/temperature.instance.json +1461 -1293
  88. package/common/temperature.js +4 -8
  89. package/common/tester.js +3 -3
  90. package/common/testing.js +8 -12
  91. package/common/time.js +20 -25
  92. package/common/tokenize.js +4 -5
  93. package/common/ui.instance.json +257 -258
  94. package/common/ui.js +11 -17
  95. package/common/weight.instance.json +5212 -4233
  96. package/common/weight.js +4 -8
  97. package/common/yesno.js +5 -5
  98. package/main.js +59 -46
  99. package/package.json +27 -5
@@ -1,10 +1,10 @@
1
- const { Config, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require("./dialogues")
4
4
  const numbers = require("./numbers")
5
5
  const comparable_tests = require('./comparable.test.json')
6
6
 
7
- let configStruct = {
7
+ let config = {
8
8
  name: 'comparable',
9
9
  operators: [
10
10
  "([condition|])",
@@ -45,31 +45,14 @@ let configStruct = {
45
45
  bridge: "{ ...next(operator) }"
46
46
  },
47
47
  ],
48
-
49
- /*
50
- generators: [
51
- {
52
- where: where(),
53
- match: ({context}) => false && context.quantity,
54
- apply: ({context, g}) => {
55
- const countable = g({ ...context, quantity: undefined, number: context.quanity == 1 ? 'one' : 'many' })
56
- return `${g(context.quantity)} ${countable}`
57
- }
58
- },
59
- ]
60
- */
61
48
  };
62
49
 
63
- const createConfig = () => {
64
- const config = new Config(configStruct, module)
65
- config.add(dialogues(), numbers())
66
- return config
67
- }
68
-
69
50
  knowledgeModule({
51
+ config,
52
+ includes: [dialogues, numbers],
53
+
70
54
  module,
71
55
  description: 'Comparable things',
72
- createConfig,
73
56
  test: {
74
57
  name: './comparable.test.json',
75
58
  contents: comparable_tests,
package/common/concept.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, flatten, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, flatten, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const { API }= require('./helpers/concept')
4
4
  const dialogues = require('./dialogues.js')
@@ -14,135 +14,137 @@ const concept_instance = require('./concept.instance.json')
14
14
  plain and regular fries mean the same thing
15
15
  */
16
16
 
17
- const createConfig = () => {
18
- const config = new Config({
19
- name: 'concept',
20
- operators: [
21
- "((context.punctuation != true)* [modifies|] (concept))",
22
- "([concept])",
23
- "([literally] (modifies/0))",
24
- ],
25
- bridges: [
26
- {
27
- id: "modifies",
28
- isA: ['verby'],
29
- words: [{ word: 'modifies', number: 'one', flatten: false }, { word: 'modify', number: 'many', flatten: true }],
30
- // bridge: "{ ...next(operator), modifiers: before, concept: after[0], flatten: true }"
31
- bridge: "{ ...next(operator), modifiers: before, concept: after[0] }"
32
- },
33
- { id: "literally", bridge: "{ ...after[0], flatten: false, literally: true }" },
34
- { id: "concept", bridge: "{ ...next(operator) }" },
35
- ],
36
- priorities: [
37
- { "context": [['literally', 0], ['modifies', 0], ], "choose": [0] },
38
- ],
39
- hierarchy: [
40
- ['concept', 'theAble'],
41
- ['concept', 'queryable'],
42
- ],
43
- generators: [
44
- {
45
- notes: '"fire type, water type and earth type" to "fire water and earth type"',
46
- /*
47
- {
48
- "water": {
49
- "marker": "water",
50
- "value": "water",
51
- "word": "water"
52
- },
53
- "marker": "water_type",
54
- "modifiers": [
55
- "water"
56
- ],
57
- "types": [
58
- "water_type"
59
- ],
60
- "value": "water_type",
61
- "word": "type",
62
- "paraphrase": true
17
+ config = {
18
+ name: 'concept',
19
+ operators: [
20
+ "((context.punctuation != true)* [modifies|] (concept))",
21
+ "([concept])",
22
+ "([literally] (modifies/0))",
23
+ ],
24
+ bridges: [
25
+ {
26
+ id: "modifies",
27
+ isA: ['verby'],
28
+ words: [{ word: 'modifies', number: 'one', flatten: false }, { word: 'modify', number: 'many', flatten: true }],
29
+ // bridge: "{ ...next(operator), modifiers: before, concept: after[0], flatten: true }"
30
+ bridge: "{ ...next(operator), modifiers: before, concept: after[0] }"
31
+ },
32
+ { id: "literally", bridge: "{ ...after[0], flatten: false, literally: true }" },
33
+ { id: "concept", bridge: "{ ...next(operator) }" },
34
+ ],
35
+ priorities: [
36
+ { "context": [['literally', 0], ['modifies', 0], ], "choose": [0] },
37
+ ],
38
+ hierarchy: [
39
+ ['concept', 'theAble'],
40
+ ['concept', 'queryable'],
41
+ ],
42
+ generators: [
43
+ {
44
+ notes: '"fire type, water type and earth type" to "fire water and earth type"',
45
+ /*
46
+ {
47
+ "water": {
48
+ "marker": "water",
49
+ "value": "water",
50
+ "word": "water"
63
51
  },
64
- */
65
- where: where(),
66
- match: ({context}) => {
67
- if (!context.paraphrase) {
68
- return
69
- }
70
- if (context.marker !== 'list') {
71
- return
72
- }
73
- if ((context.value || []).length < 2) {
74
- return
75
- }
76
- if (!context.value[0].word) {
77
- return
78
- }
79
- const word = context.value[0].word
80
-
81
- for (let value of context.value) {
82
- if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
83
- return
84
- }
85
- }
86
- return true
52
+ "marker": "water_type",
53
+ "modifiers": [
54
+ "water"
55
+ ],
56
+ "types": [
57
+ "water_type"
58
+ ],
59
+ "value": "water_type",
60
+ "word": "type",
61
+ "paraphrase": true
87
62
  },
88
- apply: ({g, context}) => {
89
- const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
90
- context.word = context.value[0].word
91
- context.value = null
92
- context.modifiers = ['modifier']
93
- context.modifier = {
94
- marker: 'list',
95
- paraphrase: true,
96
- value: modifiers
97
- }
98
- context.paraphrase = true
99
- return g(context)
63
+ */
64
+ where: where(),
65
+ match: ({context}) => {
66
+ if (!context.paraphrase) {
67
+ return
100
68
  }
101
- },
102
- {
103
- where: where(),
104
- match: ({context}) => context.marker == 'modifies' && context.paraphrase,
105
- apply: ({context, gp, gw}) => {
106
- if (context.literally) {
107
- return `${context.modifiers.map(gp).join(" ")} literally ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
108
- } else {
109
- return `${context.modifiers.map(gp).join(" ")} ${gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${gp(context.concept)}`
110
- }
69
+ if (context.marker !== 'list') {
70
+ return
111
71
  }
112
- // const chosen = chooseNumber(context, word.singular, word.plural)
113
- },
114
- ],
115
- semantics: [
116
- {
117
- notes: 'define a modifier',
118
- where: where(),
119
- match: ({context}) => context.marker == 'modifies',
120
- apply: ({config, query, km, context}) => {
121
- let modifiers
122
- if (context.literally) {
123
- literalModifiers = context.modifiers[0]
124
- modifiers = literalModifiers.value.map(modifier => modifier.value)
125
- modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
126
- } else {
127
- modifiers = context.modifiers.map(modifier => modifier.value)
72
+ if ((context.value || []).length < 2) {
73
+ return
74
+ }
75
+ if (!context.value[0].word) {
76
+ return
77
+ }
78
+ const word = context.value[0].word
79
+
80
+ for (let value of context.value) {
81
+ if (!(value.modifiers && value.modifiers.length == 1 && value.word == word)) {
82
+ return
128
83
  }
129
- // km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
130
- km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
131
84
  }
85
+ return true
132
86
  },
133
- ],
134
- }, module)
135
- config.stop_auto_rebuild()
136
- config.api = new API()
137
- config.add(dialogues())
138
- config.restart_auto_rebuild()
139
- return config
87
+ apply: async ({g, context}) => {
88
+ const modifiers = context.value.map( (p) => p[p.modifiers[0]] )
89
+ context.word = context.value[0].word
90
+ context.value = null
91
+ context.modifiers = ['modifier']
92
+ context.modifier = {
93
+ marker: 'list',
94
+ paraphrase: true,
95
+ value: modifiers
96
+ }
97
+ context.paraphrase = true
98
+ return await g(context)
99
+ }
100
+ },
101
+ {
102
+ where: where(),
103
+ match: ({context}) => context.marker == 'modifies' && context.paraphrase,
104
+ apply: async ({context, gp, gw}) => {
105
+ const modifiers = []
106
+ for (modifier of context.modifiers) {
107
+ modifiers.push(await gp(modifier))
108
+ }
109
+ if (context.literally) {
110
+ return `${modifiers.join(" ")} literally ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
111
+ } else {
112
+ return `${modifiers.join(" ")} ${await gw(context, { number: context.modifiers[context.modifiers.length - 1] })} ${await gp(context.concept)}`
113
+ }
114
+ }
115
+ // const chosen = chooseNumber(context, word.singular, word.plural)
116
+ },
117
+ ],
118
+ semantics: [
119
+ {
120
+ notes: 'define a modifier',
121
+ where: where(),
122
+ match: ({context}) => context.marker == 'modifies',
123
+ apply: ({config, query, km, context}) => {
124
+ let modifiers
125
+ if (context.literally) {
126
+ literalModifiers = context.modifiers[0]
127
+ // modifiers = literalModifiers.value.map(modifier => modifier.value)
128
+ modifiers = literalModifiers.value
129
+ modifiers = modifiers.slice(0, -1).concat([literalModifiers.marker]).concat(modifiers.slice(-1))
130
+ } else {
131
+ modifiers = context.modifiers
132
+ // modifiers = context.modifiers.map(modifier => modifier.value)
133
+ }
134
+ // km('concept').api.kindOfConcept({ config, modifiers, object: context.concept.value || context.concept.marker })
135
+ km('concept').api.kindOfConcept({ config, modifiers, object: context.concept })
136
+ }
137
+ },
138
+ ],
140
139
  }
141
140
 
142
141
  knowledgeModule({
142
+ config,
143
+ includes: [dialogues],
144
+ api: () => new API(),
145
+
143
146
  module,
144
147
  description: 'The idea of a concept whatever that might end up being',
145
- createConfig,
146
148
  test: {
147
149
  name: './concept.test.json',
148
150
  contents: concept_tests,
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
1
+ const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
2
2
  const { defaultContextCheck } = require('./helpers')
3
3
  const dialogues = require("./hierarchy")
4
4
  const numbers = require("./numbers")
@@ -11,12 +11,14 @@ const countable_tests = require('./countable.test.json')
11
11
  2 6 and 3 10 piece nuggets
12
12
  */
13
13
 
14
- let configStruct = {
14
+ let config = {
15
15
  name: 'countable',
16
16
  operators: [
17
17
  "(([quantifier|]) [counting] ([countable]))",
18
18
  "(([number|]) [countOfPieces|] ([piece]))",
19
19
  "((countOfPieces/*) [countingPieces] ([hasCountOfPieces]))",
20
+ "([more] (countable/*))",
21
+ "([less] (countable/*))",
20
22
  "([all])",
21
23
  // everything
22
24
  ],
@@ -44,6 +46,14 @@ let configStruct = {
44
46
  {
45
47
  id: "piece",
46
48
  },
49
+ {
50
+ id: "more",
51
+ bridge: "{ ...next(after[0]), more: operator, modifiers: append(['more'], after[0].modifiers) }",
52
+ },
53
+ {
54
+ id: "less",
55
+ bridge: "{ ...next(after[0]), less: operator, modifiers: append(['less'], after[0].modifiers) }",
56
+ },
47
57
  {
48
58
  id: "quantifier",
49
59
  children: ['number', 'all'],
@@ -63,28 +73,24 @@ let configStruct = {
63
73
  {
64
74
  where: where(),
65
75
  match: ({context}) => false && context.quantity,
66
- apply: ({context, g}) => {
76
+ apply: async ({context, g}) => {
67
77
  let number = context.quantity.number || 'one'
68
78
  if (context.quantity.value > 1) {
69
79
  number = 'many'
70
80
  }
71
- const countable = g({ ...context, quantity: undefined, number})
72
- return `${g(context.quantity)} ${countable}`
81
+ const countable = await g({ ...context, quantity: undefined, number})
82
+ return `${await g(context.quantity)} ${countable}`
73
83
  }
74
84
  },
75
85
  ]
76
86
  };
77
87
 
78
- const createConfig = () => {
79
- const config = new Config(configStruct, module)
80
- config.add(dialogues(), numbers())
81
- return config
82
- }
83
-
84
88
  knowledgeModule({
89
+ config,
90
+ includes: [dialogues, numbers],
91
+
85
92
  module,
86
93
  description: 'Countable things',
87
- createConfig,
88
94
  test: {
89
95
  name: './countable.test.json',
90
96
  contents: countable_tests,