Snips NLU C# wrapper library to extract meaning from text
[From https://github.com/snipsco/snips-nlu/blob/develop/README.rst]
Behind every chatbot and voice assistant lies a common piece of technology: Natural Language Understanding (NLU). Anytime a user interacts with an AI using natural language, their words need to be translated into a machine-readable description of what they meant.
The NLU engine first detects what the intention of the user is (a.k.a. intent), then extracts the parameters (called slots) of the query. The developer can then use this to determine the appropriate action or response.
0.64.3
The pre-built DLL files are available in there respective directories.
- https://www.reddit.com/r/rust/comments/78vpxg/help_cross_compiling_for_32_bit_on_windows/
- https://www.reddit.com/r/rust/comments/a5guk3/cant_use_i686pcwindowsmsvc/
- https://gist.github.com/InNoHurryToCode/955d63db0d79699fed63fe18eeebf17e
- https://github.com/japaric/rust-cross#the-target-triple
To build the dll, in Cargo.toml
set crate-type
to ["cdylib"]
. In \.rustup\settings.toml
, it might be necessary to change default_host_triple
to i686-pc-windows-msvc
or to x86_64-pc-windows-msvc
.
To check if the necessary toolchains are installed, run rustup toolchain list
.
-
x86 build
If necessary, run the following to install the toolchain:rustup install stable-i686-pc-windows-msvc
Then run:
cargo build --release --target=i686-pc-windows-msvc
-
x64 build
If necessary, run the following to install the toolchain:
rustup install stable-x86_64-pc-windows-msvc
Then run:
cargo build --release --target=x86_64-pc-windows-msvc
Load a Model from a folder:
using (var snipsNLUEngine = SnipsNLUEngine.CreateFromDirectory(@"Data\Tests\Models\nlu_engine"))
{
IntentClassifierResult[] intents = snipsNLUEngine.GetIntents("Can you make 3 cups of coffee?");
Slot[] slots = snipsNLUEngine.GetSlots("Can you make 3 cups of coffee?", intents[0].IntentName);
// or
IntentParserResult parsed = snipsNLUEngine.Parse("Can you make 3 cups of coffee?");
Console.WriteLine(parsed);
}
or
using (var snipsNLUEngine = new SnipsNLUEngine(@"Data\Tests\Models\nlu_engine"))
{
IntentClassifierResult[] intents = snipsNLUEngine.GetIntents("Can you make 3 cups of coffee?");
Slot[] slots = snipsNLUEngine.GetSlots("Can you make 3 cups of coffee?", intents[0].IntentName);
// or
IntentParserResult parsed = snipsNLUEngine.Parse("Can you make 3 cups of coffee?");
Console.WriteLine(parsed);
}
Load a Model from a Zip file:
using (var snipsNLUEngine = SnipsNLUEngine.CreateFromZip(@"Data\Tests\Models\nlu_engine.zip"))
{
IntentParserResult parsed = snipsNLUEngine.Parse("Can you make 3 cups of coffee?");
Console.WriteLine(parsed);
}
Output will be:
Can you make 3 cups of coffee?
MakeCoffee (61.43%)
'3 (Number)', '3', snips/number, number_of_cups @ [13;14]
- Load model from zip file
- Implement
CStringArray
class - Implement
intentsWhitelist
andintentsBlacklist
inSnipsNLUEngine.Parse()