This function generates a mapping list for Named Entity Recognition (NER) highlighting. The mapping list defines how different entity types should be highlighted in text displays, defining the background color, font color, label, and label color for each entity type.
Arguments
- df
A data frame containing at least two columns:
entity
: A character vector of words/entities to be highlighted.tag
: A character vector indicating the entity type of each word/entity.
- entity
A character vector of entities annotated by the model.
- tag
A character vector of tags corresponding to the annotated entities.
Value
A list with mapping settings for each entity type, where each entity type is represented as a list containing:
words
: A character vector of words to be highlighted.background_color
: A character string representing the background color for highlighting the words.font_color
: A character string representing the font color for the words.label
: A character string to label the entity type.label_color
: A character string representing the font color for the label.
Examples
if (FALSE) { # \dontrun{
sample_df <- data.frame(
entity = c("Microsoft", "USA", "dollar", "Bill Gates"),
tag = c("ORG", "LOC", "MISC", "PER"),
stringsAsFactors = FALSE
)
mapping <- map_entities(sample_df)
} # }