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

@jovotech/model-snips

v4.0.3

Published

Jovo Model for Snips NLU

Downloads

8

Readme

Jovo Model: Snips NLU

Learn how to turn the Jovo Model into a Snips NLU model.

Introduction

Snips NLU is an open source natural language understanding (NLU) service.

Learn more about the language model structure in the official Rasa NLU docs. The Jovo Model can be translated into this structure by using the npm package (see below).

Using the Snips Jovo Model npm Package

Install the package like this:

$ npm install @jovotech/model-snips

You can learn more about all the Jovo Model features here: Using the Jovo Model npm Packages.

Here is a code sample of how to convert from a Jovo model to a Snips dataset:

import { JovoModelData } from '@jovotech/model';
import { JovoModelSnips } from '@jovotech/model-snips';
import jovoModel from './models/en.json';

const snipsDataset = JovoModelSnips.fromJovoModel(jovoModel as JovoModelData, 'en');
console.log(JSON.stringify(snipsDataset, null, 2));

Customizing the Jovo Model

For Snips, the Jovo Model supports the following Intent entries:

Look in the examples folder to see how to structure a Jovo model and the corresponding Snips dataset that will be generated.

Intent only

An intent-only entry includes an array of phrases:

// Jovo model
{
  "invocation": "my test app",
  "version": "4.0",
  "intents": {
    "YesIntent": {
      "phrases": [
        "yes",
        "yes please",
        "sure"
      ]
    }
  }
}

Builtin entities

An intent can include an array of phrases with {variables} that map to a key in the entities object.

For a builtin entity, the type starts with "snips/" followed by the entity type:

// Jovo model
{
  "invocation": "my test app",
  "version": "4.0",
  "intents": {
    "NumberIntent": {
      "phrases": [
        "my number is {myNumber}"
      ],
      "entities": {
        "myNumber": {
          "type": "snips/number"
        }
      }
    }
  }
}

For a list of builtin Snips types, see Supported builtin entities and refer to the Identifier column.

Custom entities

An intent can include an array of phrases with {variables} that map to a key in the entities object.

For a custom entity, the type will be a custom name that you define and a corresponding entry must be added to the entityTypes section. Custom entity types can include synonyms:

// Jovo model
{
  "invocation": "my test app",
  "version": "4.0",
  "intents": {
    "ColorIntent": {
      "phrases": [
        "i pick {color}",
        "my favorite color is {color}"
      ],
      "entities": {
        "color": {
          "type": "CUSTOM_COLORS"
        }
      }
    }
  },
  "entityTypes": {
    "CUSTOM_COLORS": {
      "name": "CUSTOM_COLORS",
      "values": [
        {
          "value": "red",
          "synonyms": [
            "crimson"
          ]
        },
        {
          "value": "yellow",
          "synonyms": []
        },
        {
          "value": "blue",
          "synonyms": []
        },
        {
          "value": "green",
          "synonyms": []
        },
        {
          "value": "orange",
          "synonyms": []
        },
        {
          "value": "purple",
          "synonyms": []
        }
      ]
    }
  }
}

NOTICE: There is a current limitation with the mapping of a Jovo model to a Snips dataset such that the values for use_synonyms and automatically_extensible are always true and matching_strictness is always 1. With automatically_extensible set to true it means that the data list values provided are not all the values that will be recognized for the entity type.

// Snips dataset (partial)
{
    "CUSTOM_COLORS": {
        "data": [
        {
            "value": "red",
            "synonyms": [
            "crimson"
            ]
        },
        {
            "value": "yellow",
            "synonyms": []
        },
        {
            "value": "blue",
            "synonyms": []
        },
        {
            "value": "green",
            "synonyms": []
        },
        {
            "value": "orange",
            "synonyms": []
        },
        {
            "value": "purple",
            "synonyms": []
        }
        ],
        "matching_strictness": 1,
        "use_synonyms": true,
        "automatically_extensible": true
    },
}

Combined builtin and custom entities

You can also combine builtin and custom entities for the same intent:

// Jovo model
{
  "invocation": "my test app",
  "version": "4.0",
  "intents": {
    "WeatherIntent": {
      "phrases": [
        "give me the weather forecast for {weatherLocation} {weatherDate}"
      ],
      "entities": {
        "weatherLocation": {
          "type": "CUSTOM_WEATHER_LOCATION"
        },
        "weatherDate": {
          "type": "snips/datetime"
        }
      }
    }
  },
  "entityTypes": {
    "CUSTOM_WEATHER_LOCATION": {
      "name": "CUSTOM_WEATHER_LOCATION",
      "values": [
        {
          "value": "phoenix",
          "synonyms": []
        },
        {
          "value": "los angeles",
          "synonyms": []
        },
        {
          "value": "new york city",
          "synonyms": []
        }
      ]
    }
  }
}