# Generated by extendr: Do not edit by hand
# nolint start

#' @usage NULL
#' @useDynLib jiebaRS, .registration = TRUE
NULL

#' Create an internal native jieba worker.
#'
#' Internal bridge used by [worker()] to allocate a native `JiebaWorker`.
#'
#' @param worker_type Character scalar naming the worker type. Currently
#'   supports `"mix"`, `"mp"`, `"hmm"`, `"full"`, `"query"`, `"tag"`,
#'   `"keywords"`, and `"textrank"`.
#' @param use_hmm Logical scalar indicating whether HMM fallback should be
#'   enabled for segmentation.
#' @param hmm_model Character scalar containing a custom HMM model path, or an
#'   empty string to use the embedded model.
#' @param idf_path Character scalar containing a custom IDF dictionary path, or
#'   an empty string to use the embedded dictionary.
#' @param dict_path Character scalar containing a custom main dictionary path,
#'   or an empty string to use the embedded dictionary. When provided, the
#'   custom file *replaces* the embedded main dictionary entirely.
#' @param user_paths Character vector containing user dictionary paths. User
#'   entries are *appended* to the main dictionary in the supplied order.
#' @param top_n Integer scalar giving the number of keywords retained by
#'   keyword workers.
#' @param min_keyword_length Positive integer scalar giving the minimum number
#'   of Unicode scalar values in terms retained by keyword workers.
#' @param stop_words Character vector of normalized UTF-8 stop words passed to
#'   the native worker.
#'
#' @return A native `JiebaWorker` handle.
#' @keywords internal
new_worker <- function(worker_type, use_hmm, hmm_model, idf_path, dict_path, user_paths, top_n, min_keyword_length, stop_words) .Call(wrap__new_worker, worker_type, use_hmm, hmm_model, idf_path, dict_path, user_paths, top_n, min_keyword_length, stop_words)

#' Segment text with an internal native worker.
#'
#' Internal bridge used by `segment()` to segment a single UTF-8 string.
#'
#' @param text Character scalar containing the input text.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A character vector of segmented tokens.
#' @keywords internal
segment_worker <- function(text, worker) .Call(wrap__segment_worker, text, worker)

#' Segment multiple strings with an internal native worker.
#'
#' Internal bridge used by `segment()` to segment many UTF-8 strings.
#'
#' @param texts Character vector containing the input strings.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A list of character vectors, one per input string.
#' @keywords internal
segment_batch_worker <- function(texts, worker) .Call(wrap__segment_batch_worker, texts, worker)

#' Tag text with an internal native worker.
#'
#' Internal bridge used by [tagging()] to tag a single UTF-8 string.
#'
#' @param text Character scalar containing the input text.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A named list with `term` and `tag` vectors.
#' @keywords internal
tagging_worker <- function(text, worker) .Call(wrap__tagging_worker, text, worker)

#' Tag multiple strings with an internal native worker.
#'
#' Internal bridge used by `tagging()` to tag many UTF-8 strings.
#'
#' @param texts Character vector containing the input strings.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A list where each element is a named list with `term` and `tag`
#'   vectors.
#' @keywords internal
tagging_batch_worker <- function(texts, worker) .Call(wrap__tagging_batch_worker, texts, worker)

#' Extract keywords with an internal native worker.
#'
#' Internal bridge used by [keywords()] to extract TF-IDF keywords from a
#' single UTF-8 string.
#'
#' @param text Character scalar containing the input text.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A named list with `keyword` and `weight` vectors.
#' @keywords internal
keywords_worker <- function(text, worker) .Call(wrap__keywords_worker, text, worker)

#' Extract TextRank keywords with an internal native worker.
#'
#' Internal bridge used by [textrank()] to extract TextRank keywords from a
#' single UTF-8 string.
#'
#' @param text Character scalar containing the input text.
#' @param worker A native `JiebaWorker` handle created by the internal worker
#'   constructor.
#'
#' @return A named list with `keyword` and `weight` vectors.
#' @keywords internal
textrank_worker <- function(text, worker) .Call(wrap__textrank_worker, text, worker)

#' Add user-defined words with an internal native worker.
#'
#' Internal bridge used by [new_user_word()] to mutate an existing native
#' worker in place.
#'
#' @param worker A mutable native `JiebaWorker` handle.
#' @param words Character vector of custom words.
#' @param tags Character vector of tags aligned with `words`.
#' @param freq Optional integer vector of frequencies aligned with `words`.
#'
#' @return `NULL`, invisibly, after the worker has been updated.
#' @keywords internal
add_user_words <- function(worker, words, tags, freq) .Call(wrap__add_user_words, worker, words, tags, freq)

# nolint end
