highlight_tokens {tokenbrowser} | R Documentation |
This is a convenience wrapper for tag_tokens() that can be used if tokens only need to be colored.
highlight_tokens(tokens, value, col = "yellow", span_adjacent = F)
tokens |
A character vector of tokens |
value |
Either a logical vector or a numeric vector with values between 0 and 1. If a logical vector is used, then tokens with TRUE will be highlighted (with the color specified in pos_col). If a numeric vector is used, the value determines the alpha (transparency), with 0 being fully transparent and 1 being fully colored. |
col |
The color used to highlight |
span_adjacent |
If TRUE, include adjacent tokens with identical attributes within the same tag |
a character vector of color-tagged tokens
highlight_tokens(c('token_1','token_2','token_3'), value = c(FALSE,FALSE,TRUE)) highlight_tokens(c('token_1','token_2','token_3'), value = c(0,0.3,0.6))