tooltips: Add tooltips to text output.

tooltips-methodR Documentation

Add tooltips to text output.

Description

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

Usage

tooltips(.Object, tooltips, ...)

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

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

## S4 method for signature '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")

a <- partition("REUTERS", places = "argentina")
b <- html(a)
c <- highlight(b, lightgreen = "higher")
d <- tooltips(c, list(lightgreen = "Further information"))
if (interactive()) d

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

PolMine/polmineR documentation built on Nov. 9, 2023, 8:07 a.m.