% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/worker.R
\name{worker}
\alias{worker}
\title{Initialize a jiebaRS worker}
\usage{
worker(
  type = c("mix", "mp", "hmm", "full", "query", "tag", "keywords", "textrank"),
  stop_word = NULL,
  stop_word_file = NULL,
  hmm = TRUE,
  topn = 5L,
  min_keyword_length = 2L,
  idf = NULL,
  dict = NULL,
  user = NULL,
  symbol = FALSE,
  bylines = FALSE
)
}
\arguments{
\item{type}{Worker type. Supported values are \code{"mix"}, \code{"mp"}, \code{"hmm"},
\code{"full"}, \code{"query"}, \code{"tag"}, \code{"keywords"}, and \code{"textrank"}.
Default is \code{"mix"}.}

\item{stop_word}{Optional character vector of stop words supplied directly.}

\item{stop_word_file}{Optional file path containing one stop word per line.}

\item{hmm}{Logical scalar or character scalar. If logical, controls whether
to enable HMM fallback for unknown terms. If character, must be a path to a
custom HMM model file compatible with \code{jieba-rs}'s \code{hmm.model} format, and
HMM fallback is enabled with that model. Default is \code{TRUE}.}

\item{topn}{Integer. The number of terms returned by \code{keywords} and
\code{textrank} workers. Default is \code{5}.}

\item{min_keyword_length}{Positive integer. The minimum number of Unicode
scalar values in terms returned by \code{keywords} and \code{textrank} workers.
Default is \code{2}.}

\item{idf}{Optional character scalar. A path to a custom IDF dictionary
file for \code{keywords} workers. Each line should be \verb{word idf_value}. When
\code{NULL}, the embedded default IDF dictionary is used. Ignored by non-keyword
workers. Default is \code{NULL}.}

\item{dict}{Optional character scalar. A path to a custom main dictionary
file that \emph{replaces} the embedded dictionary. Each line should be
\code{word [freq] [tag]} (whitespace-separated; \code{freq} defaults to \code{1}, \code{tag}
defaults to empty). When \code{NULL}, the embedded dictionary is used. Default
is \code{NULL}.}

\item{user}{Optional character vector containing one or more paths to user
dictionary files whose entries are \emph{appended} to the main dictionary in
the supplied order. Supported line formats are \code{word}, \verb{word freq},
\verb{word tag}, and \verb{word freq tag}. Omitted frequencies are inferred from the
current dictionary. Default is \code{NULL}.}

\item{symbol}{Logical. Whether to keep symbol-like tokens in the sentence. Default is \code{FALSE}.}

\item{bylines}{\link{Deprecated} compatibility argument retained from \code{jiebaR}.
\code{jiebaRS} no longer uses this value; control batch aggregation directly
in specific functions.}
}
\value{
A \code{jieba_worker} S3 object.
}
\description{
This function can initialize a jiebaRS worker. See Details for more information.
}
\details{
\strong{The \code{qmax} argument is not supported.} Although \code{jiebaR} documented
\code{qmax} for query workers, the value was never actually passed to the
underlying segmentation call. Similarly, the \code{jieba-rs} backend implements
search-mode segmentation without a configurable query threshold. To avoid
user confusion, jiebaRS omits the qmax argument entirely rather than
retaining a no-op parameter.

\code{jieba-rs} does not expose dedicated public implementations for \code{mp} or
\code{hmm} workers. \code{jiebaRS} therefore maps \code{mp} to \code{cut(..., false)} and \code{hmm}
to \code{cut(..., true)}. This is a compatibility approximation rather than a
byte-for-byte reimplementation of \code{jiebaR}, and \code{jiebaRS} warns once per R
session when either type is requested.

\code{tag} workers use \code{jieba-rs} tagging on top of the default mixed
segmentation path, which is the closest public behavior to \code{jiebaR}.

\code{stop_word} and \code{stop_word_file} can be both supplied at once and then
be merged together. Then they will be normalized.

In \code{jiebaRS}, \code{hmm} accepts either a logical scalar or a file path. A
logical value controls whether the underlying \code{jieba-rs}
segmentation/tagging pipeline may fall back to HMM for unknown terms. A
character scalar is interpreted as a path to a custom HMM model file and
enables HMM fallback with that model. The flag affects \code{mix} and \code{query}
workers directly, \code{tag} workers through the underlying mixed tagging path,
and \code{keywords} workers through TF-IDF keyword extraction. \code{mp}, \code{hmm}, and
\code{full} workers ignore the runtime switch because their \code{jieba-rs} backends
do not use this runtime switch.

\code{dict} and \code{user} load dictionary files at worker creation time. \code{dict}
\emph{replaces} the embedded main dictionary entirely; \code{user} accepts one or more
file paths whose entries are appended, in the supplied order, to whatever
main dictionary is in place (default or custom \code{dict}). Main dictionary
entries use \code{word [freq] [tag]}; an omitted frequency defaults to \code{1}. User
dictionary entries may use \code{word}, \verb{word freq}, \verb{word tag} (the legacy
two-column \code{jiebaR} format), or \verb{word freq tag}. User frequencies must be
positive integers; when omitted, a frequency is inferred from the current
dictionary. Files must be UTF-8; a leading byte order mark (BOM) is allowed.
}
