tpmkms_4wp 8.0.0-beta.20 → 8.0.0-beta.22
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/animals.instance.json +0 -88
- package/common/animals.js +2 -2
- package/common/avatar.js +2 -2
- package/common/characters.js +12 -16
- package/common/colors.instance.json +0 -344
- package/common/colors.js +2 -2
- package/common/comparable.js +2 -15
- package/common/concept.js +13 -10
- package/common/countable.js +5 -5
- package/common/crew.instance.json +0 -416
- package/common/crew.js +4 -4
- package/common/currency.js +7 -7
- package/common/dialogues.js +52 -121
- package/common/dimension.instance.json +4 -4
- package/common/dimension.js +12 -12
- package/common/dimension.test.json +242 -1248
- package/common/edible.instance.json +30 -134
- package/common/edible.js +2 -2
- package/common/emotions.instance.json +0 -60
- package/common/emotions.js +4 -4
- package/common/events.js +6 -6
- package/common/fastfood.instance.json +929 -1408
- package/common/fastfood.js +24 -24
- package/common/formulas.instance.json +6 -6
- package/common/formulas.js +12 -12
- package/common/gdefaults.js +13 -13
- package/common/help.js +4 -4
- package/common/helpers/concept.js +0 -1
- package/common/helpers/dialogues.js +2 -3
- package/common/helpers/properties.js +48 -58
- package/common/hierarchy.js +12 -16
- package/common/javascript.js +8 -8
- package/common/kirk.js +2 -2
- package/common/length.instance.json +0 -60
- package/common/length.js +2 -2
- package/common/math.instance.json +12 -12
- package/common/math.js +7 -7
- package/common/meta.js +22 -29
- package/common/negation.js +1 -1
- package/common/numbers.js +2 -2
- package/common/ordering.js +5 -5
- package/common/people.js +4 -5
- package/common/percentages.js +4 -4
- package/common/pipboy.instance.json +30 -154
- package/common/pipboy.js +29 -32
- package/common/pokemon.instance.json +0 -44
- package/common/pokemon.js +4 -4
- package/common/pos.js +1 -1
- package/common/pressure.js +2 -2
- package/common/properties.js +52 -125
- package/common/punctuation.js +2 -2
- package/common/reports.instance.json +1 -1
- package/common/reports.js +59 -76
- package/common/scorekeeper.js +13 -21
- package/common/sdefaults.js +5 -5
- package/common/sizeable.js +2 -2
- package/common/spock.js +2 -2
- package/common/stgame.js +13 -9
- package/common/stm.js +4 -4
- package/common/tell.js +10 -10
- package/common/temperature.instance.json +0 -60
- package/common/temperature.js +2 -2
- package/common/tester.js +2 -2
- package/common/testing.js +5 -5
- package/common/time.js +7 -7
- package/common/tokenize.js +1 -1
- package/common/ui.js +9 -9
- package/common/weight.js +2 -2
- package/common/yesno.js +1 -1
- package/package.json +2 -2
package/common/dialogues.js
CHANGED
@@ -105,7 +105,7 @@ let configStruct = {
|
|
105
105
|
{
|
106
106
|
id: 'makeObject',
|
107
107
|
bridge: "{ ...next(operator), object: after[0] }",
|
108
|
-
generatorp: ({context, gp}) => `${context.word} ${gp(context.object)}`,
|
108
|
+
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.object)}`,
|
109
109
|
semantic: ({config, context, api}) => {
|
110
110
|
api.makeObject({ context: context.object, config, types: [] })
|
111
111
|
}
|
@@ -113,7 +113,7 @@ let configStruct = {
|
|
113
113
|
{
|
114
114
|
id: 'setIdSuffix',
|
115
115
|
bridge: "{ ...next(operator), suffix: after[0] }",
|
116
|
-
generatorp: ({context, gp}) => `${context.word} ${gp(context.suffix)}`,
|
116
|
+
generatorp: async ({context, gp}) => `${context.word} ${await gp(context.suffix)}`,
|
117
117
|
semantic: ({context, api}) => {
|
118
118
|
api.setIdSuffix(context.suffix.text)
|
119
119
|
}
|
@@ -163,8 +163,8 @@ let configStruct = {
|
|
163
163
|
level: 0,
|
164
164
|
isA: ['preposition'],
|
165
165
|
bridge: "{ ...next(operator), toObject: after[0] }",
|
166
|
-
generatorp: ({context, gp}) => {
|
167
|
-
return `to ${gp(context.toObject)}`
|
166
|
+
generatorp: async ({context, gp}) => {
|
167
|
+
return `to ${await gp(context.toObject)}`
|
168
168
|
},
|
169
169
|
},
|
170
170
|
{ id: "toAble", level: 0, bridge: "{ ...next(operator) }" },
|
@@ -350,10 +350,10 @@ let configStruct = {
|
|
350
350
|
where: where(),
|
351
351
|
notes: "handle making responses brief",
|
352
352
|
match: ({context, objects}) => (context.topLevel || context.isResponse) && objects.brief && !context.briefWasRun,
|
353
|
-
apply: ({context, g}) => {
|
353
|
+
apply: async ({context, g}) => {
|
354
354
|
const focussed = focus(context)
|
355
355
|
context.briefWasRun = true
|
356
|
-
return g(focussed)
|
356
|
+
return await g(focussed)
|
357
357
|
},
|
358
358
|
priority: -2,
|
359
359
|
},
|
@@ -414,8 +414,8 @@ let configStruct = {
|
|
414
414
|
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
415
415
|
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
416
416
|
match: ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value && context.value.length > 0 && context.value[0].marker == 'yesno',
|
417
|
-
apply: ({context, g, gs}) => {
|
418
|
-
return `${g(context.value[0])} ${gs(context.value.slice(1), ', ', ' and ')}`
|
417
|
+
apply: async ({context, g, gs}) => {
|
418
|
+
return `${await g(context.value[0])} ${await gs(context.value.slice(1), ', ', ' and ')}`
|
419
419
|
}
|
420
420
|
},
|
421
421
|
|
@@ -425,11 +425,11 @@ let configStruct = {
|
|
425
425
|
// ({context, hierarchy}) => context.marker == 'list' && context.paraphrase && context.value,
|
426
426
|
// ({context, hierarchy}) => context.marker == 'list' && context.value,
|
427
427
|
match: ({context, hierarchy}) => context.marker == 'list' && context.value,
|
428
|
-
apply: ({context, gs}) => {
|
428
|
+
apply: async ({context, gs}) => {
|
429
429
|
if (context.newLinesOnly) {
|
430
|
-
return gs(context.value, '\n')
|
430
|
+
return await gs(context.value, '\n')
|
431
431
|
} else {
|
432
|
-
return gs(context.value, ', ', ' and ')
|
432
|
+
return await gs(context.value, ', ', ' and ')
|
433
433
|
}
|
434
434
|
}
|
435
435
|
},
|
@@ -439,23 +439,10 @@ let configStruct = {
|
|
439
439
|
notes: 'paraphrase a queryable response',
|
440
440
|
// || context.evalue.paraphrase -> when the evalue acts as a paraphrase value
|
441
441
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.evalue && (!context.paraphrase || context.evalue.paraphrase),
|
442
|
-
apply: ({context, g}) => {
|
443
|
-
return g(context.evalue)
|
442
|
+
apply: async ({context, g}) => {
|
443
|
+
return await g(context.evalue)
|
444
444
|
}
|
445
445
|
},
|
446
|
-
/* dup of one above
|
447
|
-
{
|
448
|
-
where: where(),
|
449
|
-
notes: 'paraphrase a queryable',
|
450
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && !context.paraphrase && context.evalue,
|
451
|
-
apply: ({context, g}) => {
|
452
|
-
const oldValue = context.evalue.paraphrase
|
453
|
-
const result = g(context.evalue)
|
454
|
-
context.evalue.paraphrase = oldValue
|
455
|
-
return result
|
456
|
-
}
|
457
|
-
},
|
458
|
-
*/
|
459
446
|
{
|
460
447
|
where: where(),
|
461
448
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.isSelf && context.subject == 'my',
|
@@ -464,7 +451,7 @@ let configStruct = {
|
|
464
451
|
{
|
465
452
|
where: where(),
|
466
453
|
match: ({context, hierarchy}) => ['it', 'what'].includes(context.marker) && context.paraphrase,
|
467
|
-
apply: ({
|
454
|
+
apply: ({context}) => `${context.word}`
|
468
455
|
},
|
469
456
|
{
|
470
457
|
where: where(),
|
@@ -474,15 +461,8 @@ let configStruct = {
|
|
474
461
|
{
|
475
462
|
where: where(),
|
476
463
|
match: ({context, hierarchy}) => ['my', 'your'].includes(context.subject) && hierarchy.isA(context.marker, 'queryable') && context.paraphrase,
|
477
|
-
apply: ({
|
478
|
-
},
|
479
|
-
/*
|
480
|
-
{
|
481
|
-
where: where(),
|
482
|
-
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'theAble') && context.paraphrase && context.wantsValue && !context.pullFromContext,
|
483
|
-
apply: ({g, context}) => `a ${context.word}`
|
464
|
+
apply: ({context}) => `${context.subject} ${context.marker}`
|
484
465
|
},
|
485
|
-
*/
|
486
466
|
{
|
487
467
|
where: where(),
|
488
468
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'queryable') && !context.isQuery && context.subject,
|
@@ -507,8 +487,8 @@ let configStruct = {
|
|
507
487
|
{
|
508
488
|
where: where(),
|
509
489
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'canBeQuestion') && context.paraphrase && context.topLevel && context.query,
|
510
|
-
apply: ({context, gp}) => {
|
511
|
-
return `${gp({...context, topLevel: undefined})}?`
|
490
|
+
apply: async ({context, gp}) => {
|
491
|
+
return `${await gp({...context, topLevel: undefined})}?`
|
512
492
|
},
|
513
493
|
priority: -1,
|
514
494
|
},
|
@@ -516,27 +496,27 @@ let configStruct = {
|
|
516
496
|
where: where(),
|
517
497
|
notes: "x is y",
|
518
498
|
match: ({context, hierarchy}) => { return hierarchy.isA(context.marker, 'is') && context.paraphrase },
|
519
|
-
apply: ({context, g, gp}) => {
|
520
|
-
return `${g({ ...context.one, paraphrase: true })} ${context.word} ${gp(context.two)}`
|
499
|
+
apply: async ({context, g, gp}) => {
|
500
|
+
return `${await g({ ...context.one, paraphrase: true })} ${context.word} ${await gp(context.two)}`
|
521
501
|
}
|
522
502
|
},
|
523
503
|
{
|
524
504
|
where: where(),
|
525
505
|
notes: 'is with a response defined',
|
526
506
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.evalue,
|
527
|
-
apply: ({context, g, gs}) => {
|
507
|
+
apply: async ({context, g, gs}) => {
|
528
508
|
const response = context.evalue;
|
529
509
|
const concept = response.concept;
|
530
510
|
if (concept) {
|
531
511
|
concept.paraphrase = true
|
532
512
|
concept.isSelf = true
|
533
|
-
const instance = g(response.instance)
|
534
|
-
return `${g(concept)} ${context.word} ${instance}`
|
513
|
+
const instance = await g(response.instance)
|
514
|
+
return `${await g(concept)} ${context.word} ${instance}`
|
535
515
|
} else {
|
536
516
|
if (Array.isArray(response)) {
|
537
|
-
return `${gs(response)}`
|
517
|
+
return `${await gs(response)}`
|
538
518
|
} else {
|
539
|
-
return `${g(response)}`
|
519
|
+
return `${await g(response)}`
|
540
520
|
}
|
541
521
|
}
|
542
522
|
}
|
@@ -545,13 +525,13 @@ let configStruct = {
|
|
545
525
|
where: where(),
|
546
526
|
notes: 'x is y (not a response)',
|
547
527
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && !context.evalue,
|
548
|
-
apply: ({context, g, gp, gr, callId}) => {
|
528
|
+
apply: async ({context, g, gp, gr, callId}) => {
|
549
529
|
if ((context.two.evalue || {}).marker == 'answerNotKnown') {
|
550
|
-
return g(context.two.evalue)
|
530
|
+
return await g(context.two.evalue)
|
551
531
|
}
|
552
532
|
|
553
533
|
if (!context.isResponse) {
|
554
|
-
return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
534
|
+
return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
|
555
535
|
}
|
556
536
|
|
557
537
|
const hasFocus = (property) => {
|
@@ -576,17 +556,15 @@ let configStruct = {
|
|
576
556
|
}
|
577
557
|
// greg101
|
578
558
|
if (focus == 'one') {
|
579
|
-
return `${g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gp(context.one)}`
|
559
|
+
return `${await g(context.two)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gp(context.one)}`
|
580
560
|
} else {
|
581
561
|
// TODO fix this using the assumed and that whole mess. change isResponse to useValue
|
582
562
|
if (context.isResponse) {
|
583
|
-
return `${gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
563
|
+
return `${await gp(context.one, { responding: true })} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await g(context.two)}`
|
584
564
|
} else {
|
585
|
-
return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${gr(context.two)}`
|
565
|
+
return `${await gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${await gr(context.two)}`
|
586
566
|
}
|
587
|
-
// return `${gp(context.one)} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
588
567
|
}
|
589
|
-
// return `${g({...context.one})} ${isMany(context.one) || isMany(context.two) || isMany(context) ? "are" : "is"} ${g(context.two)}`
|
590
568
|
},
|
591
569
|
},
|
592
570
|
],
|
@@ -612,10 +590,10 @@ let configStruct = {
|
|
612
590
|
{
|
613
591
|
where: where(),
|
614
592
|
match: ({context}) => context.marker === 'error',
|
615
|
-
apply: ({context, gp}) => {
|
593
|
+
apply: async ({context, gp}) => {
|
616
594
|
context.evalue = "That is not known"
|
617
595
|
if (context.reason) {
|
618
|
-
context.evalue += ` because ${gp(context.reason)}`
|
596
|
+
context.evalue += ` because ${await gp(context.reason)}`
|
619
597
|
}
|
620
598
|
context.isResponse = true
|
621
599
|
}
|
@@ -625,7 +603,7 @@ let configStruct = {
|
|
625
603
|
notes: 'pull from context',
|
626
604
|
// match: ({context}) => context.marker == 'it' && context.pullFromContext, // && context.value,
|
627
605
|
match: ({context, callId}) => context.pullFromContext && !context.same, // && context.value,
|
628
|
-
apply: ({callId, context,
|
606
|
+
apply: async ({callId, context, kms, e, log, retry}) => {
|
629
607
|
if (true) {
|
630
608
|
/*
|
631
609
|
{
|
@@ -659,7 +637,7 @@ let configStruct = {
|
|
659
637
|
return
|
660
638
|
}
|
661
639
|
|
662
|
-
const instance = e(context.value)
|
640
|
+
const instance = await e(context.value)
|
663
641
|
if (instance.evalue && !instance.edefault) {
|
664
642
|
context.value = instance.evalue
|
665
643
|
}
|
@@ -701,7 +679,7 @@ let configStruct = {
|
|
701
679
|
// avoid loops
|
702
680
|
if (context.marker != 'unknown') {
|
703
681
|
if (context.value.marker != context.marker) {
|
704
|
-
const instance = e(context.value)
|
682
|
+
const instance = await e(context.value)
|
705
683
|
if (instance.evalue && !instance.edefault) {
|
706
684
|
context.value = instance.evalue
|
707
685
|
}
|
@@ -723,7 +701,7 @@ let configStruct = {
|
|
723
701
|
*/
|
724
702
|
|
725
703
|
match: ({context, hierarchy}) => hierarchy.isA(context.marker, 'is') && context.query,
|
726
|
-
apply: ({context, s, log, km, objects, e}) => {
|
704
|
+
apply: async ({context, s, log, km, objects, e}) => {
|
727
705
|
const one = context.one;
|
728
706
|
const two = context.two;
|
729
707
|
let concept, value;
|
@@ -737,7 +715,7 @@ let configStruct = {
|
|
737
715
|
// km('dialogues').api.mentioned(concept)
|
738
716
|
// TODO wtf is the next line?
|
739
717
|
value = JSON.parse(JSON.stringify(value))
|
740
|
-
let instance = e(value)
|
718
|
+
let instance = await e(value)
|
741
719
|
if (false && instance.evalue) {
|
742
720
|
km('stm').api.mentioned(value)
|
743
721
|
}
|
@@ -801,14 +779,14 @@ let configStruct = {
|
|
801
779
|
where: where(),
|
802
780
|
notes: 'x is y. handles x is a kind of y or x = y in the stm',
|
803
781
|
match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
|
804
|
-
apply: ({context, s, log, api, kms, config}) => {
|
782
|
+
apply: async ({context, s, log, api, kms, config}) => {
|
805
783
|
// const oneZero = { ...context.one }
|
806
784
|
// const twoZero = { ...context.two }
|
807
785
|
|
808
786
|
const one = context.one;
|
809
787
|
const two = context.two;
|
810
788
|
one.same = two;
|
811
|
-
const onePrime = s(one)
|
789
|
+
const onePrime = await s(one)
|
812
790
|
if (!onePrime.sameWasProcessed) {
|
813
791
|
warningSameNotEvaluated(log, one)
|
814
792
|
} else {
|
@@ -821,7 +799,7 @@ let configStruct = {
|
|
821
799
|
let twoPrime;
|
822
800
|
if (!onePrime.sameWasProcessed) {
|
823
801
|
two.same = one
|
824
|
-
twoPrime = s(two)
|
802
|
+
twoPrime = await s(two)
|
825
803
|
if (!twoPrime.sameWasProcessed) {
|
826
804
|
warningSameNotEvaluated(log, two)
|
827
805
|
} else {
|
@@ -840,20 +818,6 @@ let configStruct = {
|
|
840
818
|
}
|
841
819
|
}
|
842
820
|
},
|
843
|
-
/*
|
844
|
-
{
|
845
|
-
where: where(),
|
846
|
-
notes: 'x = y in the stm',
|
847
|
-
match: ({context}) => context.marker == 'is' && !context.query && context.one && context.two,
|
848
|
-
apply: ({context, s, log, api, kms, config}) => {
|
849
|
-
const one = context.one;
|
850
|
-
const two = context.two;
|
851
|
-
api.makeObject({ context: one, config, types: context.two.types || [] })
|
852
|
-
kms.stm.api.setVariable(one.value, two)
|
853
|
-
kms.stm.api.mentioned(one, two)
|
854
|
-
}
|
855
|
-
},
|
856
|
-
*/
|
857
821
|
{
|
858
822
|
where: where(),
|
859
823
|
notes: 'get variable from stm',
|
@@ -861,48 +825,15 @@ let configStruct = {
|
|
861
825
|
match: ({context, kms}) => context.evaluate && kms.stm.api.getVariable(context.value) != context.value,
|
862
826
|
// match: ({context, kms}) => context.evaluate,
|
863
827
|
priority: -1,
|
864
|
-
apply: ({context, kms, e}) => {
|
828
|
+
apply: async ({context, kms, e}) => {
|
865
829
|
const api = kms.stm.api
|
866
830
|
context.value = api.getVariable(context.value)
|
867
|
-
/*
|
868
|
-
if (!context.value && context.marker !== 'unknown') {
|
869
|
-
context.value = api.getVariable(context.marker)
|
870
|
-
}
|
871
|
-
*/
|
872
831
|
if (context.value && context.value.marker) {
|
873
|
-
context.evalue = e(context.value)
|
832
|
+
context.evalue = await e(context.value)
|
874
833
|
}
|
875
834
|
context.focusableForPhrase = true
|
876
835
|
}
|
877
836
|
},
|
878
|
-
/*
|
879
|
-
{
|
880
|
-
where: where(),
|
881
|
-
notes: 'default handle evaluate',
|
882
|
-
match: ({context, kms}) => context.evaluate && context.value,
|
883
|
-
// match: ({context, kms}) => context.evaluate,
|
884
|
-
// priority: -1,
|
885
|
-
apply: ({context, kms, e}) => {
|
886
|
-
if (context.value && context.value.marker) {
|
887
|
-
context.evalue = e(context.value)
|
888
|
-
}
|
889
|
-
}
|
890
|
-
},
|
891
|
-
*/
|
892
|
-
/*
|
893
|
-
{
|
894
|
-
priority: 2,
|
895
|
-
notes: 'evaluate top level not already done',
|
896
|
-
match: ({context}) => false && context.topLevel && !context.evalue,
|
897
|
-
apply: ({context, e}) => {
|
898
|
-
const instance = e({ ...context, value: undefined, topLevel: undefined })
|
899
|
-
if (instance.evalue && !instance.edefault) {
|
900
|
-
context.evalue = instance
|
901
|
-
context.isResponse = true
|
902
|
-
}
|
903
|
-
}
|
904
|
-
},
|
905
|
-
*/
|
906
837
|
],
|
907
838
|
};
|
908
839
|
|
@@ -947,9 +878,9 @@ const getAsk = (config) => (uuid) => {
|
|
947
878
|
where: semantic.where || ask.where || where(2),
|
948
879
|
source: 'response',
|
949
880
|
match: (args) => semantic.match(args),
|
950
|
-
apply: (args) => {
|
881
|
+
apply: async (args) => {
|
951
882
|
setWasApplied(true)
|
952
|
-
semantic.apply(args)
|
883
|
+
await semantic.apply(args)
|
953
884
|
},
|
954
885
|
})
|
955
886
|
}
|
@@ -966,7 +897,7 @@ const getAsk = (config) => (uuid) => {
|
|
966
897
|
onNevermind: ask.onNevermind,
|
967
898
|
source: 'question',
|
968
899
|
match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
|
969
|
-
apply: (args) => {
|
900
|
+
apply: async (args) => {
|
970
901
|
let matchq = ask.matchq
|
971
902
|
let applyq = ask.applyq
|
972
903
|
if (!matchq) {
|
@@ -977,11 +908,11 @@ const getAsk = (config) => (uuid) => {
|
|
977
908
|
return ask.applyq(args)
|
978
909
|
}
|
979
910
|
}
|
980
|
-
if (matchq(args)) {
|
911
|
+
if (await matchq(args)) {
|
981
912
|
setWasAsked(true)
|
982
913
|
setWasApplied(false)
|
983
914
|
// args.context.motivationKeep = true
|
984
|
-
args.verbatim(applyq(args))
|
915
|
+
args.verbatim(await applyq(args))
|
985
916
|
/*
|
986
917
|
args.context.verbatim = applyq(args)
|
987
918
|
args.context.isResponse = true;
|
@@ -1002,12 +933,12 @@ const getAsk = (config) => (uuid) => {
|
|
1002
933
|
}
|
1003
934
|
|
1004
935
|
|
1005
|
-
const createConfig = () => {
|
936
|
+
const createConfig = async () => {
|
1006
937
|
const config = new Config(configStruct, module)
|
1007
938
|
config.stop_auto_rebuild()
|
1008
|
-
config.api
|
1009
|
-
config.add(gdefaults
|
1010
|
-
config.initializer( ({objects, config, isModule}) => {
|
939
|
+
await config.setApi(api)
|
940
|
+
await config.add(gdefaults, sdefaults, pos, negation, stm, meta, punctuation)
|
941
|
+
await config.initializer( ({objects, config, isModule}) => {
|
1011
942
|
/* TODO add this beck in. some stuff from config needs to be here
|
1012
943
|
config.addArgs((args) => ({
|
1013
944
|
e: (context) => config.api.getEvaluator(args.s, args.log, context),
|
@@ -1047,7 +978,7 @@ const createConfig = () => {
|
|
1047
978
|
config.addWord("doesable", { id: "doesAble", "initial": "{}" })
|
1048
979
|
}
|
1049
980
|
})
|
1050
|
-
config.restart_auto_rebuild()
|
981
|
+
await config.restart_auto_rebuild()
|
1051
982
|
return config
|
1052
983
|
}
|
1053
984
|
|
@@ -43,7 +43,7 @@
|
|
43
43
|
{
|
44
44
|
"where": "/home/dev/code/theprogrammablemind/kms/common/dimension.js:77",
|
45
45
|
"match": "({context}) => context.marker == 'noconversion'",
|
46
|
-
"apply": "({context, gp}) => `there is no conversion between ${gp(context.from)} and ${gp(context.to)}`"
|
46
|
+
"apply": "async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`"
|
47
47
|
}
|
48
48
|
],
|
49
49
|
"bridges": [
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"isA": [
|
76
76
|
"amount"
|
77
77
|
],
|
78
|
-
"generatorp": "({context, g}) => (context.amount) ? `${g(context.amount)} ${context.word}` : context.word",
|
78
|
+
"generatorp": "async ({context, g}) => (context.amount) ? `${await g(context.amount)} ${context.word}` : context.word",
|
79
79
|
"bridge": "{ ...next(operator), value: before[0].value, amount: before[0] }"
|
80
80
|
},
|
81
81
|
{
|
@@ -101,8 +101,8 @@
|
|
101
101
|
1
|
102
102
|
]
|
103
103
|
],
|
104
|
-
"generatorp": "({context, g}) => `${g(context.from)} ${context.word} ${g(context.to)}`",
|
105
|
-
"evaluator": "({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = e(from).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned(reason)\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
|
104
|
+
"generatorp": "async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`",
|
105
|
+
"evaluator": "async ({context, kms, e, error}) => {\n /*\n error(({context, e}) => {\n context.evalue = 'dont know...'\n })\n */\n const from = context.from;\n const to = context.to;\n let evalue;\n let efrom = from\n if (!from.unit) {\n efrom = (await e(from)).evalue\n }\n if (to.value == efrom.unit.value) {\n evalue = efrom.amount\n } else {\n const formula = kms.formulas.api.get(to, [efrom.unit])\n if (!formula) {\n const reason = { marker: 'reason', focusableForPhrase: true, evalue: { marker: 'noconversion', from: efrom.unit, to } }\n kms.stm.api.mentioned(reason)\n error(reason)\n }\n kms.stm.api.setVariable(efrom.unit.value, efrom.amount)\n evalue = await e(formula)\n }\n /*\n '{\n \"marker\":\"dimension\",\n \"unit\":{\"marker\":\"unit\",\"range\":{\"start\":19,\"end\":25},\"word\":\"celcius\",\"text\":\"celcius\",\"value\":\"celcius\",\"unknown\":true,\"types\":[\"unit\",\"unknown\"]},\n \"value\":10,\n \"amount\":{\"word\":\"degrees\",\"number\":\"many\",\"text\":\"10 degrees\",\"marker\":\"degree\",\"range\":{\"start\":8,\"end\":17},\"value\":10,\"amount\":{\"value\":10,\"text\":\"10\",\"marker\":\"number\",\"word\":\"10\",\"range\":{\"start\":8,\"end\":9},\"types\":[\"number\"]}},\n \"text\":\"10 degrees celcius\",\"range\":{\"start\":8,\"end\":25}}'\n */\n context.evalue = { \n paraphrase: true,\n marker: 'dimension',\n level: 1,\n unit: to,\n amount: { evalue, paraphrase: undefined }\n }\n }"
|
106
106
|
},
|
107
107
|
{
|
108
108
|
"id": "unit"
|
package/common/dimension.js
CHANGED
@@ -36,7 +36,7 @@ class API {
|
|
36
36
|
config.addBridge({
|
37
37
|
id: dimension,
|
38
38
|
isA: ['dimension'],
|
39
|
-
generatorp: ({context, g}) => context.amount ? `${g(context.amount)} ${g(context.unit)}` : context.word,
|
39
|
+
generatorp: async ({context, g}) => context.amount ? `${await g(context.amount)} ${await g(context.unit)}` : context.word,
|
40
40
|
})
|
41
41
|
|
42
42
|
// for example, celcius and fahrenheit
|
@@ -76,7 +76,7 @@ let configStruct = {
|
|
76
76
|
{
|
77
77
|
where: where(),
|
78
78
|
match: ({context}) => context.marker == 'noconversion',
|
79
|
-
apply: ({context, gp}) => `there is no conversion between ${gp(context.from)} and ${gp(context.to)}`,
|
79
|
+
apply: async ({context, gp}) => `there is no conversion between ${await gp(context.from)} and ${await gp(context.to)}`,
|
80
80
|
},
|
81
81
|
],
|
82
82
|
bridges: [
|
@@ -86,7 +86,7 @@ let configStruct = {
|
|
86
86
|
isA: [],
|
87
87
|
generatorpr: {
|
88
88
|
match: ({context}) => context.amount,
|
89
|
-
apply: ({context,
|
89
|
+
apply: async ({context, gp, gr}) => `${await gr(context.amount)} ${await gp(context.unit)}`,
|
90
90
|
},
|
91
91
|
},
|
92
92
|
{ id: "length", isA: ['dimension'], development: true },
|
@@ -105,7 +105,7 @@ let configStruct = {
|
|
105
105
|
id: "degree",
|
106
106
|
words: [{ word: 'degrees', number: 'many' }],
|
107
107
|
isA: ['amount'],
|
108
|
-
generatorp: ({context, g}) => (context.amount) ? `${g(context.amount)} ${context.word}` : context.word,
|
108
|
+
generatorp: async ({context, g}) => (context.amount) ? `${await g(context.amount)} ${context.word}` : context.word,
|
109
109
|
bridge: "{ ...next(operator), value: before[0].value, amount: before[0] }",
|
110
110
|
},
|
111
111
|
{
|
@@ -119,9 +119,9 @@ let configStruct = {
|
|
119
119
|
bridge: "{ ...next(operator), from: before[0], to: after[0] }",
|
120
120
|
isA: ['expression', 'queryable'],
|
121
121
|
after: [['possession', 0], ['possession', 1]],
|
122
|
-
generatorp: ({context, g}) => `${g(context.from)} ${context.word} ${g(context.to)}`,
|
122
|
+
generatorp: async ({context, g}) => `${await g(context.from)} ${context.word} ${await g(context.to)}`,
|
123
123
|
// evaluator: ({context, kms, error}) => {
|
124
|
-
evaluator: ({context, kms, e, error}) => {
|
124
|
+
evaluator: async ({context, kms, e, error}) => {
|
125
125
|
/*
|
126
126
|
error(({context, e}) => {
|
127
127
|
context.evalue = 'dont know...'
|
@@ -132,7 +132,7 @@ let configStruct = {
|
|
132
132
|
let evalue;
|
133
133
|
let efrom = from
|
134
134
|
if (!from.unit) {
|
135
|
-
efrom = e(from).evalue
|
135
|
+
efrom = (await e(from)).evalue
|
136
136
|
}
|
137
137
|
if (to.value == efrom.unit.value) {
|
138
138
|
evalue = efrom.amount
|
@@ -144,7 +144,7 @@ let configStruct = {
|
|
144
144
|
error(reason)
|
145
145
|
}
|
146
146
|
kms.stm.api.setVariable(efrom.unit.value, efrom.amount)
|
147
|
-
evalue = e(formula)
|
147
|
+
evalue = await e(formula)
|
148
148
|
}
|
149
149
|
/*
|
150
150
|
'{
|
@@ -174,12 +174,12 @@ const template = {
|
|
174
174
|
],
|
175
175
|
}
|
176
176
|
|
177
|
-
const createConfig = () => {
|
177
|
+
const createConfig = async () => {
|
178
178
|
const config = new Config({ name: 'dimension' }, module)
|
179
179
|
config.stop_auto_rebuild()
|
180
|
-
config.add(hierarchy
|
181
|
-
config.api
|
182
|
-
config.restart_auto_rebuild()
|
180
|
+
await config.add(hierarchy, formulas, testing)
|
181
|
+
await config.setApi(api)
|
182
|
+
await config.restart_auto_rebuild()
|
183
183
|
return config
|
184
184
|
}
|
185
185
|
|