Skip to contents

Adds a named candidate column to a Betwixt candidate dataset. Candidate columns are stored as triplets consisting of a candidate value, an optional controlled range, and an optional semantic definition.

Usage

add_candidate_column(
  x,
  name,
  value,
  range = NA_character_,
  definition = NA_character_
)

Arguments

x

A data frame or tibble representing a Betwixt candidate dataset.

name

A character string giving the name of the candidate column.

value

A vector containing the candidate values to be reviewed. Its length must be compatible with the number of rows in x.

range

A character vector containing the admissible or suggested range of candidate values. Use NA_character_ when no controlled range is supplied. Defaults to NA_character_.

definition

A character vector containing identifiers or URLs defining the semantic property represented by the candidate column. Use NA_character_ when no definition is supplied. Defaults to NA_character_.

Value

A tibble with three additional columns: name, name_range, and name_definition, where name is the supplied candidate-column name.

Details

add_candidate_column() does not modify existing candidate columns. Candidate columns use semantic names supplied explicitly through name.

Contextual, non-reviewable information does not need to be added with this function and can be appended with ordinary data manipulation operations, for example dplyr::mutate(context_1 = held_by).

Examples

candidates <- tibble::tibble(
  row_number = 1:2,
  evidence_text = c("image-1", "image-2")
)

candidates <- add_candidate_column(
  candidates,
  name = "instance_of",
  value = c("farmhouse", "bed"),
  range = rep("farmhouse | bed | Other...", 2),
  definition = rep(
    "https://www.wikidata.org/wiki/Property:P31",
    2
  )
)

names(candidates)
#> [1] "row_number"             "evidence_text"          "instance_of"           
#> [4] "instance_of_range"      "instance_of_definition"