C API reference · Kjarni 0.2.8
classifier
kjarni_classifier_config_default
struct KjarniClassifierConfig kjarni_classifier_config_default(void);
Get default classifier configuration.
kjarni_classifier_new
enum KjarniErrorCode kjarni_classifier_new(const struct KjarniClassifierConfig *config, struct KjarniClassifier **out);
Create a new Classifier.
Safety
configmust be valid or NULLoutmust be a valid pointer- The returned handle must be freed with
kjarni_classifier_free
kjarni_classifier_free
void kjarni_classifier_free(struct KjarniClassifier *classifier);
Free a Classifier.
Safety
classifiermust be null, or a handle returned bykjarni_classifier_newthat has not already been passed to this function. It is invalid to use afterwards.
kjarni_classifier_classify
enum KjarniErrorCode kjarni_classifier_classify(struct KjarniClassifier *classifier, const char *text, struct KjarniClassResults *out);
Classify a single text.
Safety
classifiermust be null, or a live handle returned bykjarni_classifier_newthat has not been freed.textmust be null, or a valid pointer to a nul-terminated C string.outmust be a valid, writable pointer to aKjarniClassResults. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_classifier_classify_batch
enum KjarniErrorCode kjarni_classifier_classify_batch(struct KjarniClassifier *classifier, const char *const *texts, uintptr_t num_texts, struct KjarniClassBatch *out);
Classify several texts in one call.
The texts go through the model together, grouped by length, which on a CPU
is several times faster than classifying them one at a time. Each result is
the same as kjarni_classifier_classify gives for that text alone.
Safety
classifiermust be null, or a live handle returned bykjarni_classifier_new.textsmust point tonum_textsvalid, nul-terminated C strings, or be null whennum_textsis 0.outmust be a valid, writable pointer. OnKJARNI_OKit receives a value the caller owns and must release withkjarni_class_batch_free.
kjarni_classifier_labels
enum KjarniErrorCode kjarni_classifier_labels(const struct KjarniClassifier *classifier, struct KjarniStringArray *out);
Get the classifier's labels.
Safety
classifiermust be null, or a live handle returned bykjarni_classifier_newthat has not been freed.outmust be a valid, writable pointer to aKjarniStringArray. OnKJARNI_OKit receives a value the caller owns and must release with the matching*_free; on failure it is either cleared or left unmodified, and must not be read.
kjarni_classifier_num_labels
uintptr_t kjarni_classifier_num_labels(const struct KjarniClassifier *classifier);
Get number of labels.
Safety
classifiermust be null, or a live handle returned bykjarni_classifier_newthat has not been freed.
Kjarni runs the same engine on every platform: