tpmkms 9.5.1-beta.10 → 9.5.1-beta.13

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.
@@ -2,6 +2,7 @@ const pluralize = require('pluralize')
2
2
  const { defaultContextCheck, getValue, isMany } = require('./helpers')
3
3
  const { knowledgeModule, where, flatten } = require('./runtime').theprogrammablemind
4
4
  const tokenize = require('./tokenize.js')
5
+ const words = require('./words.js')
5
6
  const gdefaults_tests = require('./gdefaults.test.json')
6
7
  const englishHelpers = require('./english_helpers.js')
7
8
  const helpers = require('./helpers')
@@ -89,7 +90,7 @@ const config = {
89
90
  text.push(await g(m))
90
91
  }
91
92
  } else {
92
- text.push(await g(context[modifier], { isModifier: true }))
93
+ text.push(await g(context[modifier], { assumed: { isModifier: true } }))
93
94
  }
94
95
  }
95
96
  // text.push(context.word)
@@ -151,12 +152,16 @@ const config = {
151
152
  {
152
153
  where: where(),
153
154
  priority: -1,
154
- match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
155
+ // match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && context.number == 'one' && !context.imperative && !context.interpolate,
156
+ match: ({context}) => context.evaluateWord && context.isVerb && context.paraphrase && context.word && !context.imperative && !context.interpolate,
155
157
  apply: ({context}) => {
156
158
  const infinitive = englishHelpers.getInfinitive(context.word)
157
- if (context.tense) {
159
+ if (context.form == 'infinitive') {
160
+ const cases = englishHelpers.conjugateVerb(infinitive)
161
+ const def = cases.find((def) => def.form == context.form)
162
+ return def.word
163
+ } else if (context.tense) {
158
164
  const cases = englishHelpers.conjugateVerb(infinitive)
159
- // console.log(JSON.stringify(cases, null, 2))
160
165
  const def = cases.find((def) => def.tense == context.tense)
161
166
  return def.word
162
167
  } else {
@@ -165,6 +170,7 @@ const config = {
165
170
  },
166
171
  },
167
172
 
173
+ /*
168
174
  {
169
175
  where: where(),
170
176
  priority: -1,
@@ -175,7 +181,7 @@ const config = {
175
181
  return pluralize.singular(context.word)
176
182
  },
177
183
  },
178
-
184
+ */
179
185
  {
180
186
  where: where(),
181
187
  priority: -1,
@@ -301,7 +307,15 @@ function initializer({config}) {
301
307
  const strings = []
302
308
  let separator = ''
303
309
  for (const element of interpolate) {
304
- if (typeof element == 'string') {
310
+ // { "word": { "marker": "canPassive" } ie { word: <selectionCriteria> }
311
+ if (element.word) {
312
+ const word = args.getWordFromDictionary(element.word)
313
+ if (word) {
314
+ strings.push(separator)
315
+ strings.push(await args.gp(word))
316
+ separator = ' '
317
+ }
318
+ } else if (typeof element == 'string') {
305
319
  separator = element
306
320
  } else if (element.separator && element.values) {
307
321
  let ctr = 0
@@ -315,8 +329,33 @@ function initializer({config}) {
315
329
  vstrings.push(getValue(value))
316
330
  }
317
331
  strings.push(await args.gsp(vstrings))
318
- } else {
319
- let value = element
332
+ } else if (element.semantic) {
333
+ const wordContext = {}
334
+ for (const term of element.semantic) {
335
+ if (term.property) {
336
+ Object.assign(wordContext, context[term.property])
337
+ } else if (term.overrides) {
338
+ Object.assign(wordContext, term.overrides)
339
+ }
340
+ }
341
+ const value = await args.gp(wordContext) //, { options: { debug: { apply: true } } })
342
+ if (value) {
343
+ strings.push(separator)
344
+ strings.push(await args.gp(value))
345
+ separator = ' '
346
+ }
347
+ } else if (element.property) {
348
+ value = context[element.property]
349
+ if (value) {
350
+ if (element.context) {
351
+ value = { ...value, ...element.context }
352
+ }
353
+ strings.push(separator)
354
+ strings.push(await args.gp(value))
355
+ separator = ' '
356
+ }
357
+ } else if (element.context) {
358
+ let value = element.context
320
359
  if (element.property) {
321
360
  value = context[element.property]
322
361
  if (element.context) {
@@ -324,7 +363,7 @@ function initializer({config}) {
324
363
  }
325
364
  }
326
365
  // if (!value?.number && element.number) {
327
- if (value?.number !== 'infinitive' && element.number) {
366
+ if (value?.form !== 'infinitive' && element.number) {
328
367
  value.number = isMany(context[element.number]) ? "many": "one"
329
368
  }
330
369
  if (value) {
@@ -345,7 +384,7 @@ function initializer({config}) {
345
384
 
346
385
  knowledgeModule({
347
386
  config,
348
- includes: [tokenize],
387
+ includes: [tokenize, words],
349
388
  initializer,
350
389
 
351
390
  module,
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "contexts": [
54
54
  {
55
+ "context_id": 2,
55
56
  "context_index": 1,
56
57
  "dead": true,
57
58
  "default": true,
@@ -230,6 +231,8 @@
230
231
  ]
231
232
  },
232
233
  "objects": {
234
+ "associations": [
235
+ ],
233
236
  "nameToUUID": {
234
237
  "articles": "articles2",
235
238
  "asking": "asking2",
@@ -244,50 +247,71 @@
244
247
  "punctuation": "punctuation2",
245
248
  "sdefaults": "sdefaults2",
246
249
  "stm": "stm2",
247
- "tokenize": "tokenize2"
250
+ "tokenize": "tokenize2",
251
+ "words": "words2"
248
252
  },
249
253
  "namespaced": {
250
254
  "articles2": {
255
+ "km": "articles2"
251
256
  },
252
257
  "asking2": {
258
+ "km": "asking2"
253
259
  },
254
260
  "conjunction2": {
261
+ "km": "conjunction2"
255
262
  },
256
263
  "dialogues2": {
257
264
  "idSuffix": "",
265
+ "km": "dialogues2",
258
266
  "mentioned": [
259
267
  ],
260
268
  "variables": {
261
269
  }
262
270
  },
263
271
  "evaluate2": {
272
+ "km": "evaluate2"
264
273
  },
265
274
  "gdefaults2": {
275
+ "km": "gdefaults2"
266
276
  },
267
277
  "help1": {
278
+ "km": "help1"
268
279
  },
269
280
  "meta2": {
281
+ "km": "meta2"
270
282
  },
271
283
  "negation2": {
284
+ "km": "negation2"
272
285
  },
273
286
  "pos2": {
287
+ "km": "pos2"
274
288
  },
275
289
  "punctuation2": {
290
+ "km": "punctuation2"
276
291
  },
277
292
  "sdefaults2": {
293
+ "km": "sdefaults2"
278
294
  },
279
295
  "stm2": {
296
+ "km": "stm2",
280
297
  "mentioned": [
281
298
  ],
282
299
  "variables": {
283
300
  }
284
301
  },
285
302
  "tokenize2": {
303
+ "km": "tokenize2"
304
+ },
305
+ "words2": {
306
+ "km": "words2",
307
+ "words": [
308
+ ]
286
309
  }
287
310
  },
288
311
  "processed": [
289
312
  {
290
313
  "context": {
314
+ "context_id": 2,
291
315
  "context_index": 1,
292
316
  "dead": true,
293
317
  "default": true,
@@ -352,9 +376,12 @@
352
376
  "value": "help",
353
377
  "word": "help"
354
378
  },
355
- "generatedParenthesized": "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n)",
356
- "paraphrases": "help",
357
- "paraphrasesParenthesized": "(help)",
379
+ "generatedParenthesized": [
380
+ ],
381
+ "paraphrases": [
382
+ ],
383
+ "paraphrasesParenthesized": [
384
+ ],
358
385
  "responses": [
359
386
  " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n"
360
387
  ]
@@ -626,6 +653,7 @@
626
653
  },
627
654
  "contexts": [
628
655
  {
656
+ "context_id": 2,
629
657
  "context_index": 1,
630
658
  "dead": true,
631
659
  "default": true,
@@ -645,7 +673,7 @@
645
673
  }
646
674
  ],
647
675
  "generatedParenthesized": [
648
- "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)"
676
+ "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)"
649
677
  ],
650
678
  "metadata": {
651
679
  "opChoices": [
@@ -665,6 +693,8 @@
665
693
  ]
666
694
  },
667
695
  "objects": {
696
+ "associations": [
697
+ ],
668
698
  "nameToUUID": {
669
699
  "articles": "articles2",
670
700
  "asking": "asking2",
@@ -679,50 +709,71 @@
679
709
  "punctuation": "punctuation2",
680
710
  "sdefaults": "sdefaults2",
681
711
  "stm": "stm2",
682
- "tokenize": "tokenize2"
712
+ "tokenize": "tokenize2",
713
+ "words": "words2"
683
714
  },
684
715
  "namespaced": {
685
716
  "articles2": {
717
+ "km": "articles2"
686
718
  },
687
719
  "asking2": {
720
+ "km": "asking2"
688
721
  },
689
722
  "conjunction2": {
723
+ "km": "conjunction2"
690
724
  },
691
725
  "dialogues2": {
692
726
  "idSuffix": "",
727
+ "km": "dialogues2",
693
728
  "mentioned": [
694
729
  ],
695
730
  "variables": {
696
731
  }
697
732
  },
698
733
  "evaluate2": {
734
+ "km": "evaluate2"
699
735
  },
700
736
  "gdefaults2": {
737
+ "km": "gdefaults2"
701
738
  },
702
739
  "help1": {
740
+ "km": "help1"
703
741
  },
704
742
  "meta2": {
743
+ "km": "meta2"
705
744
  },
706
745
  "negation2": {
746
+ "km": "negation2"
707
747
  },
708
748
  "pos2": {
749
+ "km": "pos2"
709
750
  },
710
751
  "punctuation2": {
752
+ "km": "punctuation2"
711
753
  },
712
754
  "sdefaults2": {
755
+ "km": "sdefaults2"
713
756
  },
714
757
  "stm2": {
758
+ "km": "stm2",
715
759
  "mentioned": [
716
760
  ],
717
761
  "variables": {
718
762
  }
719
763
  },
720
764
  "tokenize2": {
765
+ "km": "tokenize2"
766
+ },
767
+ "words2": {
768
+ "km": "words2",
769
+ "words": [
770
+ ]
721
771
  }
722
772
  },
723
773
  "processed": [
724
774
  {
725
775
  "context": {
776
+ "context_id": 2,
726
777
  "context_index": 1,
727
778
  "dead": true,
728
779
  "default": true,
@@ -740,11 +791,14 @@
740
791
  "value": "help",
741
792
  "word": "help"
742
793
  },
743
- "generatedParenthesized": "( NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n)",
744
- "paraphrases": "help",
745
- "paraphrasesParenthesized": "(help)",
794
+ "generatedParenthesized": [
795
+ ],
796
+ "paraphrases": [
797
+ ],
798
+ "paraphrasesParenthesized": [
799
+ ],
746
800
  "responses": [
747
- " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
801
+ " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
748
802
  ]
749
803
  }
750
804
  ]
@@ -757,7 +811,7 @@
757
811
  ],
758
812
  "query": "help",
759
813
  "responses": [
760
- " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
814
+ " NAME: help\n DESCRIPTION: Help the user with the current knowledge modules\n\n SAMPLE SENTENCES\n\n help with help and dialogues\n help\n\n NAME: dialogues\n DESCRIPTION: framework for dialogues\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n be brief\n be brief greg\n is x y\n no\n what is it\n x is y?\n yes\n x is 3 what is x\n x is 3 what is x what is it\n be brief x is 3 what is x what is it\n to it\n why\n setidsuffix greg\n setidsuffix greg resetidsuffix\n setidsuffix greg makeObject banana\\nbanana\n setidsuffix _suffy\n\n NAME: asking\n DESCRIPTION: asking the user questions\n\n SAMPLE SENTENCES\n\n nevermindTestSetup accept nevermind hi\n nevermindTestSetup reject nevermind hi\n whichOnesTestSetup apple banana pear\\npear\n whichOnesTestSetup apple banana pear\\ngoat\n whichOnesTestSetup apple banana pear\\nnevermind\n whichOnesTestSetup apple banana pear\\napple and pear\n\n NAME: negation\n DESCRIPTION: negation\n\n SAMPLE SENTENCES\n\n not negatable\n not negatables\n\n NAME: stm\n DESCRIPTION: short term memory\n\n SAMPLE SENTENCES\n\n remember m1\n previous memorable\n m1\n remember m1\\nevaluate the memorable\n the memorable before\n remember m1\\nremember m2\\nevaluate the memorable before\n\n NAME: meta\n DESCRIPTION: Ways of defining new language elements\n\n SAMPLE SENTENCES\n\n a means b\n a means x\n if f then g gq\n undefined means defined\n\n NAME: conjunction\n DESCRIPTION: framework for conjunction\n\n SAMPLE SENTENCES\n\n 1 2 and 3\n\n NAME: evaluate\n DESCRIPTION: Explicit handling of evaluate\n\n SAMPLE SENTENCES\n\n evaluate value1\n\n NAME: articles\n DESCRIPTION: articles\n\n SAMPLE SENTENCES\n\n the theable\n a theable\n every distributable\n each distributable\n\n\n\n NAME: punctuation\n DESCRIPTION: punctuation\n\n SAMPLE SENTENCES\n\n (a)\n :\n \"hi man\"\n\n\n\n NAME: tokenize\n DESCRIPTION: tokenize\n\n SAMPLE SENTENCES\n\n hello_world\n"
761
815
  ],
762
816
  "summaries": [
763
817
  {
@@ -10,6 +10,24 @@ const { compose, translationMapping, translationMappingToInstantiatorMappings }
10
10
  class API {
11
11
  constructor() {
12
12
  this.digraph = new Digraph()
13
+ this.hierarchyWatchers = []
14
+ }
15
+
16
+ addHierarchyWatcher(watcher) {
17
+ this.hierarchyWatchers.push(watcher)
18
+ }
19
+
20
+ removeHierarchyWatcher(watcher) {
21
+ this.hierarchyWatchers = this.hierarchyWatchers.filter((w) => w.id == watcher.id)
22
+ }
23
+
24
+ seenHierarchyWatcher(watcherArgs) {
25
+ const args = { ...this.args, ...watcherArgs }
26
+ for (const { match, apply } of this.hierarchyWatchers) {
27
+ if (match(args)) {
28
+ apply(args)
29
+ }
30
+ }
13
31
  }
14
32
 
15
33
  initialize({ km, objects, config }) {
@@ -311,7 +329,6 @@ class API {
311
329
  pattern: `([(${beforeOperators} [${operator}|] ${afterOperators}^)])`,
312
330
  allowDups: true,
313
331
  })
314
- // config.addOperator({ id: operator, level: 1, words: [operator] })
315
332
  config.addBridge({
316
333
  id: operator,
317
334
  level: 1,
@@ -331,7 +348,6 @@ class API {
331
348
  if (create.includes(argument.id)) {
332
349
  // config.addHierarchy('unknown', argument.id)
333
350
  // config.addHierarchy('what', argument.id)
334
- // greg23 <<<<<<<<<<<< doing this
335
351
  config.addHierarchy(argument.id, 'unknown')
336
352
  config.addHierarchy(argument.id, 'what')
337
353
  }
@@ -413,14 +429,14 @@ class API {
413
429
  const conjugation = conjugateVerb(createDef.infinitive)
414
430
  if (can) {
415
431
  const def = conjugation.find((def) => def.form == "pastParticiple")
416
- config.addWord(def.word, { id: operator, initial: `{ value: '${operator}', tense: '${def.tense}' }`})
432
+ config.addWord(def.word, { id: operator, initial: `{ value: '${operator}', isVerb: true, tense: '${def.tense}' }`})
417
433
  }
418
434
  }
419
435
 
420
436
  const operatorPlural = pluralize.singular(operator)
421
437
  const operatorSingular = pluralize.plural(operator)
422
- config.addWord(operatorSingular, { id: operator, initial: `{ value: '${operator}', number: 'one' }`})
423
- config.addWord(operatorPlural, { id: operator, initial: `{ value: '${operator}', number: 'many' }`})
438
+ config.addWord(operatorSingular, { id: operator, initial: `{ value: '${operator}', isVerb: true, number: 'one' }`})
439
+ config.addWord(operatorPlural, { id: operator, initial: `{ value: '${operator}', isVerb: true, number: 'many' }`})
424
440
  }
425
441
 
426
442
  for (const { child, parent } of hierarchy) {
@@ -438,12 +454,12 @@ class API {
438
454
  const beforeIds = before.map((def) => def.id)
439
455
  const afterIds = after.map((def) => def.id)
440
456
  config.addHierarchy(operator, 'canableAction')
441
- config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestion', 0], [beforeIds[0], 0], ['make', 0]], choose: 1 })
442
- config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestion', 0], [beforeIds[0], 0], ['make', 0]], choose: 1 })
443
- config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], ['make', 0], ['byCanPassive', 0]], choose: 1 })
444
- config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], ['make', 0], ['byCanPassive', 0]], choose: 1 })
445
- config.addAssociation({ context: [[afterIds[0], 0], ['canPassive', 0], ['beCanPassive', 0], ['make', 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
446
- config.addAssociation({ context: [[afterIds[0], 1], ['canPassive', 0], ['beCanPassive', 0], ['make', 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
457
+ config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestion', 0], [beforeIds[0], 0], [operator, 0]], choose: 1 })
458
+ config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestion', 0], [beforeIds[0], 0], [operator, 0]], choose: 1 })
459
+ config.addAssociation({ context: [[afterIds[0], 0], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0]], choose: 1 })
460
+ config.addAssociation({ context: [[afterIds[0], 1], ['whatCanQuestionPassive', 0], [beforeIds[0], 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0]], choose: 1 })
461
+ config.addAssociation({ context: [[afterIds[0], 0], ['canPassive', 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
462
+ config.addAssociation({ context: [[afterIds[0], 1], ['canPassive', 0], ['beCanPassive', 0], [operator, 0], ['byCanPassive', 0], [beforeIds[0], 0]], choose: 1 })
447
463
  }
448
464
 
449
465
  if (false) {
@@ -473,10 +489,10 @@ class API {
473
489
  config.addGenerator({
474
490
  notes: 'ordering generator for response',
475
491
  match: ({context}) => context.marker == operator && context.evalue && context.isResponse,
476
- apply: async ({context, g, km, flatten}) => {
492
+ apply: async ({context, s, g, km, flatten}) => {
477
493
  const brief = km("dialogues").api.getBrief()
478
494
 
479
- const { evalue } = context
495
+ let { evalue } = context
480
496
  let yesno = ''
481
497
  let hasVariables = false
482
498
  if (context.focusable) {
@@ -510,6 +526,10 @@ class API {
510
526
  if (evalue.truthValueOnly) {
511
527
  return `${yesno}`
512
528
  } else {
529
+ if (context.voice) {
530
+ evalue = await s({ ...evalue, toVoice: context.voice, flatten: false})
531
+ }
532
+
513
533
  const details = await g(Object.assign({}, evalue, { paraphrase: true }))
514
534
  if (yesno) {
515
535
  return `${yesno} ${details}`
@@ -596,7 +616,7 @@ class API {
596
616
  if (relation) {
597
617
  config.addSemantic({
598
618
  notes: `setter for ${operator}`,
599
- match: ({context}) => context.marker == operator,
619
+ match: ({context}) => context.marker == operator && !context.toVoice,
600
620
  apply: ({context, km, hierarchy, config}) => {
601
621
  const api = km('properties').api
602
622
  // add types for arguments
@@ -256,6 +256,7 @@ const config = {
256
256
  oneConceptId = await api.makeObject({...args, context: oneConcept})
257
257
  twoConceptId = await api.makeObject({...args, context: twoConcept})
258
258
  api.rememberIsA(oneConceptId, twoConceptId)
259
+ api.seenHierarchyWatcher({ childId: oneConceptId, child: oneConcept, parentId: twoConceptId, parent: twoConcept })
259
260
  context.sameWasProcessed = true
260
261
  }
261
262
  }
@@ -70,7 +70,7 @@
70
70
  "person": "third"
71
71
  }
72
72
  ],
73
- "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
73
+ "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, { context: operator }] }",
74
74
  "selector": {
75
75
  "arguments": {
76
76
  "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
@@ -83,7 +83,7 @@
83
83
  {
84
84
  "id": "dare",
85
85
  "level": 0,
86
- "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
86
+ "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, { context: operator }] }",
87
87
  "selector": {
88
88
  "arguments": {
89
89
  "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
@@ -159,7 +159,7 @@
159
159
  },
160
160
  {
161
161
  "id": "queryMarker",
162
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
162
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], question: true }",
163
163
  "separators": "|",
164
164
  "before": [
165
165
  "hierarchy"
@@ -173,7 +173,7 @@
173
173
  "listable"
174
174
  ]
175
175
  ],
176
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
176
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], isList: true }",
177
177
  "separators": "|"
178
178
  },
179
179
  {
@@ -187,7 +187,7 @@
187
187
  "hierarchiable"
188
188
  ]
189
189
  ],
190
- "bridge": "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: all }",
190
+ "bridge": "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: map(all, { context: element }) }",
191
191
  "words": [
192
192
  {
193
193
  "word": "sum",
@@ -305,7 +305,7 @@
305
305
  "person": "third"
306
306
  }
307
307
  ],
308
- "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
308
+ "bridge": "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, { context: operator }] }",
309
309
  "selector": {
310
310
  "arguments": {
311
311
  "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
@@ -318,7 +318,7 @@
318
318
  {
319
319
  "id": "dare",
320
320
  "level": 0,
321
- "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
321
+ "bridge": "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, { context: operator }] }",
322
322
  "selector": {
323
323
  "arguments": {
324
324
  "nominative": "(context.declension == 'nominative' && context.number == operator.number)",
@@ -394,7 +394,7 @@
394
394
  },
395
395
  {
396
396
  "id": "queryMarker",
397
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
397
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], question: true }",
398
398
  "separators": "|",
399
399
  "before": [
400
400
  "hierarchy"
@@ -408,7 +408,7 @@
408
408
  "listable"
409
409
  ]
410
410
  ],
411
- "bridge": "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
411
+ "bridge": "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], isList: true }",
412
412
  "separators": "|"
413
413
  },
414
414
  {
@@ -422,7 +422,7 @@
422
422
  "hierarchiable"
423
423
  ]
424
424
  ],
425
- "bridge": "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: all }",
425
+ "bridge": "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: map(all, { context: element }) }",
426
426
  "words": [
427
427
  {
428
428
  "word": "sum",
package/common/latin.js CHANGED
@@ -56,7 +56,7 @@ const config = {
56
56
  words: [
57
57
  ...conjugateVerb('iacere'),
58
58
  ],
59
- bridge: "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, operator] }",
59
+ bridge: "{ ...next(operator), thrower: nominative?, receiver: dative?, object: object?, location: location?, interpolate: [{ property: 'thrower' }, { property: 'receiver' }, { property: 'location' }, { property: 'object' }, { context: operator }] }",
60
60
  selector: {
61
61
  arguments: {
62
62
  nominative: "(context.declension == 'nominative' && context.number == operator.number)",
@@ -69,7 +69,7 @@ const config = {
69
69
  {
70
70
  id: "dare",
71
71
  level: 0,
72
- bridge: "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, operator] }",
72
+ bridge: "{ ...next(operator), giver: nominative?, receiver: dative?, object: accusative?, interpolate: [{ property: 'giver' }, { property: 'receiver' }, { property: 'object' }, { context: operator }] }",
73
73
  selector: {
74
74
  arguments: {
75
75
  nominative: "(context.declension == 'nominative' && context.number == operator.number)",
@@ -105,21 +105,21 @@ const config = {
105
105
 
106
106
  {
107
107
  id: "queryMarker",
108
- bridge: "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], question: true }",
108
+ bridge: "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], question: true }",
109
109
  separators: '|',
110
110
  before: ['hierarchy'],
111
111
  },
112
112
  {
113
113
  id: "listMarker",
114
114
  localHierarchy: [['unknown', 'listable']],
115
- bridge: "{ ...before[0], verb: before[0], interpolate: [before[0], '', operator], isList: true }",
115
+ bridge: "{ ...before[0], verb: before[0], interpolate: [{ context: before[0] }, '', { context: operator }], isList: true }",
116
116
  separators: '|',
117
117
  },
118
118
  { id: "hierarchiable" },
119
119
  {
120
120
  id: "hierarchy",
121
121
  localHierarchy: [['unknown', 'hierarchiable']],
122
- bridge: "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: all }",
122
+ bridge: "{ ...next(operator), child: arguments[0], parent: arguments[1], question: less_than(indexes.operator, indexes.arguments[0]), interpolate: map(all, { context: element }) }",
123
123
  words: [
124
124
  { word: 'sum', number: 'singular', person: 'first' },
125
125
  { word: 'es', number: 'singular', person: 'second' },