public void Dispose() { if (NativeMethods.snips_nlu_engine_destroy_client(_client) != SNIPS_RESULT.SNIPS_RESULT_OK) { throw NluEngineError.GetLast(); } _client = IntPtr.Zero; }
public static string GetModelVersion() { IntPtr versionPtr = IntPtr.Zero; if (NativeMethods.snips_nlu_engine_get_model_version(ref versionPtr) != SNIPS_RESULT.SNIPS_RESULT_OK) { throw NluEngineError.GetLast(); } return(Marshal.PtrToStringAnsi(versionPtr)); }
/// <summary> /// Extracts the list of intents ranked by their confidence score. /// </summary> /// <param name="str"></param> public IntentClassifierResult[] GetIntents(string str) { string json = ""; if (NativeMethods.snips_nlu_engine_run_get_intents_into_json(_client, EncodeUTF8(str), ref json) != SNIPS_RESULT.SNIPS_RESULT_OK) { throw NluEngineError.GetLast(); } return(JsonConvert.DeserializeObject <IntentClassifierResult[]>(json)); }
/// <summary> /// Loads an NluEngine from a directory /// </summary> /// <param name="rootDir"></param> public SnipsNLUEngine(string rootDir) { var tempPrt = IntPtr.Zero; if (NativeMethods.snips_nlu_engine_create_from_dir(rootDir, ref tempPrt) != SNIPS_RESULT.SNIPS_RESULT_OK) { this._client = IntPtr.Zero; throw NluEngineError.GetLast(); } _client = tempPrt; }
/// <summary> /// Loads an NluEngine from a zip file /// </summary> /// <param name="rootDir"></param> public SnipsNLUEngine(byte[] rootDir, uint zipSize) { var tempPrt = IntPtr.Zero; if (NativeMethods.snips_nlu_engine_create_from_zip(rootDir, zipSize, ref tempPrt) != SNIPS_RESULT.SNIPS_RESULT_OK) { this._client = IntPtr.Zero; throw NluEngineError.GetLast(); } _client = tempPrt; }
/// <summary> /// Extracts intent and slots from the input /// </summary> /// <param name="str">input to process</param> /// <param name="intentsWhitelist">[TODO] optional list of intents used to restrict the parsing scope</param> /// <param name="intentsBlacklist">[TODO] optional list of intents to exclude during parsing</param> public IntentParserResult Parse(string str, string[] intentsWhitelist = null, string[] intentsBlacklist = null) { if (intentsWhitelist != null || intentsBlacklist != null) { throw new NotImplementedException(); } string json = ""; if (NativeMethods.snips_nlu_engine_run_parse_into_json(_client, EncodeUTF8(str), null, null, ref json) != SNIPS_RESULT.SNIPS_RESULT_OK) { throw NluEngineError.GetLast(); } return(JsonConvert.DeserializeObject <IntentParserResult>(json)); }