10 {
11 printf("=== C-Kernel-Engine Tokenizer Test ===\n\n");
12
13
15 if (!tok) {
16 fprintf(stderr, "Failed to create tokenizer\n");
17 return 1;
18 }
19
20 printf("Tokenizer type: %s\n\n", ck_tokenizer_type_name(tok));
21
22
23 printf("Adding test vocabulary...\n");
24
25
30
31
41
42
45
47
48
49 const char *test_strings[] = {
50 "hello world",
51 "testing",
52 "tokenizer",
53 "hello world testing tokenizer",
54 NULL
55 };
56
57 printf("=== Encoding Tests ===\n\n");
58
59 for (int i = 0; test_strings[i] != NULL; i++) {
60 const char *
text = test_strings[i];
63
64
67
69
70 printf(
"Input: \"%s\"\n",
text);
71 printf(
"Tokens [%d]: ",
num_ids);
72
73 for (
int j = 0; j <
num_ids; j++) {
77 printf(
"(%s)",
token);
78 }
79 if (j <
num_ids - 1) printf(
", ");
80 }
81 printf("\n");
82
83
84 char decoded[1024];
86 printf("Decoded: \"%s\"\n\n", decoded);
87 }
88
89
90 printf("=== Lookup Tests ===\n\n");
94
95
97
98 printf("\n=== Test Complete ===\n");
99 return 0;
100}
int32_t ck_tokenizer_lookup(const CKTokenizer *tok, const char *token, int len)
int ck_tokenizer_decode(const CKTokenizer *tok, const int32_t *ids, int num_ids, char *text, int max_len)
int ck_tokenizer_encode(const CKTokenizer *tok, const char *text, int text_len, int32_t *ids, int max_ids)
int32_t ck_tokenizer_add_token(CKTokenizer *tok, const char *token, int len)
void ck_tokenizer_free(CKTokenizer *tok)
const char * ck_tokenizer_id_to_token(const CKTokenizer *tok, int32_t id)
static int ck_tokenizer_vocab_size(const CKTokenizer *tok)
const int32_t int num_ids
static CKTokenizer * ck_tokenizer_create_bpe(void)
int ck_tokenizer_add_special_token(CKTokenizer *tok, const char *name, int32_t id)
const char int int32_t int max_ids