Comparing version 1.1.1 to 1.2.0
@@ -12,4 +12,10 @@ { | ||
"program": "${workspaceFolder}\\toto.js" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Console bot", | ||
"program": "${workspaceFolder}\\examples\\console-bot\\index.js" | ||
} | ||
] | ||
} |
@@ -39,2 +39,3 @@ /* | ||
const { XTableUtils, XTable, XDoc } = require('./xtables'); | ||
const { ConversationContext, MemoryConversationContext, Recognizer } = require('./recognizer'); | ||
@@ -62,2 +63,5 @@ module.exports = { | ||
XDoc, | ||
ConversationContext, | ||
MemoryConversationContext, | ||
Recognizer, | ||
}; |
@@ -83,4 +83,6 @@ /* | ||
const truncated = NlpUtil.getTruncatedLocale(locale); | ||
if (!this.languages.includes(truncated)) { | ||
this.languages.push(truncated); | ||
} | ||
if (!this.classifiers[truncated]) { | ||
this.languages.push(truncated); | ||
this.classifiers[truncated] = new NlpClassifier({ language: truncated }); | ||
@@ -87,0 +89,0 @@ } |
{ | ||
"name": "node-nlp", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Library for NLU (Natural Language Understanding) done in Node.js", | ||
@@ -10,3 +10,3 @@ "main": "lib/index.js", | ||
"lintfix": "eslint --fix lib/**", | ||
"test": "eslint lib/** && jest --coverage" | ||
"test": "eslint lib/** && jest --coverage --maxWorkers=4" | ||
}, | ||
@@ -13,0 +13,0 @@ "author": { |
@@ -395,2 +395,9 @@ /* | ||
}); | ||
test('Should return undefined if the operator is not recognized', () => { | ||
const context = { a: 1, b: 2 }; | ||
const evaluator = new Evaluator(); | ||
const question = 'a >> b'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
@@ -580,2 +587,68 @@ | ||
describe('Walk call', () => { | ||
test('It should walk a function', () => { | ||
const context = { a: 12, b: 2, sum: (a, b) => a + b }; | ||
const evaluator = new Evaluator(); | ||
const question = 'sum(a, b)'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toEqual(14); | ||
}); | ||
test('If the function does not exists, should return undefined', () => { | ||
const context = { a: 12, b: 2, sum: (a, b) => a + b }; | ||
const evaluator = new Evaluator(); | ||
const question = 'zum(a, b)'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toBeUndefined(); | ||
}); | ||
test('If some argument of the function does not exists, should return undefined', () => { | ||
const context = { a: 12, b: 2, sum: (a, b) => a + b }; | ||
const evaluator = new Evaluator(); | ||
const question = 'sum(a, c)'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
describe('Walk member', () => { | ||
test('It should be able to walk a member', () => { | ||
const context = { a: 12, b: 2 }; | ||
const evaluator = new Evaluator(); | ||
const question = 'c = [a, b]; d = c[0] + c[1];'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toEqual(14); | ||
}); | ||
test('It should return undefined when then member expression does not exists', () => { | ||
const context = { a: 12, b: x => x + 1 }; | ||
const evaluator = new Evaluator(); | ||
const question = 'c = [a, b]; d = e[0] + e[1];'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toBeUndefined(); | ||
}); | ||
test('It should return undefined when then member cannot be resolved', () => { | ||
const context = { a: 12, b: 2 }; | ||
const evaluator = new Evaluator(); | ||
const question = 'c = [a, b, d]; e = c[0] + c[1] + c[2];'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
describe('Walk set member', () => { | ||
test('It should set a member', () => { | ||
const context = { a: 12, b: 2, c: [1, 2] }; | ||
const evaluator = new Evaluator(); | ||
const question = 'c[0] = 3'; | ||
const result = evaluator.evaluate(question, context); | ||
expect(result).toEqual(3); | ||
expect(context.c).toEqual([3, 2]); | ||
}); | ||
test('It should not set a member of a non existing variable', () => { | ||
const context = { a: 12, b: 2 }; | ||
const evaluator = new Evaluator(); | ||
const question = 'c[0] = 3'; | ||
evaluator.evaluate(question, context); | ||
expect(context.c).toBeUndefined(); | ||
}); | ||
}); | ||
describe('Evaluator', () => { | ||
@@ -582,0 +655,0 @@ test('If no term is provided, return undefined', () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11399699
160
337046