Skip to main content
https://travis-ci.org/snipsco/snips-nlu.svg?branch=develop https://ci.appveyor.com/api/projects/status/github/snipsco/snips-nlu?branch=develop&svg=true https://img.shields.io/pypi/v/snips-nlu.svg?branch=develop https://img.shields.io/pypi/pyversions/snips-nlu.svg?branch=develop https://codecov.io/gh/snipsco/snips-nlu/branch/develop/graph/badge.svg https://img.shields.io/twitter/url/http/shields.io.svg?style=social

Snips NLU (Natural Language Understanding) is a Python library that allows to parse sentences written in natural language and extracts structured information.

Check out our blog post to get more details about why we built Snips NLU and how it works under the hood.

System requirements

  • 64-bit Linux, MacOS >= 10.11, 64-bit Windows

  • Python 2.7 or Python >= 3.4

  • RAM: Snips NLU will typically use between 100MB and 200MB of RAM, depending on the language and the size of the dataset.

Installation

pip install snips-nlu

We currently have pre-built binaries (wheels) for snips-nlu and its dependencies for MacOS (10.11 and later), Linux x86_64 and Windows.

For any other architecture/os snips-nlu can be installed from the source distribution. To do so, Rust and setuptools_rust must be installed before running the pip install snips-nlu command.

Language resources

Snips NLU relies on language resources that must be downloaded before the library can be used. You can fetch resources for a specific language by running the following command:

python -m snips_nlu download en

Or simply:

snips-nlu download en

Once the resources have been fetched, they can be loaded in Python using:

from snips_nlu import load_resources

load_resources("en")

The list of supported languages is available here.

A simple example

Let’s take an example to illustrate the main purpose of this lib, and consider the following sentence:

"What will be the weather in paris at 9pm?"

Properly trained, the Snips NLU engine will be able to extract structured data such as:

{
   "intent": {
      "intentName": "searchWeatherForecast",
      "probability": 0.95
   },
   "slots": [
      {
         "value": "paris",
         "entity": "locality",
         "slotName": "forecast_locality"
      },
      {
         "value": {
            "kind": "InstantTime",
            "value": "2018-02-08 20:00:00 +00:00"
         },
         "entity": "snips/datetime",
         "slotName": "forecast_start_datetime"
      }
   ]
}

Sample code

Here is a sample code that you can run on your machine after having installed snips-nlu, fetched the english resources and downloaded this sample dataset:

from __future__ import unicode_literals, print_function

import io
import json

from snips_nlu import SnipsNLUEngine, load_resources
from snips_nlu.default_configs import CONFIG_EN

with io.open("sample_dataset.json") as f:
    sample_dataset = json.load(f)

load_resources("en")
nlu_engine = SnipsNLUEngine(config=CONFIG_EN)
nlu_engine.fit(sample_dataset)

text = "What will be the weather in San Francisco next week?"
parsing = nlu_engine.parse(text)
print(json.dumps(parsing, indent=2))

What it does is training an NLU engine on a sample weather dataset and parsing a weather query.

Documentation

To find out how to use Snips NLU please refer to our documentation, it will provide you with a step-by-step guide on how to use and setup our library.

FAQ

Please join our Discord channel to ask your questions and get feedback from the community.

How do I contribute ?

Please see the Contribution Guidelines.

Licence

This library is provided by Snips as Open Source software. See LICENSE for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snips_nlu-0.16.5.tar.gz (62.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snips_nlu-0.16.5-py2.py3-none-any.whl (87.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file snips_nlu-0.16.5.tar.gz.

File metadata

  • Download URL: snips_nlu-0.16.5.tar.gz
  • Upload date:
  • Size: 62.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/38.5.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.4

File hashes

Hashes for snips_nlu-0.16.5.tar.gz
Algorithm Hash digest
SHA256 50eabdfcdd0a74aeb9b5161568edfc3a048390bd8d422dc18706f83cee2d7e35
MD5 2660e65c9c5386fa5119288843150688
BLAKE2b-256 6c0838c5e7a835331f93add32240e49c2a15eb728eaaa5df58286c8e96968dba

See more details on using hashes here.

File details

Details for the file snips_nlu-0.16.5-py2.py3-none-any.whl.

File metadata

  • Download URL: snips_nlu-0.16.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 87.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/38.5.2 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.4

File hashes

Hashes for snips_nlu-0.16.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fa50685e108516a7b65d121574fd0f0c1a2d1f0b0958ac3c5bc523f9fceaa55d
MD5 f6aa6f7f54033fe9be0b129e5d70f83f
BLAKE2b-256 dc921138623270ae40b6b8ca004a5d5e321a2018d58bcea5c00e6692e27eb481

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page