textrank_batch: Extract TextRank keywords from a batch of strings

View source: R/textrank.R

textrank_batchR Documentation

Extract TextRank keywords from a batch of strings

Description

Convenience wrapper around textrank() for multi-string input. When batch is not supplied, textrank_batch() returns list output.

Usage

textrank_batch(
  x,
  worker,
  ...,
  format = c("vector", "data.frame", "legacy"),
  batch = c("list", "flatten"),
  texts = deprecated(),
  jiebar = deprecated()
)

Arguments

x

A non-empty character vector to analyze.

worker

A jieba_worker object created with worker(type = "textrank").

...

Must be empty. This enforces that optional arguments such as format and batch are supplied with explicit names.

format

Output format for each document. Must be one of "vector", "data.frame", or "legacy".

batch

Aggregation mode. Must be one of "list" or "flatten".

texts, jiebar

[Deprecated] Use x and worker instead.

Details

Each string is one document; documents are processed in parallel and up to topn keywords are ranked within each one. The returned object depends on both format and batch:

  • batch = "list": one single-document TextRank result per input string.

  • batch = "flatten": all results concatenated. "vector"/"legacy" produce one named vector, while "data.frame" produces a combined data frame with a leading doc_id column.

Value

TextRank results in the requested format.

Examples

ranker <- worker(type = "textrank", topn = 2)
texts <- c(
  "\u5317\u4eac\u70e4\u9e2d\u771f\u597d\u5403\uff0c\u5317\u4eac\u70e4\u9e2d",
  "\u7ebd\u7ea6\u7684\u5929\u6c14\u771f\u597d\uff0c\u7ebd\u7ea6\u7684\u5929\u6c14"
)
textrank_batch(texts, ranker)
textrank_batch(texts, ranker, format = "data.frame", batch = "flatten")

jiebaRS documentation built on Dec. 3, 2026, 5:09 p.m.