| keywords | R Documentation |
Extract TF-IDF keywords from one or more in-memory strings with a keyword
worker created by worker(). This is separate from textrank(), which uses
TextRank weighting.
keywords(
x,
worker,
...,
format = c("vector", "data.frame", "legacy"),
batch = c("list", "flatten"),
code = deprecated(),
jiebar = deprecated()
)
x |
A non-empty character vector to analyze. Each string is one document. |
worker |
A |
... |
Must be empty. This enforces that optional arguments such as
|
format |
Output format for each document. |
batch |
Aggregation mode for multi-string input. Must be one of
|
code, jiebar |
Each string is treated as one document, and up to topn keywords (see
worker()) are extracted from each document independently. Multiple
strings are processed in parallel.
format controls the shape of each single-document result:
"vector": a named numeric vector of weights, named by keyword.
"data.frame": a data frame with term and weight columns.
"legacy": the old jiebaR layout with keyword values and weights in
names().
When x contains multiple strings, batch controls how the
per-document results are aggregated:
"list": one single-document result per input string.
"flatten": concatenate all results into one. "vector"/"legacy"
produce one named vector, while "data.frame" produces a combined data
frame with a leading doc_id column.
A single input string always returns a single-document result, and batch
is ignored after being validated.
Keyword results in the requested format.
keys <- worker(type = "keywords", topn = 2)
text1 <- "\u5317\u4eac\u70e4\u9e2d\u771f\u597d\u5403\uff0c\u5317\u4eac\u70e4\u9e2d"
text2 <- "\u7ebd\u7ea6\u7684\u5929\u6c14\u771f\u597d\uff0c\u7ebd\u7ea6\u7684\u5929\u6c14"
keywords(text1, keys)
keywords(c(text1, text2), keys)
keywords(c(text1, text2), keys, format = "data.frame", batch = "flatten")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.