theprogrammablemind 7.2.3 → 7.3.1

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.
Files changed (4) hide show
  1. package/client.js +9 -4
  2. package/demo.js +1 -1
  3. package/package.json +39 -39
  4. package/readme +46 -32
package/client.js CHANGED
@@ -1325,8 +1325,11 @@ const knowledgeModule = async ({
1325
1325
  } else if (args.test || args.testVerbose || args.testAllVerbose) {
1326
1326
  // TODO make test always a string
1327
1327
  if (typeof test === 'string') {
1328
- const l = (n) => {
1328
+ const l = (n, hasError) => {
1329
1329
  if (n === 0) {
1330
+ if (hasError) {
1331
+ process.exit(-1)
1332
+ }
1330
1333
  return
1331
1334
  }
1332
1335
  runTests(config, test, { debug: args.debug, testConfig: testConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose, beforeQuery, beforeTests, afterTests, beforeTest, afterTest }).then((results) => {
@@ -1335,6 +1338,7 @@ const knowledgeModule = async ({
1335
1338
  vimdiff(result.expected, result.actual)
1336
1339
  }
1337
1340
  }
1341
+ let newError = false
1338
1342
  if (results.length > 0) {
1339
1343
  let headerShown = false
1340
1344
  console.log('**************************** ERRORS ************************')
@@ -1346,7 +1350,7 @@ const knowledgeModule = async ({
1346
1350
  }
1347
1351
  console.log(' expected paraphrases', result.expected.paraphrases)
1348
1352
  console.log(' actual paraphrases ', result.actual.paraphrases)
1349
-
1353
+ newError = true
1350
1354
  headerShown = true
1351
1355
  }
1352
1356
  if (JSON.stringify(result.expected.responses) !== JSON.stringify(result.actual.responses)) {
@@ -1355,6 +1359,7 @@ const knowledgeModule = async ({
1355
1359
  }
1356
1360
  console.log(' expected responses ', result.expected.responses)
1357
1361
  console.log(' actual responses ', result.actual.responses)
1362
+ newError = true
1358
1363
  headerShown = true
1359
1364
  }
1360
1365
  }
@@ -1366,12 +1371,12 @@ const knowledgeModule = async ({
1366
1371
  console.log('**************************** ERRORS ************************')
1367
1372
  }
1368
1373
  // const contexts = { failures: results }
1369
- l(n - 1)
1374
+ l(n - 1, hasError || newError)
1370
1375
  }).catch((error) => {
1371
1376
  errorHandler(error)
1372
1377
  })
1373
1378
  }
1374
- l(args.count)
1379
+ l(args.count, false)
1375
1380
  } else {
1376
1381
  test()
1377
1382
  }
package/demo.js CHANGED
@@ -1,4 +1,4 @@
1
- const { Config, knowledgeModule, where } = require('entodicton')
1
+ const { Config, knowledgeModule, where } = require('theprogrammablemind')
2
2
 
3
3
  /*
4
4
  This demo does not use the knowledge modules and just shows the
package/package.json CHANGED
@@ -1,42 +1,4 @@
1
1
  {
2
- "license": "ISC",
3
- "scripts": {
4
- "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
5
- "to": "node node_modules/.bin/jest --runInBand -t NEO",
6
- "lint": "eslint \"**/*.js\"",
7
- "test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
8
- "test:watch": "npm run test -- --watch",
9
- "test": "jest --config ./jest.config.json",
10
- "lint:fix": "eslint \"**/*.js\" --fix",
11
- "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO"
12
- },
13
- "main": "index.js",
14
- "devDependencies": {
15
- "eslint-plugin-node": "^11.1.0",
16
- "eslint": "^7.31.0",
17
- "jest": "^26.6.3",
18
- "eslint-config-standard": "^16.0.3",
19
- "eslint-plugin-import": "^2.23.4",
20
- "@typescript-eslint/parser": "^4.28.4",
21
- "@typescript-eslint/eslint-plugin": "^4.28.4",
22
- "eslint-plugin-promise": "^5.1.0"
23
- },
24
- "dependencies": {
25
- "underscore": "^1.13.1",
26
- "deep-equal": "^2.0.4",
27
- "node-fetch": "^2.6.1",
28
- "lodash": "^4.17.20",
29
- "uuid": "^8.3.2",
30
- "scriptjs": "^2.5.9",
31
- "base-64": "^1.0.0",
32
- "sort-json": "^2.0.0",
33
- "json-diff": "^1.0.3",
34
- "json-stable-stringify": "^1.0.1",
35
- "fs": "0.0.1-security",
36
- "readline": "^1.3.0"
37
- },
38
- "author": "dev@thinktelligence.com",
39
- "name": "theprogrammablemind",
40
2
  "keywords": [
41
3
  "NLP",
42
4
  "NLU",
@@ -46,6 +8,21 @@
46
8
  "natural language understanding",
47
9
  "chatbot"
48
10
  ],
11
+ "author": "dev@thinktelligence.com",
12
+ "dependencies": {
13
+ "sort-json": "^2.0.0",
14
+ "scriptjs": "^2.5.9",
15
+ "deep-equal": "^2.0.4",
16
+ "readline": "^1.3.0",
17
+ "json-diff": "^1.0.3",
18
+ "uuid": "^8.3.2",
19
+ "node-fetch": "^2.6.1",
20
+ "json-stable-stringify": "^1.0.1",
21
+ "fs": "0.0.1-security",
22
+ "base-64": "^1.0.0",
23
+ "lodash": "^4.17.20",
24
+ "underscore": "^1.13.1"
25
+ },
49
26
  "files": [
50
27
  "client.js",
51
28
  "index.js",
@@ -61,5 +38,28 @@
61
38
  "src/generators.js",
62
39
  "src/semantics.js"
63
40
  ],
64
- "version": "7.2.3"
41
+ "name": "theprogrammablemind",
42
+ "scripts": {
43
+ "test:watch": "npm run test -- --watch",
44
+ "tod": "node inspect node_modules/.bin/jest --runInBand -t NEO",
45
+ "to": "node node_modules/.bin/jest --runInBand -t NEO",
46
+ "lint:fix": "eslint \"**/*.js\" --fix",
47
+ "test": "jest --config ./jest.config.json",
48
+ "test:debug": "node inspect node_modules/.bin/jest --runInBand --config ./jest.config.json",
49
+ "lint": "eslint \"**/*.js\"",
50
+ "to:debug": "node inspect node_modules/.bin/jest --runInBand -t NEO"
51
+ },
52
+ "devDependencies": {
53
+ "eslint-config-standard": "^16.0.3",
54
+ "@typescript-eslint/eslint-plugin": "^4.28.4",
55
+ "eslint-plugin-promise": "^5.1.0",
56
+ "@typescript-eslint/parser": "^4.28.4",
57
+ "jest": "^26.6.3",
58
+ "eslint": "^7.31.0",
59
+ "eslint-plugin-node": "^11.1.0",
60
+ "eslint-plugin-import": "^2.23.4"
61
+ },
62
+ "license": "ISC",
63
+ "main": "index.js",
64
+ "version": "7.3.1"
65
65
  }
package/readme CHANGED
@@ -1,62 +1,73 @@
1
1
  # The Programmable Mind (aka Entodicton)
2
2
 
3
3
  This is the client for a server that processes natural language statements
4
- into JSON. Instead of using grammar based parser, the server uses a
5
- generalized operator precedence parser and neural nets.
4
+ into JSON which can be paraphrase or acted upon. Instead of using grammar based parser,
5
+ the server uses a generalized operator precedence parser.
6
6
 
7
7
  ## Demo Walkthough
8
8
 
9
- If you run node_modules/entodiction/test.js that will run a sample
10
- program against the API.
11
-
12
- This is the input
9
+ A simple demo program can be run by installing this package and the running this command.
13
10
 
14
11
  ```
15
- operators = ['(i [([went] ([to] (<the> store)))])']
12
+ dev@devlaptop:~/temp/myProject$ node node_modules/theprogrammablemind/demo -q 'i went to the store' -d
13
+ ```
16
14
 
17
- bridges = [
18
- { "id": "the", "level": 0, "bridge": "{ ...after, determiner: 'the' }" },
19
- { "id": "to", "level": 0, "bridge": "{ ...next(operator), after: after[0] }" },
20
- { "id": "went", "level": 0, "bridge": "{ ...squish(after[0]), ...next(operator) }" },
21
- { "id": "went", "level": 1, "bridge": "{ ...next(operator), who: before[0] }" },
22
- { "id": "went", "level": 2, "bridge": "{ action: 'go', marker: 'go', actor: operator.who, place: operator.to }" },
23
- ]
15
+ This is the input
24
16
 
25
- utterances = ["joe went to the store"]
17
+ ```
18
+ operators: [
19
+ '((i) [went] ([to] (<the> store)))',
20
+ ],
21
+ bridges: [
22
+ {
23
+ id: "the",
24
+ level: 0,
25
+ bridge: "{ ...after, determiner: 'the' }"
26
+ },
27
+ {
28
+ id: "to",
29
+ level: 0,
30
+ bridge: "{ ...next(operator), after: after[0] }"
31
+ },
32
+ {
33
+ id: "went",
34
+ level: 0,
35
+ generatorp: ({context, gp}) => `${gp(context.actor)} went to ${gp(context.place)}`,
36
+ bridge: "{ action: 'go', marker: 'went', actor: before[0], place: after[0].after }"
37
+ },
38
+ ],
26
39
  ```
27
40
 
28
41
  ## Operators
29
42
 
30
- Operators is used to do two things: specify the priority of operators and the argument structure. The priority
31
- is used to train a neural net. The idea here is to give sample sentences that are marked up so a graph
32
- of priorities can be made and fed to a neural net. The '[]' or '<>' is used to mark operators. In a generalized
43
+ Operators is used to do two things: specify the priority of operators and the argument structure.
44
+ The idea here is to give sample sentences that are marked up so a graph
45
+ of priorities can be made. The '[]' or '<>' is used to mark operators. In a generalized
33
46
  operator precedence parser, the result of a apply an operator can be another operator. The '[]' means
34
- there is a next operator the '<>' means there is not. The operators that this example defines are
47
+ there is a next level of the operator. The '<>' means there is not. The operators that this example defines are
35
48
 
36
49
  ```
37
50
  Operator/Level Arity
38
51
  the/0 prefix operator
39
52
  to/0 prefix operator
40
- went/0 prefix operator
41
- went/1 postfix operator
53
+ went/0 infix operator
42
54
  ```
43
55
 
44
56
  The priorities defined in order of application are
45
57
 
46
58
  ```
47
- the/1 > to/1 > went/1 > went/2
59
+ the/0 > to/0 > went/0
48
60
  ```
49
61
 
50
62
 
51
- 'Went' could be defined as infix but in the future once I implement conjunction this definition will allow
52
- sentences such as "I went to the store bought a coffee and chips and jumped on the bus and I got there".
63
+ 'went' is defined as infix for the example but defined as a prefix operator that evaluates to postfix operator
64
+ would allow sentences such as "I went to the store bought a coffee and chips and jumped on the bus".
53
65
 
54
66
  ## Bridges
55
67
 
56
- This works by combining contexts. Each context has a marker which indicates that is the operator. The
57
- bridge langauge is used to specify how to combine contexts to get the next context. This abstraction
58
- support multiple languages mapping ultimately to the same JSON. Its a generaliztion of what I did
59
- before in the v4 design seen in the youtube video. The syntax is
68
+ This works by combining contexts. Each context has a marker which indicates what is the operator. The
69
+ bridge is used to specify how to combine contexts to get the next context. This abstraction
70
+ support multiple languages mapping ultimately to the same JSON. The basic components are
60
71
 
61
72
  ```
62
73
  {
@@ -101,10 +112,6 @@ the result is
101
112
  }
102
113
  ```
103
114
 
104
- ## Utterances
105
-
106
- This is a list of statement that will be processed using the given definitions
107
-
108
115
  ## Priorities
109
116
 
110
117
  If request fail to process correctly one of the main causes is operator ordering. The 'operators' definition is used to generate training data for the ordering neural net. Sometimes that is not enough. There is a 'priorities' property that can be used to supply additional training data. Priorties is a list of operators. The last operator it the preferred one. The logs show the order that operators were run in. If it wrong look for another message like
@@ -130,3 +137,10 @@ A generator is used to describe how to map json back to strings. This is an exam
130
137
  The first part is a condition that is used to select the context. This example would match a context where the value 'marker' equals 'tankConcept' and the property 'number' is an number greater than zero. The second part can access properties in the context and generate a string. The access the properties 'number' and 'word' to generate a string.
131
138
 
132
139
  List the default generators first. For example if you want English to be the default list the generator for English for and for other language with a language selector later.
140
+
141
+ # More
142
+
143
+ Videos with more details can be found at <a href=http://thinktelligence.com/kms>thinktelligence videos</a>
144
+
145
+ This is a list of statement that will be processed using the given definitions
146
+