@@ -16,66 +16,66 @@ class NluEngine private constructor(clientBuilder: () -> Pointer) : Closeable {
1616
1717 companion object {
1818 private fun parseError (returnCode : Int ) {
19- if (returnCode != 1 ) {
19+ if (returnCode != 0 ) {
2020 PointerByReference ().apply {
21- LIB .nlu_engine_get_last_error (this )
21+ LIB .snips_nlu_engine_get_last_error (this )
2222 throw RuntimeException (value.getString(0 ).apply {
23- LIB .nlu_engine_destroy_string (value)
23+ LIB .snips_nlu_engine_destroy_string (value)
2424 })
2525 }
2626 }
2727 }
2828
2929 @JvmStatic
3030 fun modelVersion (): String = PointerByReference ().run {
31- parseError(LIB .nlu_engine_get_model_version (this ))
32- value.getString(0 ).apply { LIB .nlu_engine_destroy_string (value) }
31+ parseError(LIB .snips_nlu_engine_get_model_version (this ))
32+ value.getString(0 ).apply { LIB .snips_nlu_engine_destroy_string (value) }
3333 }
3434 }
3535
3636 constructor (assistant: File ) :
3737 this ({
3838 PointerByReference ().apply {
3939 if (assistant.isDirectory) {
40- parseError(LIB .nlu_engine_create_from_dir (assistant.absolutePath.toPointer(), this ))
40+ parseError(LIB .snips_nlu_engine_create_from_dir (assistant.absolutePath.toPointer(), this ))
4141 } else {
42- parseError(LIB .nlu_engine_create_from_file (assistant.absolutePath.toPointer(), this ))
42+ parseError(LIB .snips_nlu_engine_create_from_file (assistant.absolutePath.toPointer(), this ))
4343 }
4444 }.value
4545 })
4646
4747 constructor (data: ByteArray ) :
4848 this ({
4949 PointerByReference ().apply {
50- parseError(LIB .nlu_engine_create_from_zip (data, data.size, this ))
50+ parseError(LIB .snips_nlu_engine_create_from_zip (data, data.size, this ))
5151 }.value
5252 })
5353
5454
5555 val client: Pointer = clientBuilder()
5656
5757 override fun close () {
58- LIB .nlu_engine_destroy_client (client)
58+ LIB .snips_nlu_engine_destroy_client (client)
5959 }
6060
6161 fun parse (input : String ): IntentParserResult =
6262 CIntentParserResult (PointerByReference ().apply {
63- parseError(LIB .nlu_engine_run_parse (client, input.toPointer(), this ))
63+ parseError(LIB .snips_nlu_engine_run_parse (client, input.toPointer(), this ))
6464 }.value).let {
6565 it.toIntentParserResult().apply {
6666 // we don't want jna to try and sync this struct after the call as we're destroying it
6767 // /!\ removing that will make the app crash semi randomly...
6868 it.autoRead = false
69- LIB .nlu_engine_destroy_result (it)
69+ LIB .snips_nlu_engine_destroy_result (it)
7070 }
7171 }
7272
7373 fun parseIntoJson (input : String ): String =
7474 PointerByReference ().apply {
75- parseError(LIB .nlu_engine_run_parse_into_json (client, input.toPointer(), this ))
75+ parseError(LIB .snips_nlu_engine_run_parse_into_json (client, input.toPointer(), this ))
7676 }.value.let {
7777 it.readString().apply {
78- LIB .nlu_engine_destroy_string (it)
78+ LIB .snips_nlu_engine_destroy_string (it)
7979 }
8080 }
8181
@@ -84,15 +84,15 @@ class NluEngine private constructor(clientBuilder: () -> Pointer) : Closeable {
8484 val INSTANCE : SnipsNluClientLibrary = Native .loadLibrary(" snips_nlu_ffi" , SnipsNluClientLibrary ::class .java)
8585 }
8686
87- fun nlu_engine_get_model_version (version : PointerByReference ): Int
88- fun nlu_engine_create_from_file (file_path : Pointer , pointer : PointerByReference ): Int
89- fun nlu_engine_create_from_dir (root_dir : Pointer , pointer : PointerByReference ): Int
90- fun nlu_engine_create_from_zip (data : ByteArray , data_size : Int , pointer : PointerByReference ): Int
91- fun nlu_engine_run_parse (client : Pointer , input : Pointer , result : PointerByReference ): Int
92- fun nlu_engine_run_parse_into_json (client : Pointer , input : Pointer , result : PointerByReference ): Int
93- fun nlu_engine_get_last_error (error : PointerByReference ): Int
94- fun nlu_engine_destroy_client (client : Pointer ): Int
95- fun nlu_engine_destroy_result (result : CIntentParserResult ): Int
96- fun nlu_engine_destroy_string (string : Pointer ): Int
87+ fun snips_nlu_engine_get_model_version (version : PointerByReference ): Int
88+ fun snips_nlu_engine_create_from_file (file_path : Pointer , pointer : PointerByReference ): Int
89+ fun snips_nlu_engine_create_from_dir (root_dir : Pointer , pointer : PointerByReference ): Int
90+ fun snips_nlu_engine_create_from_zip (data : ByteArray , data_size : Int , pointer : PointerByReference ): Int
91+ fun snips_nlu_engine_run_parse (client : Pointer , input : Pointer , result : PointerByReference ): Int
92+ fun snips_nlu_engine_run_parse_into_json (client : Pointer , input : Pointer , result : PointerByReference ): Int
93+ fun snips_nlu_engine_get_last_error (error : PointerByReference ): Int
94+ fun snips_nlu_engine_destroy_client (client : Pointer ): Int
95+ fun snips_nlu_engine_destroy_result (result : CIntentParserResult ): Int
96+ fun snips_nlu_engine_destroy_string (string : Pointer ): Int
9797 }
9898}
0 commit comments