From 4d929dc4faaad0ef918b9c4fb56653eb8861353f Mon Sep 17 00:00:00 2001 From: Louistiti Date: Sat, 4 May 2019 11:20:35 +0800 Subject: [PATCH] refactor(server): actions to fallbacks --- core/langs.json | 3 ++- server/src/core/nlu.js | 1 + test/unit/server/core/nlu.spec.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/langs.json b/core/langs.json index bfb074ac..28102155 100644 --- a/core/langs.json +++ b/core/langs.json @@ -13,7 +13,8 @@ { "words": ["merci"], "package": "leon", - "module": "welcome" + "module": "welcome", + "action": "run" } ] } diff --git a/server/src/core/nlu.js b/server/src/core/nlu.js index 8fa21c0c..caa3fab9 100644 --- a/server/src/core/nlu.js +++ b/server/src/core/nlu.js @@ -148,6 +148,7 @@ class Nlu { if (JSON.stringify(tmpWords) === JSON.stringify(fallbacks[i].words)) { obj.classification.package = fallbacks[i].package obj.classification.module = fallbacks[i].module + obj.classification.action = fallbacks[i].action obj.classification.confidence = 1 log.success('Fallback found') diff --git a/test/unit/server/core/nlu.spec.js b/test/unit/server/core/nlu.spec.js index 33f7a502..0bd5ff83 100644 --- a/test/unit/server/core/nlu.spec.js +++ b/test/unit/server/core/nlu.spec.js @@ -94,8 +94,8 @@ describe('NLU', () => { } expect(Nlu.fallback(obj, [ - { words: ['query', 'example', 'test', 'fallbacks'], package: 'fake-pkg', module: 'fake-module' } - ]).classification).toContainEntries([['package', 'fake-pkg'], ['module', 'fake-module'], ['confidence', 1]]) + { words: ['query', 'example', 'test', 'fallbacks'], package: 'fake-pkg', module: 'fake-module', action: 'fake-action' } + ]).classification).toContainEntries([['package', 'fake-pkg'], ['module', 'fake-module'], ['action', 'fake-action'], ['confidence', 1]]) }) }) })