% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/segment.R
\name{segment_batch}
\alias{segment_batch}
\title{Segment a batch of strings}
\usage{
segment_batch(texts, jiebar, ..., batch = c("list", "data.frame", "flatten"))
}
\arguments{
\item{texts}{A character vector of strings to segment.}

\item{jiebar}{A \code{jieba_worker} object.}

\item{...}{Must be empty. This enforces that optional arguments such as
\code{batch} are supplied with explicit names.}

\item{batch}{Batch aggregation mode. Must be one of \code{"list"},
\code{"data.frame"}, or \code{"flatten"}. The default is \code{"list"}.}
}
\value{
Segmented tokens in the requested aggregation form.
}
\description{
Convenience wrapper around \code{\link[=segment]{segment()}} for multi-string input. When
\code{batch} is omitted, \code{segment_batch()} will return \strong{list} output by default.
}
\details{
\code{segment_batch()} is a convenience wrapper around \code{\link[=segment]{segment()}} for explicit
batch processing. It always treats \code{texts} as multi-string input. The
returned object depends on \code{batch}:
\itemize{
\item \code{"list"}: one character vector per input string.
\item \code{"data.frame"}: a data frame with \code{doc_id} and \code{word} columns.
\item \code{"flatten"}: one concatenated character vector.
}

In the current release benchmarks on the bundled \emph{Fortress Besieged} and
\emph{Dream of the Red Chamber} texts, batch segmentation reaches about \strong{7x to
12x speedup} over the comparable \code{jiebaR} workflow on many-string inputs.
For very long texts, splitting into about \strong{32 to 128 chunks} before calling
\code{segment_batch()} is recommended for good throughput.
}
\examples{
seg <- worker()
texts <- c("\u5357\u4eac\u5e02\u957f\u6c5f\u5927\u6865", "\u8fd9\u662f\u4e00\u4e2a\u6d4b\u8bd5")
segment_batch(texts, seg)
segment_batch(texts, seg, batch = "flatten")
}
