Skip to contents

Add one or more custom words to a jieba worker.

Usage

new_user_word(worker, words, tags = "n", freq = NULL)

add_word(worker, words, tags = "n", freq = NULL)

Arguments

worker

A jieba_worker object.

words

A single string or a character vector of new words.

tags

A single tag or a character vector of tags. Defaults to "n" for each supplied word. NA values are allowed and will be interpreted as missing tags.

freq

Optional non-negative integer frequency or integer vector of frequencies. Defaults to NULL. NA values are allowed and will be interpreted as missing frequencies.

Examples

cutter <- worker()
segment("\u91cf\u5b50\u673a\u5668\u72d7", cutter)
#> [1] "量子" "机器" "狗"  
new_user_word(cutter, "\u91cf\u5b50\u673a\u5668\u72d7", tags = "n", freq = 1000L)
#> NULL
segment("\u91cf\u5b50\u673a\u5668\u72d7", cutter)
#> [1] "量子机器狗"

cutter2 <- worker()
add_word(
  cutter2,
  c("\u8d85\u5bfc\u91cf\u5b50\u6bd4\u7279", "\u91cf\u5b50\u673a\u5668\u72d7"),
  tags = c(NA, "n"),
  freq = c(NA, 1000L)
)
#> NULL
segment("\u8d85\u5bfc\u91cf\u5b50\u6bd4\u7279", cutter2)
#> [1] "超导量子比特"