npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@botonic/plugin-nlu

v0.19.0

Published

## What Does This Plugin Do?

Downloads

78

Readme

Botonic Plugin NLU

What Does This Plugin Do?

Botonic Plugin NLU allows you to predict intents from the user inputs for your bot.

To set up a new example using Botonic Plugin NLU, you can create a bot by running the following command:

$ botonic new {BOT_NAME} nlu

Alternatively, if you already have a project, you can follow the steps below to setup it up.

Setup

Install the plugin

  1. From your project, enter the command npm install @botonic/plugin-nlu. This command installs everything necessary to start working with your intents and entities. Note: Windows users should first use the command npm install --global --production windows-build-tools --vs2015 followed by npm install @botonic/plugin-nlu
  2. Under the src files of your project, create a folder called nlu.

Require the Plugin

You must require the plugin in src/plugins.js to be able to predict the intent of user inputs. You must set its id to nlu for the plugin to work.

In case that you have trained your model with default preprocessing engines, you only need to specify the languages that you want to support.

src/plugins.js

E.g.:

export const plugins = [
  {
    id: 'nlu',
    resolve: require('@botonic/plugin-nlu'),
    options: {
      en: {},
      es: {},
    },
  },
]

Otherwise, you must load also the preprocessing engines for every language used to train your models.

E.g.:

import { ENTokenizer, ESTokenizer } from './nlu/preprocessing-tools/tokenizer'

export const plugins = [
  {
    id: 'nlu',
    resolve: require('@botonic/plugin-nlu'),
    options: {
      en: {
        tokenizer: ENTokenizer,
      },
      es: {
        tokenizer: ESTokenizer,
      },
    },
  },
]

Use

Define Intents

  1. Under the nlu folder, create a folder called utterances, which will contain your multilingual intents.
  2. For every language you want to support, create a folder under /src/nlu/utterances with its language code (it must be ISO 639-1). Ex: Training for English (en), will result in the following path: /src/nlu/utterances/en/.
  3. Add a text file for each intent you want to create by naming them IntentName.txt.
  4. Fill them with possible ways to express each intent. Every sentence must be on a different line of the file. See Natural Language Understanding section for more information.

Train the Bot

Now it's time to order Botonic NLU to train each intent with the provided sentences:

botonic train

Alternatively you can also run npm run train.

After this, the bot will be able to run predictions on new inputs.
Every time you make changes in your utterances, you will need to run again the command above so that the changes take effect.

Define Routes with Intents

Once you've defined your intents, you can use them in the routes in the same way you use text, payloads, and the like. Below, we see how we might use them: routes.js

import Start from './actions/start'
import ShowRestaurants from './actions/show-restaurants'
import NotFound from './actions/not-found'
import ShowDirections from './actions/show-directions'
export const routes = [
  { input: i => i.confidence < 0.7, action: NotFound },
  { intent: 'Greetings', action: Start },
  { intent: 'BookRestaurant', action: ShowRestaurants },
]

Go Live

  1. Run botonic serve to see how the bot runs in the development environment.
  2. For further details of the variables stored during the execution, open the Botonic Dev Console by clicking on the tab in the top-left corner.
  3. Deploy your bot with botonic deploy. You got a bot with a customized intent and entity recognition system!

Multilingual Support

The pre-trained word embeddings below are supported, which means that you can train your bot in these specific languages. For more information about other supported languages, feel free to contact us on Slack.

You can also generate your own word embeddings following these instructions.

| Language | Language Code | Type* | Dimensions | Source | | :--------: | :-----------: | :----------: | :--------: | :----------------------------------------------------------------------------------------------------------------: | | English | en | glove | 50 | glove-50d-en | | English | en | 10k-fasttext | 300 | 10k-fasttext-300d-en | | Spanish | es | 10k-fasttext | 300 | 10k-fasttext-300d-es | | Catalan | ca | 10k-fasttext | 300 | 10k-fasttext-300d-ca | | French | fr | 10k-fasttext | 300 | 10k-fasttext-300d-fr | | Portuguese | pt | 10k-fasttext | 300 | 10k-fasttext-300d-pt | | German | de | 10k-fasttext | 300 | 10k-fasttext-300d-de | | Italian | it | 10k-fasttext | 300 | 10k-fasttext-300d-it | | Hindi | hi | 10k-fasttext | 300 | 10k-fasttext-300d-hi | | Indonesian | id | 10k-fasttext | 300 | 10k-fasttext-300d-id | | Russian | ru | 10k-fasttext | 300 | 10k-fasttext-300d-ru | | Turkish | tr | 10k-fasttext | 300 | 10k-fasttext-300d-tr |

*10k-fasttext word embeddings contain the 10k most commons words of the language.

Note: All the word embeddings are stored by default in ~/.botonic/word-embeddings/. If you encounter any issues when automatically downloading word embeddings, you can download them manually and store them in the mentioned directory.