tpmkms_4wp 7.12.8 → 8.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. package/common/animals.instance.json +192 -406
  2. package/common/animals.js +1 -1
  3. package/common/avatar.js +7 -5
  4. package/common/characters.js +12 -6
  5. package/common/{pipboyTemplate.instance.json → colors.instance.json} +13784 -8900
  6. package/common/colors.js +71 -0
  7. package/common/colors.test.json +4860 -0
  8. package/common/concept.js +2 -2
  9. package/common/crew.instance.json +3945 -3636
  10. package/common/crew.js +5 -3
  11. package/common/currency.js +0 -2
  12. package/common/dialogues.js +152 -20
  13. package/common/dialogues.test.json +1053 -33
  14. package/common/dimension.instance.json +750 -86
  15. package/common/dimension.js +15 -7
  16. package/common/dimension.test.json +289 -312
  17. package/common/edible.instance.json +446 -578
  18. package/common/edible.js +1 -1
  19. package/common/emotions.instance.json +67 -39
  20. package/common/emotions.js +1 -1
  21. package/common/fastfood.instance.json +1769 -2136
  22. package/common/fastfood.js +2 -2
  23. package/common/fastfood.test.json +7941 -3647
  24. package/common/formulas.instance.json +996 -0
  25. package/common/formulas.js +19 -6
  26. package/common/formulas.test.json +504 -2896
  27. package/common/gdefaults.js +2 -0
  28. package/common/help.js +7 -2
  29. package/common/help.test.json +18 -10
  30. package/common/helpers/concept.js +29 -9
  31. package/common/helpers/dialogues.js +17 -1
  32. package/common/helpers/formulas.js +0 -14
  33. package/common/helpers/meta.js +0 -1
  34. package/common/helpers/properties.js +6 -13
  35. package/common/helpers.js +5 -0
  36. package/common/javascript.js +8 -6
  37. package/common/kirk.instance.json +5 -1
  38. package/common/kirk.js +1 -1
  39. package/common/length.instance.json +417 -811
  40. package/common/length.js +1 -1
  41. package/common/math.instance.json +1938 -1
  42. package/common/math.js +17 -5
  43. package/common/meta.instance.json +1 -1
  44. package/common/meta.js +33 -10
  45. package/common/numbers.js +28 -24
  46. package/common/ordering.instance.json +98 -138
  47. package/common/ordering.js +1 -1
  48. package/common/people.instance.json +68 -121
  49. package/common/people.js +1 -1
  50. package/common/pipboy.instance.json +23411 -1076
  51. package/common/pipboy.js +31 -4
  52. package/common/pipboy.test.json +13 -9
  53. package/common/pokemon.instance.json +172 -223
  54. package/common/pokemon.js +1 -1
  55. package/common/pressure.instance.json +131 -81
  56. package/common/pressure.js +1 -1
  57. package/common/properties.instance.json +25 -49
  58. package/common/properties.js +20 -15
  59. package/common/properties.test.json +17605 -4030
  60. package/common/punctuation.js +8 -0
  61. package/common/punctuation.test.json +233 -5
  62. package/common/reports.instance.json +33 -65
  63. package/common/reports.js +9 -9
  64. package/common/scorekeeper.instance.json +1 -1
  65. package/common/scorekeeper.js +9 -7
  66. package/common/sizeable.js +7 -2
  67. package/common/spock.instance.json +5 -1
  68. package/common/spock.js +1 -1
  69. package/common/stm.js +16 -5
  70. package/common/tell.js +4 -2
  71. package/common/temperature.instance.json +142 -252
  72. package/common/temperature.js +1 -1
  73. package/common/testing.js +0 -1
  74. package/common/time.js +36 -20
  75. package/common/time.test.json +66 -44
  76. package/common/tokenize.js +47 -0
  77. package/common/tokenize.test.json +87 -0
  78. package/common/ui.instance.json +13 -1
  79. package/common/ui.js +0 -1
  80. package/common/weight.instance.json +335 -228
  81. package/common/weight.js +1 -1
  82. package/common/weight.test.json +242 -238
  83. package/main.js +6 -8
  84. package/package.json +10 -18
  85. package/common/dimensionTemplate.instance.json +0 -582
  86. package/common/dimensionTemplate.js +0 -35
  87. package/common/dimensionTemplate.test.json +0 -2
  88. package/common/formulasTemplate.instance.json +0 -483
  89. package/common/formulasTemplate.js +0 -30
  90. package/common/formulasTemplate.test.json +0 -2
  91. package/common/mathTemplate.instance.json +0 -1635
  92. package/common/mathTemplate.js +0 -32
  93. package/common/mathTemplate.test.json +0 -1422
  94. package/common/pipboyTemplate.js +0 -48
  95. package/common/pipboyTemplate.test.json +0 -2
package/common/crew.js CHANGED
@@ -7,7 +7,8 @@ const crew_instance = require('./crew.instance.json')
7
7
  const pluralize = require('pluralize')
8
8
 
9
9
  const template = {
10
- queries: [
10
+ configs: [
11
+ "crew modifies member",
11
12
  "kirk's name is jim",
12
13
  "kirk's rank is captain",
13
14
  "kirk's eyes are blue",
@@ -24,6 +25,7 @@ const template = {
24
25
  "mccoy is a crew member",
25
26
  "mccoy is a doctor",
26
27
  "the status of the phasers is armed",
28
+ "photon modifies torpedoes",
27
29
  "the status of the photon torpedoes is armed",
28
30
  "phasers are weapons",
29
31
  "torpedoes are weapons",
@@ -43,8 +45,8 @@ const createConfig = () => {
43
45
  config.initializer( ({config, apis}) => {
44
46
  const api = apis('properties')
45
47
  const conceptApi = apis('concept')
46
- conceptApi.kindOfConcept({ config, modifiers: ['photon'], object: 'torpedo' })
47
- conceptApi.kindOfConcept({ config, modifiers: ['crew'], object: 'member' })
48
+ // conceptApi.kindOfConcept({ config, modifiers: ['photon'], object: 'torpedo' })
49
+ // conceptApi.kindOfConcept({ config, modifiers: ['crew'], object: 'member' })
48
50
  api.createActionPrefix({
49
51
  operator: 'arm',
50
52
  create: ['arm', 'weapon'],
@@ -55,8 +55,6 @@ let configStruct = {
55
55
  floaters: ['isQuery'],
56
56
  debug: true,
57
57
  "version": '3',
58
- "words": {
59
- },
60
58
 
61
59
  generators: [
62
60
  {
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('./runtime').theprogrammablemind
1
+ const { Config, knowledgeModule, where, stableId } = require('./runtime').theprogrammablemind
2
2
  const meta = require('./meta.js')
3
3
  const gdefaults = require('./gdefaults.js')
4
4
  const sdefaults = require('./sdefaults.js')
@@ -36,6 +36,10 @@ const warningSameNotEvaluated = (log, one) => {
36
36
  let configStruct = {
37
37
  name: 'dialogues',
38
38
  operators: [
39
+ "([makeObject] (word))",
40
+ "([setIdSuffix] (word))",
41
+ "([resetIdSuffix])",
42
+
39
43
  "(([queryable]) [is|] ([queryable|]))",
40
44
  "([is:queryBridge|] ([queryable]) ([queryable]))",
41
45
  // "(([queryable]) [is:isEdBridge|is,are] ([isEdAble|]))",
@@ -54,7 +58,7 @@ let configStruct = {
54
58
  "([what:optional])",
55
59
  "(<the|> ([theAble|]))",
56
60
  "(<a|a,an> ([theAble|]))",
57
- "([unknown])",
61
+ // "([unknown])",
58
62
  "([not] ([notAble|]))",
59
63
 
60
64
  "([be] ([briefOrWordy|]))",
@@ -98,6 +102,30 @@ let configStruct = {
98
102
  ]
99
103
  },
100
104
  bridges: [
105
+ {
106
+ id: 'makeObject',
107
+ bridge: "{ ...next(operator), object: after[0] }",
108
+ generatorp: ({context, gp}) => `${context.word} ${gp(context.object)}`,
109
+ semantic: ({config, context, api}) => {
110
+ api.makeObject({ context: context.object, config, types: [] })
111
+ }
112
+ },
113
+ {
114
+ id: 'setIdSuffix',
115
+ bridge: "{ ...next(operator), suffix: after[0] }",
116
+ generatorp: ({context, gp}) => `${context.word} ${gp(context.suffix)}`,
117
+ semantic: ({context, api}) => {
118
+ api.setIdSuffix(context.suffix.text)
119
+ }
120
+ },
121
+ {
122
+ id: 'resetIdSuffix',
123
+ bridge: "{ ...next(operator) }",
124
+ semantic: ({context, api}) => {
125
+ api.setIdSuffix('')
126
+ }
127
+ },
128
+
101
129
  { id: "by", level: 0, bridge: "{ ...next(operator), object: after[0] }", optional: { 'isEder': "{ marker: 'unknown', implicit: true, concept: true }", }, },
102
130
 
103
131
  { id: "debug23", level: 0, bridge: "{ ...next(operator) }" },
@@ -150,8 +178,8 @@ let configStruct = {
150
178
  { id: "yesno", level: 0, bridge: "{ ...next(operator) }" },
151
179
  { id: "canBeQuestion", level: 0, bridge: "{ ...next(operator) }" },
152
180
  { id: "canBeQuestion", level: 1, bridge: "{ ...next(operator) }" },
153
- { id: "unknown", level: 0, bridge: "{ ...next(operator), unknown: true, dead: true }" },
154
- { id: "unknown", level: 1, bridge: "{ ...next(operator) }" },
181
+ // { id: "unknown", level: 0, bridge: "{ ...next(operator), unknown: true, dead: true }" },
182
+ // { id: "unknown", level: 1, bridge: "{ ...next(operator) }" },
155
183
  { id: "queryable", level: 0, bridge: "{ ...next(operator) }" },
156
184
  { id: "questionMark", level: 0, bridge: "{ ...before[0], query: [before.marker] }" },
157
185
  // { id: "isEd", level: 0, bridge: "{ ...context, query: true }" },
@@ -235,7 +263,6 @@ let configStruct = {
235
263
  applyq: () => 'the test question?',
236
264
  onNevermind: ({objects, context}) => {
237
265
  objects.onNevermindWasCalled = true
238
- debugger
239
266
  objects.nevermindType = nevermindType
240
267
  return nevermindType == 'accept'
241
268
  },
@@ -275,17 +302,19 @@ let configStruct = {
275
302
  },
276
303
  ],
277
304
  words: {
278
- "?": [{"id": "questionMark", "initial": "{}" }],
279
- "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
280
- "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
281
- "yes": [{"id": "yesno", "initial": "{ value: true }" }],
282
- "no": [{"id": "yesno", "initial": "{ value: false }" }],
283
- "brief": [{"id": "briefOrWordy", "initial": "{ value: 'brief' }" }],
284
- "wordy": [{"id": "briefOrWordy", "initial": "{ value: 'wordy' }" }],
285
- "does": [{"id": "does", "initial": "{ number: 'one' }" }],
286
- "do": [{"id": "does", "initial": "{ number: 'many' }" }],
287
- "is": [{"id": "is", "initial": "{ number: 'one' }" }, {"id": "isEd", "initial": "{ number: 'one' }" }],
288
- "are": [{"id": "is", "initial": "{ number: 'many' }" }, {"id": "isEd", "initial": "{ number: 'many' }" }],
305
+ "literals": {
306
+ "?": [{"id": "questionMark", "initial": "{}" }],
307
+ "the": [{"id": "the", "initial": "{ modifiers: [] }" }],
308
+ "who": [{"id": "what", "initial": "{ modifiers: [], query: true }" }],
309
+ "yes": [{"id": "yesno", "initial": "{ value: true }" }],
310
+ "no": [{"id": "yesno", "initial": "{ value: false }" }],
311
+ "brief": [{"id": "briefOrWordy", "initial": "{ value: 'brief' }" }],
312
+ "wordy": [{"id": "briefOrWordy", "initial": "{ value: 'wordy' }" }],
313
+ "does": [{"id": "does", "initial": "{ number: 'one' }" }],
314
+ "do": [{"id": "does", "initial": "{ number: 'many' }" }],
315
+ "is": [{"id": "is", "initial": "{ number: 'one' }" }, {"id": "isEd", "initial": "{ number: 'one' }" }],
316
+ "are": [{"id": "is", "initial": "{ number: 'many' }" }, {"id": "isEd", "initial": "{ number: 'many' }" }],
317
+ }
289
318
  },
290
319
 
291
320
  floaters: ['query'],
@@ -301,6 +330,7 @@ let configStruct = {
301
330
  { "context": [['isEdAble', 0], ['is', 1], ], "choose": [0] },
302
331
  ],
303
332
  hierarchy: [
333
+ ['doubleQuote', 'queryable'],
304
334
  ['it', 'pronoun'],
305
335
  ['this', 'pronoun'],
306
336
  ['questionMark', 'punctuation'],
@@ -679,7 +709,6 @@ let configStruct = {
679
709
 
680
710
  */
681
711
  context.value = kms.stm.api.mentions(context)
682
- // debugger;
683
712
  if (!context.value) {
684
713
  // retry()
685
714
  context.value = { marker: 'answerNotKnown' }
@@ -893,6 +922,102 @@ let configStruct = {
893
922
  ],
894
923
  };
895
924
 
925
+ // move ask to the KM's since verbatim is called probably in dialogues?
926
+ const getAsk = (config) => (uuid) => {
927
+ return (asks) => {
928
+ const ask = (ask) => {
929
+ let oneShot = true // default
930
+ if (ask.oneShot === false) {
931
+ oneShot = false
932
+ }
933
+
934
+ const id_q = stableId('semantic')
935
+ const id_rs = []
936
+ let wasAsked = false
937
+ let wasApplied = false
938
+ const getWasAsked = () => {
939
+ return wasAsked
940
+ }
941
+ const setWasAsked = (value) => {
942
+ wasAsked = value
943
+ }
944
+ const getWasApplied = () => {
945
+ return wasApplied
946
+ }
947
+ const setWasApplied = (value) => {
948
+ wasApplied = value
949
+ }
950
+
951
+ const semanticsr = ask.semanticsr || []
952
+ if (semanticsr.length == 0) {
953
+ semanticsr.push({ match: ask.matchr, apply: ask.applyr })
954
+ }
955
+ for (const semantic of semanticsr) {
956
+ const id_r = stableId('semantic')
957
+ id_rs.push(id_r)
958
+ config.addSemantic({
959
+ uuid,
960
+ id: id_r,
961
+ tied_ids: [id_q],
962
+ oneShot,
963
+ where: semantic.where || ask.where || where(2),
964
+ source: 'response',
965
+ match: (args) => semantic.match(args),
966
+ apply: (args) => {
967
+ setWasApplied(true)
968
+ semantic.apply(args)
969
+ },
970
+ })
971
+ }
972
+
973
+ config.addSemantic({
974
+ uuid,
975
+ oneShot,
976
+ id: id_q,
977
+ tied_ids: id_rs,
978
+ where: ask.where,
979
+ isQuestion: true, // do one question at a time
980
+ getWasAsked,
981
+ getWasApplied,
982
+ onNevermind: ask.onNevermind,
983
+ source: 'question',
984
+ match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
985
+ apply: (args) => {
986
+ let matchq = ask.matchq
987
+ let applyq = ask.applyq
988
+ if (!matchq) {
989
+ let wasAsked = false
990
+ matchq = () => !wasAsked,
991
+ applyq = (args) => {
992
+ wasAsked = true
993
+ return ask.applyq(args)
994
+ }
995
+ }
996
+ if (matchq(args)) {
997
+ setWasAsked(true)
998
+ setWasApplied(false)
999
+ // args.context.motivationKeep = true
1000
+ args.verbatim(applyq(args))
1001
+ /*
1002
+ args.context.verbatim = applyq(args)
1003
+ args.context.isResponse = true;
1004
+ delete args.context.controlRemove;
1005
+ */
1006
+ args.context.controlKeepMotivation = true
1007
+ }
1008
+ args.context.cascade = true
1009
+ }
1010
+ })
1011
+ }
1012
+ if (!Array.isArray(asks)) {
1013
+ asks = [asks]
1014
+ }
1015
+
1016
+ [...asks].reverse().forEach( (a) => ask(a) )
1017
+ }
1018
+ }
1019
+
1020
+
896
1021
  const createConfig = () => {
897
1022
  const config = new Config(configStruct, module)
898
1023
  config.stop_auto_rebuild()
@@ -904,7 +1029,7 @@ const createConfig = () => {
904
1029
  e: (context) => config.api.getEvaluator(args.s, args.log, context),
905
1030
  }))
906
1031
  */
907
- config.addArgs(({isA}) => ({
1032
+ config.addArgs(({config, api, isA}) => ({
908
1033
  isAListable: (context, type) => {
909
1034
  if (context.marker == 'list' || context.listable) {
910
1035
  return context.value.every( (element) => isA(element.marker, type) )
@@ -912,7 +1037,7 @@ const createConfig = () => {
912
1037
  return isA(context.marker, type)
913
1038
  }
914
1039
  },
915
- toContext(v) {
1040
+ toContext: (v) => {
916
1041
  if (Array.isArray(v)) {
917
1042
  return { marker: 'list', level: 1, value: v }
918
1043
  }
@@ -921,6 +1046,13 @@ const createConfig = () => {
921
1046
  }
922
1047
  return v
923
1048
  },
1049
+ getUUIDScoped: (uuid) => { return {
1050
+ ask: getAsk(config)(uuid),
1051
+ }
1052
+ },
1053
+ toScopedId: (context) => {
1054
+ return api('dialogues').toScopedId(context)
1055
+ },
924
1056
  }))
925
1057
  objects.mentioned = []
926
1058
  objects.variables = {
@@ -943,7 +1075,7 @@ knowledgeModule( {
943
1075
  name: './dialogues.test.json',
944
1076
  contents: dialogues_tests,
945
1077
  checks: {
946
- objects: ['onNevermindWasCalled', 'nevermindType'],
1078
+ objects: ['onNevermindWasCalled', 'nevermindType', 'idSuffix'],
947
1079
  context: defaultContextCheck,
948
1080
  },
949
1081