MCPcopy Create free account
hub / github.com/cactus-compute/cactus / Java_com_cactus_CactusJNI_nativeTokenize

Function Java_com_cactus_CactusJNI_nativeTokenize

android/cactus_jni.cpp:338–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338JNIEXPORT jintArray JNICALL
339Java_com_cactus_CactusJNI_nativeTokenize(JNIEnv* env, jobject, jlong handle, jstring text) {
340 if (handle == 0) { throwCactusException(env, "Model not initialized"); return nullptr; }
341
342 const char* textStr = jstring_to_cstr(env, text);
343 std::vector<uint32_t> buffer(8192);
344 size_t tokenLen = 0;
345
346 int result = cactus_tokenize(
347 reinterpret_cast<cactus_model_t>(handle),
348 textStr,
349 buffer.data(),
350 buffer.size(),
351 &tokenLen
352 );
353
354 release_jstring(env, text, textStr);
355
356 if (result < 0) { throwOnError(env); return nullptr; }
357
358 jintArray jarray = env->NewIntArray(static_cast<jsize>(tokenLen));
359 if (tokenLen > 0) {
360 env->SetIntArrayRegion(jarray, 0, static_cast<jsize>(tokenLen), reinterpret_cast<jint*>(buffer.data()));
361 }
362 return jarray;
363}
364
365JNIEXPORT jstring JNICALL
366Java_com_cactus_CactusJNI_nativeScoreWindow(JNIEnv* env, jobject, jlong handle,

Callers

nothing calls this directly

Calls 7

throwCactusExceptionFunction · 0.85
jstring_to_cstrFunction · 0.85
release_jstringFunction · 0.85
throwOnErrorFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.80
cactus_tokenizeFunction · 0.50

Tested by

no test coverage detected