|
virtual void | Dispose (bool disposing) |
|
◆ AddSpecialTokens()
bool ailiaTokenizer.AiliaTokenizerModel.AddSpecialTokens |
( |
string[] |
tokens | ) |
|
|
inline |
Adding SpecialToken.
- Parameters
-
- Returns
- If this function is successful, it returns true , or false otherwise.
This is valid only for AILIA_TOKENIZER_TYPE_ROBERTA and AILIA_TOKENIZER_TYPE_ROBERTA.
394 IntPtr[] utf8Strings =
new IntPtr[tokens.Length];
395 for (
int i = 0; i < tokens.Length; i++) {
396 byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(tokens[i] +
'\0');
397 utf8Strings[i] = Marshal.AllocHGlobal(utf8Bytes.Length);
398 Marshal.Copy(utf8Bytes, 0, utf8Strings[i], utf8Bytes.Length);
401 IntPtr tokensPtr = Marshal.AllocHGlobal(IntPtr.Size * tokens.Length);
402 Marshal.Copy(utf8Strings, 0, tokensPtr, utf8Strings.Length);
404 int status = AiliaTokenizer.ailiaTokenizerAddSpecialTokens(net, tokensPtr, (uint)tokens.Length);
406 Marshal.FreeHGlobal(tokensPtr);
407 foreach (IntPtr ptr
in utf8Strings) {
408 Marshal.FreeHGlobal(ptr);
413 Debug.Log(
"ailiaTokenizerAddSpecialTokens failed " + status);
◆ Close()
virtual void ailiaTokenizer.AiliaTokenizerModel.Close |
( |
| ) |
|
|
inlinevirtual |
Destroys instance.
Destroys and initializes the instance.
135 if (net != IntPtr.Zero){
136 AiliaTokenizer.ailiaTokenizerDestroy(net);
◆ Create()
bool ailiaTokenizer.AiliaTokenizerModel.Create |
( |
int |
type, |
|
|
int |
flag |
|
) |
| |
|
inline |
Create a instance.
- Parameters
-
- Returns
- If this function is successful, it returns true , or false otherwise.
38 if (net != IntPtr.Zero){
42 int status = AiliaTokenizer.ailiaTokenizerCreate(ref net, type, flag);
45 Debug.Log(
"ailiaTokenizerCreate failed " + status);
◆ Decode()
string ailiaTokenizer.AiliaTokenizerModel.Decode |
( |
int[] |
tokens | ) |
|
|
inline |
Perform decode @pram tokens Input tokens.
- Returns
- If this function is successful, it returns string , or empty string otherwise.
304 return DecodeCore(tokens,
false);
◆ DecodeWithSpecialTokens()
string ailiaTokenizer.AiliaTokenizerModel.DecodeWithSpecialTokens |
( |
int[] |
tokens | ) |
|
|
inline |
Perform decode with special tokens @pram tokens Input tokens.
- Returns
- If this function is successful, it returns string , or empty string otherwise.
322 return DecodeCore(tokens,
true);
◆ Dispose() [1/2]
virtual void ailiaTokenizer.AiliaTokenizerModel.Dispose |
( |
| ) |
|
|
inlinevirtual |
◆ Dispose() [2/2]
virtual void ailiaTokenizer.AiliaTokenizerModel.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
◆ Encode()
int [] ailiaTokenizer.AiliaTokenizerModel.Encode |
( |
string |
utf8 | ) |
|
|
inline |
Perform encode.
- Parameters
-
- Returns
- If this function is successful, it returns array of tokens , or empty array otherwise.
268 return EncodeCore(utf8,
false);
◆ EncodeWithSpecialTokens()
int [] ailiaTokenizer.AiliaTokenizerModel.EncodeWithSpecialTokens |
( |
string |
utf8 | ) |
|
|
inline |
Perform encode with special tokens.
- Parameters
-
- Returns
- If this function is successful, it returns array of tokens , or empty array otherwise.
286 return EncodeCore(utf8,
true);
◆ GetVocab()
string ailiaTokenizer.AiliaTokenizerModel.GetVocab |
( |
int |
token | ) |
|
|
inline |
Acquiring vocab.
- Parameters
-
- Returns
- If this function is successful, it returns string , or null otherwise.
364 IntPtr ptr = IntPtr.Zero;
365 int status = AiliaTokenizer.ailiaTokenizerGetVocab(net, token, ref ptr);
368 Debug.Log(
"ailiaTokenizerGetVocab failed " + status);
372 return Marshal.PtrToStringAnsi(ptr);
◆ GetVocabSize()
int ailiaTokenizer.AiliaTokenizerModel.GetVocabSize |
( |
| ) |
|
|
inline |
Gets the size of vocab.
- Returns
- If this function is successful, it returns the size of vocab , or -1 otherwise.
339 int status = AiliaTokenizer.ailiaTokenizerGetVocabSize(net, ref len);
342 Debug.Log(
"ailiaTokenizerGetVocabSize failed " + status);
◆ Open()
bool ailiaTokenizer.AiliaTokenizerModel.Open |
( |
string |
model_path = null , |
|
|
string |
dictionary_path = null , |
|
|
string |
vocab_path = null , |
|
|
string |
merge_path = null |
|
) |
| |
|
inline |
Open a model.
- Parameters
-
model_path | Path for model (don't load if null) |
dictionary_path | Path for dictionary (don't load if null) |
vocab_path | Path for vocab (don't load if null) |
merge_path | Path for merge (don't load if null) |
- Returns
- If this function is successful, it returns true , or false otherwise.
73 if (net == IntPtr.Zero){
79 if (model_path !=
null){
80 status = AiliaTokenizer.ailiaTokenizerOpenModelFile(net, model_path);
83 Debug.Log(
"ailiaTokenizerOpenModelFile failed " + status);
88 if (dictionary_path !=
null){
89 status = AiliaTokenizer.ailiaTokenizerOpenDictionaryFile(net, dictionary_path);
92 Debug.Log(
"ailiaTokenizerOpenDictionaryFile failed " + status);
97 if (vocab_path !=
null){
98 status = AiliaTokenizer.ailiaTokenizerOpenVocabFile(net, vocab_path);
101 Debug.Log(
"ailiaTokenizerOpenVocabFile failed " + status);
106 if (merge_path !=
null){
107 status = AiliaTokenizer.ailiaTokenizerOpenMergeFile(net, merge_path);
110 Debug.Log(
"ailiaTokenizerOpenMergeFile failed " + status);
The documentation for this class was generated from the following file: