Highlight tokens based on exact match, a regular expression or corpus position in kwic output or html document.

tooltips(.Object, tooltips, ...)

# S4 method for class 'character'
tooltips(
  .Object,
  tooltips = list(),
  fmt = "//span[@style=\"background-color:%s\"]",
  verbose
)

# S4 method for class 'html'
tooltips(.Object, tooltips = list(), fmt, verbose = TRUE)

# S4 method for class 'kwic'
tooltips(.Object, tooltips, regex = FALSE, ...)

Arguments

.Object

A html or character object with html.

tooltips

A named list of character vectors, the names need to match colors in the list provided to param highlight. The value of the character vector is the tooltip to be displayed.

...

Further arguments are interpreted as assignments of tooltips to tokens.

fmt

A format string with an xpath expression used to look up the node where the tooltip is inserted. If missing, a heuristic evaluating the names of the tooltips list decides whether tooltips are inserted based on highlighting colors or corpus positions.

verbose

A logical value, whether to show messages.

regex

A logical value, whether character vector values of argument tooltips are interpreted as regular expressions.

Examples

use(pkg = "RcppCWB", corpus = "REUTERS")
#> ✔ corpus loaded: REUTERS

a <- partition("REUTERS", places = "argentina")
#> ... get cpos and strucs
b <- html(a)
c <- highlight(b, lightgreen = "higher")
d <- tooltips(c, list(lightgreen = "Further information"))
#> ℹ assign tooltips based on color
if (interactive()) d

# Using the tooltips-method in a pipe ...
h <- a %>%
  html() %>%
  highlight(yellow = c("barrels", "oil", "gas")) %>%
  tooltips(list(yellow = "energy"))
#> ℹ assign tooltips based on color