AiliaTokenizer

class AiliaTokenizer(tokenizerType: Int = AILIA_TOKENIZER_TYPE_XLM_ROBERTA)

Tokenizer for natural language processing models.

This class provides text tokenization (encoding to token IDs) and vocabulary lookup via the ailia Tokenizer native library.

Parameters

tokenizerType

Type of the tokenizer, one of the AILIA_TOKENIZER_TYPE_* constants.

Constructors

Link copied to clipboard
constructor(tokenizerType: Int = AILIA_TOKENIZER_TYPE_XLM_ROBERTA)

Creates a tokenizer instance of the given type.

Types

Link copied to clipboard
object Companion

Constants of the tokenizer.

Functions

Link copied to clipboard
fun close()

Releases the native resources held by the tokenizer.

Link copied to clipboard
fun encode(text: String): IntArray

Encodes a text into token IDs.

Link copied to clipboard
fun getWord(token: Int): String

Returns the vocabulary word corresponding to a token ID.

Link copied to clipboard
fun loadFiles(modelPath: String? = null, vocabPath: String? = null, mergePath: String? = null, dictionaryPath: String? = null)

Loads the resource files required by the tokenizer.