tag_tokens(tokens = c('token_1','token_2', 'token_3'),
class = c(1,1,2),
style = attr_style(color = set_col('red'),
`background-color` = highlight_col(c(FALSE,FALSE,TRUE))))
## tokens without attributes are not given a span tag
tag_tokens(tokens = c('token_1','token_2', 'token_3'),
class = c(1,NA,NA),
style = attr_style(color = highlight_col(c(TRUE,TRUE,FALSE))))
## span_adjacent can be used to put tokens with identical tags within one tag
## but then a doc_id has to be given as well
tag_tokens(tokens = c('token_1','token_2', 'token_3'),
class = c(1,1,NA),
span_adjacent=TRUE,
doc_id = c(1,1,1))
Run the code above in your browser using DataLab