ekms 8.0.0-beta.77 → 8.0.0-beta.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/asking.instance.json +2 -0
- package/common/asking.js +253 -0
- package/common/asking.test.json +2290 -0
- package/common/colors.instance.json +0 -28
- package/common/conjunction.instance.json +2 -0
- package/common/conjunction.js +104 -0
- package/common/conjunction.test.json +322 -0
- package/common/crew.instance.json +36 -0
- package/common/dialogues.js +14 -173
- package/common/dialogues.test.json +0 -786
- package/common/edible.instance.json +2 -58
- package/common/fastfood.instance.json +259 -979
- package/common/help.test.json +20 -26
- package/common/helpers.js +7 -0
- package/common/ordering.instance.json +0 -68
- package/common/ordinals.instance.json +2 -0
- package/common/ordinals.js +60 -0
- package/common/ordinals.test.json +306 -0
- package/common/pipboy.instance.json +0 -56
- package/common/reports.instance.json +1 -1
- package/main.js +6 -0
- package/package.json +14 -2
package/common/dialogues.js
CHANGED
@@ -2,6 +2,8 @@ const { knowledgeModule, where, stableId } = require('./runtime').theprogrammabl
|
|
2
2
|
const meta = require('./meta.js')
|
3
3
|
const gdefaults = require('./gdefaults.js')
|
4
4
|
const sdefaults = require('./sdefaults.js')
|
5
|
+
const asking = require('./asking.js')
|
6
|
+
const conjunction = require('./conjunction.js')
|
5
7
|
const articles = require('./articles.js')
|
6
8
|
const pos = require('./pos.js')
|
7
9
|
const negation = require('./negation.js')
|
@@ -47,8 +49,8 @@ let config = {
|
|
47
49
|
// "(([queryable]) [is:isEdBridge|is,are] ([isEdAble|]))",
|
48
50
|
"(([queryable]) [(<isEd|> ([isEdAble|]))])",
|
49
51
|
|
50
|
-
"([nevermind])",
|
51
|
-
{ pattern: "([nevermindTestSetup] (allowed))", development: true },
|
52
|
+
// "([nevermind])",
|
53
|
+
// { pattern: "([nevermindTestSetup] (allowed))", development: true },
|
52
54
|
"([why])",
|
53
55
|
"([reason])",
|
54
56
|
// "([thisitthat|])",
|
@@ -75,7 +77,6 @@ let config = {
|
|
75
77
|
// joe is a person the age of joe ...
|
76
78
|
//"arm them, what, the phasers"
|
77
79
|
//greg is a first name
|
78
|
-
"(x [list|and] y)",
|
79
80
|
"([yesno|])",
|
80
81
|
"(([isEdee])^ <isEdAble|> ([by] ([isEder])?))",
|
81
82
|
"([isEdee|])",
|
@@ -135,29 +136,6 @@ let config = {
|
|
135
136
|
{ id: "whatAble", level: 0, bridge: "{ ...next(operator) }" },
|
136
137
|
|
137
138
|
// context.instance == variables.instance (unification)
|
138
|
-
{
|
139
|
-
id: "list",
|
140
|
-
level: 0,
|
141
|
-
selector: {
|
142
|
-
match: "same",
|
143
|
-
left: [ { pattern: '($type && context.instance == variables.instance)' } ],
|
144
|
-
right: [ { pattern: '($type && context.instance == variables.instance)' } ],
|
145
|
-
// left: [ { pattern: '($type)' } ],
|
146
|
-
// right: [ { pattern: '($type)' } ],
|
147
|
-
passthrough: true
|
148
|
-
},
|
149
|
-
bridge: "{ ...next(operator), listable: true, isList: true, value: append(before, after) }"
|
150
|
-
},
|
151
|
-
{
|
152
|
-
id: "list",
|
153
|
-
level: 1,
|
154
|
-
selector: {
|
155
|
-
match: "same",
|
156
|
-
left: [ { pattern: '($type && context.instance == variables.instance)' } ],
|
157
|
-
passthrough: true
|
158
|
-
},
|
159
|
-
bridge: "{ ...operator, value: append(before, operator.value) }"
|
160
|
-
},
|
161
139
|
{
|
162
140
|
where: where(),
|
163
141
|
id: "to",
|
@@ -238,6 +216,7 @@ let config = {
|
|
238
216
|
bridge: "{ ...next(operator) }"
|
239
217
|
},
|
240
218
|
*/
|
219
|
+
/*
|
241
220
|
{
|
242
221
|
id: "nevermind",
|
243
222
|
bridge: "{ ...next(operator) }",
|
@@ -257,6 +236,8 @@ let config = {
|
|
257
236
|
}
|
258
237
|
}
|
259
238
|
},
|
239
|
+
*/
|
240
|
+
/*
|
260
241
|
{
|
261
242
|
id: "nevermindTestSetup",
|
262
243
|
development: true,
|
@@ -275,6 +256,7 @@ let config = {
|
|
275
256
|
})
|
276
257
|
}
|
277
258
|
},
|
259
|
+
*/
|
278
260
|
{
|
279
261
|
id: "why",
|
280
262
|
level: 0,
|
@@ -417,32 +399,6 @@ let config = {
|
|
417
399
|
priority: -1,
|
418
400
|
},
|
419
401
|
|
420
|
-
{
|
421
|
-
where: where(),
|
422
|
-
notes: 'handle lists with yes no',
|
423
|
-
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
424
|
-
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
425
|
-
match: ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value && context.value.length > 0 && context.value[0].marker == 'yesno',
|
426
|
-
apply: async ({context, g, gs}) => {
|
427
|
-
return `${await g(context.value[0])} ${await gs(context.value.slice(1), ', ', ' and ')}`
|
428
|
-
}
|
429
|
-
},
|
430
|
-
|
431
|
-
{
|
432
|
-
where: where(),
|
433
|
-
notes: 'handle lists',
|
434
|
-
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
435
|
-
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
436
|
-
match: ({context, hierarchy}) => context.marker == 'list' && context.value,
|
437
|
-
apply: async ({context, gs}) => {
|
438
|
-
if (context.newLinesOnly) {
|
439
|
-
return await gs(context.value, '\n')
|
440
|
-
} else {
|
441
|
-
return await gs(context.value, ', ', ' and ')
|
442
|
-
}
|
443
|
-
}
|
444
|
-
},
|
445
|
-
|
446
402
|
{
|
447
403
|
where: where(),
|
448
404
|
notes: 'paraphrase a queryable response',
|
@@ -803,102 +759,6 @@ let config = {
|
|
803
759
|
],
|
804
760
|
};
|
805
761
|
|
806
|
-
// move ask to the KM's since verbatim is called probably in dialogues?
|
807
|
-
const getAsk = (config) => (uuid) => {
|
808
|
-
return (asks) => {
|
809
|
-
const ask = (ask) => {
|
810
|
-
let oneShot = true // default
|
811
|
-
if (ask.oneShot === false) {
|
812
|
-
oneShot = false
|
813
|
-
}
|
814
|
-
|
815
|
-
const id_q = stableId('semantic')
|
816
|
-
const id_rs = []
|
817
|
-
let wasAsked = false
|
818
|
-
let wasApplied = false
|
819
|
-
const getWasAsked = () => {
|
820
|
-
return wasAsked
|
821
|
-
}
|
822
|
-
const setWasAsked = (value) => {
|
823
|
-
wasAsked = value
|
824
|
-
}
|
825
|
-
const getWasApplied = () => {
|
826
|
-
return wasApplied
|
827
|
-
}
|
828
|
-
const setWasApplied = (value) => {
|
829
|
-
wasApplied = value
|
830
|
-
}
|
831
|
-
|
832
|
-
const semanticsr = ask.semanticsr || []
|
833
|
-
if (semanticsr.length == 0) {
|
834
|
-
semanticsr.push({ match: ask.matchr, apply: ask.applyr })
|
835
|
-
}
|
836
|
-
for (const semantic of semanticsr) {
|
837
|
-
const id_r = stableId('semantic')
|
838
|
-
id_rs.push(id_r)
|
839
|
-
config.addSemantic({
|
840
|
-
uuid,
|
841
|
-
id: id_r,
|
842
|
-
tied_ids: [id_q],
|
843
|
-
oneShot,
|
844
|
-
where: semantic.where || ask.where || where(2),
|
845
|
-
source: 'response',
|
846
|
-
match: (args) => semantic.match(args),
|
847
|
-
apply: async (args) => {
|
848
|
-
setWasApplied(true)
|
849
|
-
await semantic.apply(args)
|
850
|
-
},
|
851
|
-
})
|
852
|
-
}
|
853
|
-
|
854
|
-
config.addSemantic({
|
855
|
-
uuid,
|
856
|
-
oneShot,
|
857
|
-
id: id_q,
|
858
|
-
tied_ids: id_rs,
|
859
|
-
where: ask.where,
|
860
|
-
isQuestion: true, // do one question at a time
|
861
|
-
getWasAsked,
|
862
|
-
getWasApplied,
|
863
|
-
onNevermind: ask.onNevermind,
|
864
|
-
source: 'question',
|
865
|
-
match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
866
|
-
apply: async (args) => {
|
867
|
-
let matchq = ask.matchq
|
868
|
-
let applyq = ask.applyq
|
869
|
-
if (!matchq) {
|
870
|
-
let wasAsked = false
|
871
|
-
matchq = () => !wasAsked,
|
872
|
-
applyq = (args) => {
|
873
|
-
wasAsked = true
|
874
|
-
return ask.applyq(args)
|
875
|
-
}
|
876
|
-
}
|
877
|
-
if (await matchq(args)) {
|
878
|
-
setWasAsked(true)
|
879
|
-
setWasApplied(false)
|
880
|
-
// args.context.motivationKeep = true
|
881
|
-
args.verbatim(await applyq(args))
|
882
|
-
/*
|
883
|
-
args.context.verbatim = applyq(args)
|
884
|
-
args.context.isResponse = true;
|
885
|
-
delete args.context.controlRemove;
|
886
|
-
*/
|
887
|
-
args.context.controlKeepMotivation = true
|
888
|
-
}
|
889
|
-
args.context.cascade = true
|
890
|
-
}
|
891
|
-
})
|
892
|
-
}
|
893
|
-
if (!Array.isArray(asks)) {
|
894
|
-
asks = [asks]
|
895
|
-
}
|
896
|
-
|
897
|
-
[...asks].reverse().forEach( (a) => ask(a) )
|
898
|
-
}
|
899
|
-
}
|
900
|
-
|
901
|
-
|
902
762
|
const initializer = ({objects, config, isModule}) => {
|
903
763
|
/* TODO add this beck in. some stuff from config needs to be here
|
904
764
|
config.addArgs((args) => ({
|
@@ -906,34 +766,15 @@ const initializer = ({objects, config, isModule}) => {
|
|
906
766
|
}))
|
907
767
|
*/
|
908
768
|
config.addArgs(({config, api, isA}) => ({
|
909
|
-
isAListable: (context, type) => {
|
910
|
-
if (context.marker == 'list' || context.listable) {
|
911
|
-
return context.value.every( (element) => isA(element.marker, type) )
|
912
|
-
} else {
|
913
|
-
return isA(context.marker, type)
|
914
|
-
}
|
915
|
-
},
|
916
|
-
toContext: (v) => {
|
917
|
-
if (Array.isArray(v)) {
|
918
|
-
return { marker: 'list', level: 1, value: v }
|
919
|
-
}
|
920
|
-
if (v.marker == 'list') {
|
921
|
-
return v
|
922
|
-
}
|
923
|
-
return v
|
924
|
-
},
|
925
|
-
getUUIDScoped: (uuid) => { return {
|
926
|
-
ask: getAsk(config)(uuid),
|
927
|
-
}
|
928
|
-
},
|
929
769
|
toScopedId: (context) => {
|
930
770
|
return api('dialogues').toScopedId(context)
|
931
771
|
},
|
932
772
|
addWords: (id, word, additional) => {
|
933
|
-
for (let props of words(word, additional)) {
|
934
|
-
config.addWord(id, props)
|
773
|
+
for (let props of words(word, { ...additional })) {
|
774
|
+
config.addWord(props.word, { id, initial: JSON.stringify(props) })
|
935
775
|
}
|
936
|
-
}
|
776
|
+
},
|
777
|
+
values: propertyToArray,
|
937
778
|
}))
|
938
779
|
objects.mentioned = []
|
939
780
|
objects.variables = {
|
@@ -947,7 +788,7 @@ const initializer = ({objects, config, isModule}) => {
|
|
947
788
|
|
948
789
|
knowledgeModule( {
|
949
790
|
config,
|
950
|
-
includes: [articles, gdefaults, sdefaults, pos, negation, stm, meta, punctuation],
|
791
|
+
includes: [articles, gdefaults, sdefaults, conjunction, asking, pos, negation, stm, meta, punctuation],
|
951
792
|
initializer,
|
952
793
|
api: () => new API(),
|
953
794
|
|
@@ -958,7 +799,7 @@ knowledgeModule( {
|
|
958
799
|
name: './dialogues.test.json',
|
959
800
|
contents: dialogues_tests,
|
960
801
|
checks: {
|
961
|
-
objects: ['
|
802
|
+
objects: ['idSuffix'],
|
962
803
|
context: defaultContextCheck,
|
963
804
|
},
|
964
805
|
|