xref: /aosp_15_r20/external/libtextclassifier/native/lang_id/lang-id_jni.h (revision 993b0882672172b81d12fad7a7ac0c3e5c824a12)
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 // JNI wrapper for LangId.
18 
19 #ifndef LIBTEXTCLASSIFIER_LANG_ID_LANG_ID_JNI_H_
20 #define LIBTEXTCLASSIFIER_LANG_ID_LANG_ID_JNI_H_
21 
22 #include <jni.h>
23 
24 #include <string>
25 
26 #include "utils/java/jni-base.h"
27 
28 #ifndef TC3_LANG_ID_CLASS_NAME
29 #define TC3_LANG_ID_CLASS_NAME LangIdModel
30 #endif
31 
32 #define TC3_LANG_ID_CLASS_NAME_STR TC3_ADD_QUOTES(TC3_LANG_ID_CLASS_NAME)
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 TC3_JNI_METHOD(jlong, TC3_LANG_ID_CLASS_NAME, nativeNew)
39 (JNIEnv* env, jobject clazz, jint fd);
40 
41 TC3_JNI_METHOD(jlong, TC3_LANG_ID_CLASS_NAME, nativeNewFromPath)
42 (JNIEnv* env, jobject clazz, jstring path);
43 
44 TC3_JNI_METHOD(jlong, TC3_LANG_ID_CLASS_NAME, nativeNewWithOffset)
45 (JNIEnv* env, jobject clazz, jint fd, jlong offset, jlong size);
46 
47 TC3_JNI_METHOD(jobjectArray, TC3_LANG_ID_CLASS_NAME, nativeDetectLanguages)
48 (JNIEnv* env, jobject thiz, jlong ptr, jstring text);
49 
50 TC3_JNI_METHOD(void, TC3_LANG_ID_CLASS_NAME, nativeClose)
51 (JNIEnv* env, jobject thiz, jlong ptr);
52 
53 TC3_JNI_METHOD(jint, TC3_LANG_ID_CLASS_NAME, nativeGetVersion)
54 (JNIEnv* env, jobject thiz, jlong ptr);
55 
56 TC3_JNI_METHOD(jint, TC3_LANG_ID_CLASS_NAME, nativeGetVersionFromFd)
57 (JNIEnv* env, jobject clazz, jint fd);
58 
59 TC3_JNI_METHOD(jfloat, TC3_LANG_ID_CLASS_NAME, nativeGetLangIdThreshold)
60 (JNIEnv* env, jobject thizz, jlong ptr);
61 
62 TC3_JNI_METHOD(jfloat, TC3_LANG_ID_CLASS_NAME, nativeGetLangIdNoiseThreshold)
63 (JNIEnv* env, jobject thizz, jlong ptr);
64 
65 TC3_JNI_METHOD(jint, TC3_LANG_ID_CLASS_NAME, nativeGetMinTextSizeInBytes)
66 (JNIEnv* env, jobject thizz, jlong ptr);
67 
68 TC3_JNI_METHOD(jint, TC3_LANG_ID_CLASS_NAME, nativeGetVersionWithOffset)
69 (JNIEnv* env, jobject clazz, jint fd, jlong offset, jlong size);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif  // LIBTEXTCLASSIFIER_LANG_ID_LANG_ID_JNI_H_
76