项目作者: notquiterussell

项目描述 :
NLP.js based Microsoft Bot Framework middleware.
高级语言: JavaScript
项目地址: git://github.com/notquiterussell/botbuilder-nlpjs.git
创建时间: 2021-01-02T13:49:45Z
项目社区:https://github.com/notquiterussell/botbuilder-nlpjs

开源协议:Apache License 2.0

下载


NLP.js based middleware for Microsoft Bot framework

This is a middleware plugin for the Botkit part of the Microsoft Bot framework.

The plugin uses a local, private model via NLP.js to extract:

  • Input classifications
  • Intents for the given input
  • The sentiment of the input
  • Entities in the input (see the note below on entity analysis)
  • Answers to the input, to allow building Question and Answer bots

Each one can be added individually to the bot, but they can all share the same bot model to reduce memory
consumption.

Adding the middleware

To add the middleware first await the build of the NlpjsEngine, then instantiate the components you
wish to add. Finally, add the components to the required adapters.

Note that you will need a built model file to drive the NLP, see this example
for how to build the required file.

  1. const { NlpjsEngine, Answer, IntentAnalysis, EntityAnalysis, LanguageAnalysis } = require('botbuilder-nlpjs');
  2. // Other setup
  3. NlpjsEngine.build({ languages: ['en'], forceNER: true }, path.join(__dirname, 'features', 'private.json')).then(
  4. nlpEngine => {
  5. // Note that there is nothing special about using the Slack adapter
  6. const adapter = new SlackAdapter({/* Slack setup options */});
  7. adapter.use(new Answer(nlpEngine));
  8. adapter.use(new IntentAnalysis(nlpEngine));
  9. adapter.use(new EntityAnalysis(nlpEngine));
  10. adapter.use(new LanguageAnalysis(["en", "de"], 3))
  11. // Final setup and run
  12. }
  13. );

Note on EntityAnalysis

For the entity analysis to work correctly the NlpjsEngine must be built using the setting forceNER: true,
for example:

  1. NlpjsEngine.build(
  2. { languages: ['en'], forceNER: true },
  3. path.join(__dirname, 'features', 'private.json')
  4. ).then(nlpEngine => {
  5. // Do stuff with the engine
  6. });

Build status

Node CI Code Quality