| filter_segment | R Documentation |
Remove selected words from a segmented character vector or from each element of a list of segmented character vectors.
filter_segment(input, filter_words, ..., keep_na = TRUE)
input |
A character vector or a list of character vectors. |
filter_words |
A character vector of words to remove. |
... |
Must be empty. This enforces that optional arguments such as
|
keep_na |
Whether to keep |
This is a modern reimplementation of jiebaR::filter_segment() with the
same core filtering behavior under the default settings.
In the reproducible benchmark, this version is about 110x to 140x
faster than jiebaR::filter_segment() on the tested workloads.
An object with the same shape as input, with matching words
removed.
filter_segment(c("abc", "def", " ", "."), c("abc"))
filter_segment(c("a", NA, "b", "a"), c("b"), keep_na = FALSE)
input <- list(
c("\u6211", "\u662f", "\u6d4b\u8bd5"),
c("\u6d4b\u8bd5", "\u6587\u672c", "\u6211")
)
filter_segment(input, "\u6211")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.