Package 'betwixt'

Title: Scoped Semantic Claims and Human Review Workflows
Description: Provides a lightweight framework for constructing, reviewing, and documenting candidate semantic claims in tabular data. Candidate claims can be organised into bounded review tasks and presented through configurable human review interfaces. Review decisions, states, and provenance can be recorded while keeping the semantic representation independent of a particular review interface.
Authors: Daniel Antal [aut, cre] (ORCID: <https://orcid.org/0000-0001-7513-6760>)
Maintainer: Daniel Antal <[email protected]>
License: GPL (>= 3)
Version: 0.0.8002
Built: 2026-12-02 11:32:24 UTC
Source: https://github.com/dataobservatory-eu/betwixt

Help Index


Add a candidate column to a Betwixt candidate dataset

Description

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_.

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).

Value

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

Special candidate-range values

Candidate ranges may contain reserved tokens that have special meanings in the review interface:

⁠<other>⁠

Allows the reviewer to enter a value not included in the proposed candidate range. For backward compatibility, ⁠Other…⁠ (Unicode ellipsis) and Other... (three periods) are also recognised.

⁠<unknown>⁠

Indicates that an applicable value may exist, but its value is unknown.

⁠<no-value>⁠

Indicates that no applicable value is possible.

Reserved tokens are recognised only when they appear as complete range entries. Ordinary strings such as Other, Unknown, and None retain their literal meanings.

Special values are optional and are not automatically appended to candidate ranges.

Examples

candidates <- tibble::tibble(
  row_id = 1:2,
  input_description = 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)

Create a Betwixt candidate range

Description

Creates the canonical pipe-delimited representation of a candidate value range used in Betwixt semantic review.

Values may be supplied as a character vector or as one or more pipe-delimited character strings. Whitespace surrounding values is removed.

Candidate ranges may include ordinary values and reserved special values that control how the reviewer can respond to a semantic assertion.

Usage

add_candidate_range(...)

Arguments

...

Character values defining the candidate range.

Details

Candidate ranges define the values offered to a reviewer when examining a semantic assertion. The values are preserved in their supplied order.

The function combines the supplied values into a single pipe-delimited string. It does not validate their semantic meaning, resolve entities, or interpret special values.

Value

A single pipe-delimited character string. If no values are supplied, NA_character_ is returned.

Special candidate-range values

Betwixt recognises the following reserved values in candidate ranges:

⁠<other>⁠

Allows the reviewer to enter a value outside the proposed candidate range. Displayed as ⁠Other [curator entered]⁠.

⁠<unknown>⁠

Indicates that an applicable value may exist, but its value is unknown. Displayed as ⁠Value unknown⁠.

⁠<no-value>⁠

Indicates that no applicable value is possible. Displayed as ⁠No value possible⁠.

⁠Other…⁠ (Unicode ellipsis) and Other... (three periods) are also recognised as equivalents of ⁠<other>⁠.

The distinction between these values is semantic:

  • ⁠<other>⁠ requests a curator-entered replacement value.

  • ⁠<unknown>⁠ expresses uncertainty about an applicable value.

  • ⁠<no-value>⁠ expresses the absence of an applicable value.

Ordinary strings such as Other, Unknown, and None retain their literal meanings and are not interpreted as reserved values.

Special values are optional and must be explicitly included in the candidate range. They are not automatically appended.

add_candidate_range() preserves the supplied tokens. Their special behaviour is applied when the candidate range is rendered in the Betwixt review interface.

Examples

# Ordinary candidate ranges
add_candidate_range("depicts", "documents")
add_candidate_range(c("depicts", "documents"))
add_candidate_range("depicts|documents")
add_candidate_range("depicts | documents")

# Allow a curator to enter another value
add_candidate_range("Spreading", "Debunking", "<other>")

# Allow explicit uncertainty or absence of an applicable value
add_candidate_range("Farmhouse", "Dwelling", "<unknown>", "<no-value>")

# Combine ordinary and special values
add_candidate_range(
  "Spreading", "Debunking", "Discussing",
  "<other>", "<unknown>", "<no-value>"
)

Identify a Betwixt representation

Description

Identifies whether a Betwixt table uses wide, dual-wide, long, or dual-long representation. It returns "invalid" for tables that cannot be identified as a valid Betwixt representation.

Usage

betwixt_representation(x)

Arguments

x

A data frame representing a Betwixt table.

Value

One of "wide", "dual_wide", "long", "dual_long", or "invalid".

Examples

x <- data.frame(
  row_id = 1:2,
  subject = c("Q1", "Q2"),
  instance_of = c("human", "human"),
  occupation = c("composer", "pianist")
)

betwixt_representation(x)
# "wide"

Construct a Betwixt candidate dataset

Description

Constructs an initial wide-form candidate dataset for a Betwixt review. Each row associates an input with a subject and provides the information required to present candidate semantic assertions for review.

The subject forms the first reviewable candidate column. Additional reviewable columns can subsequently be appended with add_candidate_column().

An optional input predicate can express a candidate semantic relation between the input and the subject, for example "depicts" or "documents". When supplied, this relation is itself reviewable.

Usage

create_candidate_dataset(
  subject,
  input_url = NA_character_,
  input_media_url = NA_character_,
  input_label = NA_character_,
  input_description = NA_character_,
  label = NA_character_,
  description = NA_character_,
  alternative_label = NA_character_,
  alternative_description = NA_character_,
  input_predicate = NULL,
  input_predicate_range = NA_character_,
  subject_range = NA_character_,
  subject_definition = NA_character_,
  data_manager_name = "",
  data_manager_iri = "",
  data_manager_email = "",
  table_id = "",
  project_id = "",
  table_iri = ""
)

Arguments

subject

A vector containing the subject identifiers or values to be reviewed. The subject is stored in the subject column.

input_url

An optional character vector containing URLs or other resolvable locations of input resources that can be opened by the reviewer.

input_media_url

An optional character vector containing URLs or other resolvable locations of media that can be presented directly to the reviewer.

input_label

An optional character vector containing short human-readable labels identifying the inputs.

input_description

An optional character vector containing human-readable descriptions of the inputs.

label

An optional character vector containing human-readable labels for the subjects presented for review.

description

An optional character vector containing human-readable descriptions of the subjects presented for review.

alternative_label

An optional character vector containing alternative human-readable labels for the subjects presented for review, for example a translation or a label intended for a different user group.

alternative_description

An optional character vector containing alternative human-readable descriptions of the subjects presented for review, for example a translation, a more detailed description, or a description intended for a different user group.

input_predicate

An optional character vector expressing a candidate semantic relation from the input to the subject, for example "depicts" or "documents". If NULL, no input-predicate candidate columns are added. Defaults to NULL.

input_predicate_range

An optional character vector containing the admissible or suggested values for input_predicate. Use add_candidate_range() to construct controlled ranges. This argument can only be used when input_predicate is supplied. Defaults to NA_character_.

subject_range

A character vector containing the admissible or suggested subject values. Use add_candidate_range() to construct controlled ranges, or NA_character_ when no controlled range is supplied. Defaults to NA_character_.

subject_definition

A character vector containing resolvable identifiers or URLs defining the proposed subject. A supplied definition indicates that the subject already exists as an identified entity; NA_character_ indicates an unresolved candidate subject. Defaults to NA_character_.

data_manager_name

Character string containing the name of the person responsible for preparing the candidate dataset.

data_manager_iri

Character string containing an IRI identifying the data manager, such as an ORCID, ISNI, or Wikidata URI.

data_manager_email

Character string containing the data manager's email address.

table_id

Character string identifying the table within a project. The identifier is local to the project and need not be an IRI.

project_id

Character string identifying the larger knowledge-production project within which the table is created and reviewed. The optional project_id can help identify and relate tables belonging to the same project.

table_iri

Optional absolute IRI identifying the logical Betwixt table across its successive states and representations. The IRI may resolve to the latest published state, while historical states can be retained as separately identified versions. Defaults to "".

Details

create_candidate_dataset() establishes the initial structure of a Betwixt candidate dataset. row_id is generated automatically as an integer sequence in input order.

Input columns describe or identify the serialised artefact supplied to the review process. They are distinct from the subject and from the semantic assertions proposed about that subject. An input may be a document, image, dataset, web resource, or another serialised artefact from which candidate assertions have been generated.

input_label and input_description are separate semantic fields. Renderers may choose to present them together, but their distinction is preserved in the candidate dataset.

When input_predicate is supplied, it expresses a candidate relation directed from the input to the subject:

input -- input_predicate --> subject

The input predicate is therefore distinct from review provenance. It is a candidate domain assertion and can itself be accepted, rejected, deferred, or otherwise reviewed.

The subject, its candidate range, and its definition follow the same candidate-column contract used by add_candidate_column() for subsequent reviewable assertions.

Additional reviewable assertions can be appended with add_candidate_column(). Display-only contextual information can be added as ⁠context_*⁠ columns using ordinary data manipulation functions such as dplyr::mutate().

Dataset-level provenance is stored in the provenance attribute rather than repeated across observation rows. The generation timestamp is recorded as an ISO 8601 UTC value at one-second precision. The software agent and installed Betwixt package version are recorded automatically.

At least one of input_media_url or input_url must be supplied for each row.

Value

A tibble representing the initial Betwixt candidate dataset, with one row per input-subject observation. The table contains structural coordinates, input information, subject presentation information, and the candidate subject assertion.

The core columns are row_id, input_url, input_media_url, input_label, input_description, label, description, alternative_label, alternative_description, subject, subject_range, and subject_definition.

If input_predicate is supplied, the tibble additionally contains input_predicate and input_predicate_range.

See Also

create_candidate_template()

Examples

# Candidate dataset without a reviewable input predicate
delini_candidates <- create_candidate_dataset(
  input_media_url = delini$input_media_url,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject = delini$subject,
  subject_range = delini$subject_range,
  subject_definition = delini$subject_definition
)

delini_candidates

# Candidate dataset with a reviewable input predicate
delini_dual_candidates <- create_candidate_dataset(
  input_media_url = delini$input_media_url,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject = delini$subject,
  subject_definition = delini$subject_definition,
  input_predicate = rep("depicts", nrow(delini)),
  input_predicate_range = rep(
    add_candidate_range("depicts", "documents", "Other…"),
    nrow(delini)
  )
)

delini_dual_candidates

# Statistical example based on the W3C RDF Data Cube Vocabulary
w3c_candidates <- create_candidate_dataset(
  input_url = rep(
    "https://www.w3.org/TR/vocab-data-cube/",
    nrow(w3c_life_expectancy)
  ),
  input_label = rep(
    "W3C RDF Data Cube Vocabulary",
    nrow(w3c_life_expectancy)
  ),
  label = w3c_life_expectancy$observation,
  description = paste(
    "Life expectancy observation for",
    w3c_life_expectancy$area
  ),
  subject = w3c_life_expectancy$observation
)

w3c_candidates <- w3c_candidates |>
  add_candidate_column(
    name = "area",
    value = w3c_life_expectancy$area
  ) |>
  add_candidate_column(
    name = "period",
    value = w3c_life_expectancy$period
  ) |>
  add_candidate_column(
    name = "sex",
    value = w3c_life_expectancy$sex
  ) |>
  add_candidate_column(
    name = "life_expectancy",
    value = w3c_life_expectancy$life_expectancy
  )

w3c_candidates

Create a Betwixt candidate template

Description

Creates a candidate dataset template for preparing a Betwixt review. Standard descriptive and evidence columns can be included or omitted. Additional reviewable columns are specified through columns, while display-only contextual columns are specified through context.

Usage

create_candidate_template(
  input_url = TRUE,
  input_media_url = TRUE,
  input_label = TRUE,
  input_description = TRUE,
  label = TRUE,
  description = TRUE,
  alternative_label = FALSE,
  alternative_description = FALSE,
  input_predicate = FALSE,
  subject_range = TRUE,
  subject_definition = TRUE,
  columns = NULL,
  context = NULL,
  n = 0
)

Arguments

input_url

Include the input_url column.

input_media_url

Include the input_media_url column.

input_label

Include input_label for short human-readable labels identifying the inputs.

input_description

Include input_description for optional human-readable descriptions of the inputs.

label

Include label for optional human-readable subject labels.

description

Include description for optional subject descriptions.

alternative_label

Include alternative_label for alternative subject labels, such as translations or labels for different audiences.

alternative_description

Include alternative_description for alternative subject descriptions.

input_predicate

Include input_predicate and input_predicate_range columns.

subject_range

Include the subject_range column.

subject_definition

Include the subject_definition column.

columns

Optional character vector naming additional reviewable candidate columns. Each creates a column with corresponding ⁠_range⁠ and ⁠_definition⁠ columns.

context

Optional character vector naming display-only contextual columns.

n

Number of rows to initialise. NULL (default) or 0 creates a header-only template; a positive whole number creates rows with sequential row_id values.

Details

By default, creates a header-only template for use in a spreadsheet application. Set n to initialise rows for programmatic population. Re-imported datasets can be checked with validate_candidate_dataset() before rendering.

Value

A data.frame containing row_id, subject, and the requested evidence, descriptive, candidate, and contextual columns. Unpopulated fields are NA.

See Also

create_candidate_dataset()

Examples

create_candidate_template()

create_candidate_template(
  n = 3,
  columns = c("instance_of", "heritage_of"),
  context = "held_by"
)

Delini cultural heritage candidate data

Description

A small cultural heritage dataset describing three artefacts and two archival records associated with the Delini farmstead at the Ethnographic Open-Air Museum of Latvia. It provides a worked example of heterogeneous semantic candidates that can be presented for human review with Betwixt.

The three artefacts are the Delini farmhouse, a tablet-woven sash, and a bed. The two archival records document the farmhouse: one contains photographs of it, while the other is a floor plan prepared for its reconstruction.

Each row associates an evidential resource with a described entity and candidate semantic values. Candidate values are accompanied, where applicable, by controlled ranges and semantic definitions.

Usage

delini

Format

A data frame with 5 rows and 16 variables:

row_id

Integer row identifier.

input_url

Optional URL of an evidential resource.

input_media_url

URL of the evidential media resource.

input_description

Short human-readable identifier for the evidence.

label

Human-readable label of the described entity.

description

Human-readable description of the described entity.

subject

Candidate subject identifier or value.

subject_range

Optional controlled range for the subject.

subject_definition

Optional semantic definition or resolvable reference associated with the subject.

instance_of

Candidate value for the ⁠instance of⁠ assertion.

instance_of_range

Optional controlled range for the ⁠instance of⁠ value.

instance_of_definition

Optional semantic definition associated with the ⁠instance of⁠ candidate.

heritage_of

Candidate value for the ⁠heritage of⁠ assertion.

heritage_of_range

Optional controlled range for the ⁠heritage of⁠ value.

heritage_of_definition

Optional semantic definition associated with the ⁠heritage of⁠ candidate.

context_1

Display-only holding-institution context supplied to the reviewer.

Source

Delini cultural heritage materials used in the Betwixt worked example.

Examples

data(delini)
head(delini)

Project a Betwixt review to long form

Description

Projects a Betwixt review into one row per atomic assertion in the candidate and reviewed states.

Descriptive fields are represented as assertions about the subject. Each semantic candidate column is represented as a predicate, with its cell value forming the value of the atomic assertion. Review status is inherited from the aligned wide projection.

The long projection is derived from project_review_wide() and introduces no additional review semantics.

Row-scoped ⁠context_*⁠ fields are inherited by each assertion generated from the corresponding wide row. They provide descriptive context only: they do not become assertions and do not receive review status.

Usage

project_review_long(review)

Arguments

review

A Betwixt review object returned by read_review().

Details

The long projection contains one row for each atomic assertion in both the candidate and reviewed states. The status plane supplies the review status of these assertions but does not itself generate additional long-form rows.

Value

A data frame with one row per candidate or reviewed assertion and columns assertion_number, row_id, zero or more ⁠context_*⁠ columns, plane, subject, predicate, value, status, and provenance fields.

Examples

review_html <- render_review(delini)

path <- tempfile(fileext = ".html")
writeLines(review_html, path)

review <- read_review(path)
long <- project_review_long(review)

head(long)

Project a Betwixt review to aligned wide planes

Description

Projects a Betwixt review into candidate, reviewed, and status planes while preserving the wide structure of the original review.

Usage

project_review_wide(review)

Arguments

review

A Betwixt review object returned by read_review().

Details

The candidate plane contains the assertions presented for review. The reviewed plane contains the values persisted by the reviewer. The status plane describes the review state of each reviewable field.

Semantic assertions may carry explicit defer or reject qualifications. These take precedence over states inferred from candidate and reviewed values. Descriptive fields currently use inferred review states only.

For a finalised row, an unchanged value is corroborated, a changed non-empty value is corrected, deletion of a candidate value is rejected, and an absent descriptive assertion that remains absent is deferred. Values in rows that have not been finalised are pending, unless an explicit semantic qualification applies.

Reviewable fields include descriptive fields such as label, description, alternative_label, and alternative_description, when present, together with semantic assertion fields represented by ⁠_qualification⁠ columns.

An empty reviewed descriptive value is interpreted as rejection only when the corresponding candidate value was non-empty and the row was finalised. If both candidate and reviewed descriptive values are missing in a finalised row, the assertion is interpreted as deferred rather than rejected.

Value

A data frame containing three structurally aligned wide planes, identified by the plane column as candidate, reviewed, or status. Review provenance is retained in the provenance attribute.


Read a Betwixt review

Description

Reads a standalone Betwixt review HTML file and reconstructs the original candidate state, the persisted reviewed state, review metadata, and review provenance.

Usage

read_review(path)

Arguments

path

A single character string giving the path to a standalone Betwixt review HTML file.

Details

read_review() does not finalise semantic knowledge or construct a subsequent stabilised semantic state. It reconstructs the review artefact as saved by Betwixt.

The returned candidate and reviewed data frames preserve the same evidence, descriptive, and semantic fields. The reviewed data additionally contains assertion qualifications, row finalisation state, row outcome, and optional row-level comments.

Review-wide information such as reviewer identity and IRI, lifecycle timestamps, and the review-level comment is returned separately in provenance.

The reconstructed review can be projected into assertion-oriented forms with project_review_wide() and project_review_long(). The wide projection preserves the candidate, reviewed, and status planes, while the long projection represents individual semantic assertions as subject-predicate-value records.

Betwixt review files preserve both original candidate values and the current reviewed values in machine-readable HTML attributes and controls. read_review() uses these persisted values to reconstruct the two states independently.

A finalised Betwixt review is a completed review artefact. Reading such a file does not promote reviewed assertions into a subsequent stabilised semantic state or apply them to an external knowledge system.

Value

A named list with four elements:

metadata

Review-level metadata including title, description, table_id, sequence, and status.

provenance

Review provenance including the original and saved filenames, creation and lifecycle timestamps, reviewer name, IRI and email, and the optional review-level comment.

candidate

A data frame reconstructing the candidate state presented for review. It contains row number, the fields related to the inputs, the descriptive fields, and candidate semantic assertion values.

reviewed

A data frame reconstructing the persisted reviewed state. It contains the current descriptive and semantic values, assertion qualifications, row finalisation state, row outcome, and optional row-level comments.

Empty optional fields describing the inputs and comments are returned as NA_character_. row_id is returned as integer and reviewed$finalised as logical.

Examples

## Not run: 
review <- read_review("muis-garments-review_1-finalised.html")

review$metadata
review$provenance
review$candidate
review$reviewed

## End(Not run)

Render a local HTML Betwixt review

Description

Renders a Betwixt candidate dataset as an interactive, standalone HTML review. The type argument selects between a web-based review using HTTP(S) resources and a local review using files stored alongside the generated HTML document.

Both formats preserve the original candidate values alongside editable review values. The generated HTML includes the original filename and creation timestamp as artefact provenance. Timestamps are recorded in ISO 8601 UTC format at one-second precision.

A review belongs to a project, has a filename stem, and has a non-negative sequence number. Sequence 0 represents the initial candidate review. Subsequent review states may use sequence 1, 2, and so on. Saving a draft or finalising a review does not itself change the sequence.

The project identifier identifies the larger knowledge-production project, while the table identifier identifies a table across successive review states. The filename stem independently determines the saved HTML filename.

Usage

render_local_html_review(
  candidate,
  cols = NULL,
  subheadings = NULL,
  title = "Betwixt Review",
  description = "Please review the following claims.",
  filename_stem = "betwixt-review",
  reviewer_name = "",
  reviewer_iri = "",
  table_id = "",
  table_iri = NULL,
  project_id = "",
  sequence = 0L,
  row_comment = FALSE,
  review_comment = FALSE,
  input_link_target = "blank",
  path = NULL
)

render_review(candidate, ..., type = "web_html")

render_web_html_review(
  candidate,
  cols = NULL,
  subheadings = NULL,
  title = "Betwixt Review",
  description = "Please review the following claims.",
  filename_stem = "betwixt-review",
  reviewer_name = "",
  reviewer_iri = "",
  table_id = "",
  table_iri = NULL,
  project_id = "",
  sequence = 0L,
  row_comment = FALSE,
  review_comment = FALSE,
  input_link_target = "blank",
  path = NULL
)

Arguments

candidate

A Betwixt candidate dataset.

cols

Optional named character vector containing presentation labels for candidate and context columns.

subheadings

Optional named character vector containing presentation subheadings for candidate columns.

title

Character string used as the review title.

description

Character string containing review instructions.

filename_stem

Base name for saved review files. Sequences greater than 0 append the sequence number.

reviewer_name

Initial reviewer name.

reviewer_iri

IRI identifying the reviewer, such as an ORCID, ISNI, or Wikidata URI.

table_id

Identifier of the table across successive review states.

table_iri

Optional IRI identifying the source candidate table. Candidate provenance takes precedence when present. If omitted, an IRI is generated from project_id and table_id.

project_id

Identifier of the larger knowledge-production project.

sequence

Single non-negative integer identifying the review sequence. Defaults to 0, representing the initial candidate review.

row_comment

Logical. Add an optional comment field to each review row. Defaults to FALSE.

review_comment

Logical. Add an optional comment field for the review as a whole. Defaults to FALSE.

input_link_target

How links in the Input column are opened. "blank" (default) opens resources in a new browser tab. "modal" opens resources in a popup within the review page. Does not affect semantic assertion or definition links.

path

Output directory for the generated HTML. For "web_html", NULL returns the HTML without writing a file. For "local_html", an existing directory is required to resolve local resource references.

...

Arguments passed to the selected review renderer.

type

Review format: "web_html" (default) or "local_html".

Details

The "web_html" renderer accepts HTTP(S) references in input_url and input_media_url. These references are validated syntactically without checking network availability.

The "local_html" renderer uses local resource paths, including relative references such as media/photo.jpg. Resources must already exist and be readable. Relative paths are resolved against the review output directory. The local renderer does not copy resources automatically.

Both formats embed the review CSS and JavaScript in the HTML document. Local reviews can therefore be moved together with their referenced resources without changing the relative paths.

Value

A character string containing the rendered HTML, returned invisibly when written to path.

See Also

create_candidate_dataset(), validate_candidate_dataset(), validate_external_resources(), validate_local_resources()

Examples

# Create a local review using photographs bundled with Betwixt.
data(delini)

review_path <- tempfile("delini-review-")
dir.create(file.path(review_path, "media"), recursive = TRUE)

# Resolve packaged images and copy them into the review directory.
source_media <- sub(
  "^.*?/images/delini/",
  "media/delini/",
  delini$input_media_url
)
source_files <- system.file(source_media, package = "betwixt")
stopifnot(all(nzchar(source_files)))

file.copy(source_files, file.path(review_path, "media"))

# Use relative references in the candidate dataset.
candidate <- create_candidate_dataset(
  subject = delini$subject,
  input_media_url = file.path("media", basename(source_files)),
  input_label = delini$input_label,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject_range = delini$subject_range,
  subject_definition = delini$subject_definition
)

render_local_html_review(
  candidate,
  title = "Deliņi Farmstead Review",
  filename_stem = "delini-review",
  path = review_path
)
# Review using externally hosted photographs.
data(delini)

candidates <- create_candidate_dataset(
  input_media_url = delini$input_media_url,
  input_description = delini$input_description,
  label = delini$label,
  description = delini$description,
  subject = delini$subject,
  subject_range = delini$subject_range,
  subject_definition = delini$subject_definition
)

review_html <- render_web_html_review(
  candidates,
  title = "Deliņi Farmstead Review"
)

Project a Betwixt dataset to canonical long form

Description

Projects a Betwixt candidate or reviewed dataset into the canonical assertion representation.

The projection preserves the order of rows, fields, and pipe-separated values in the supplied dataset. row_id identifies the originating wide-form tuple. assertion_id identifies the position of the assertion in the canonical long projection.

Dataset identity is represented with row_id = 0. Domain assertions, input-to-subject relations, contextual statements, and row comments are assigned distinct components.

Range and definition columns describe candidate fields and are not themselves projected as assertions. Review-state columns such as qualifications, finalisation, and outcomes are likewise not domain assertions.

Usage

review_pivot_longer(x)

Arguments

x

A Betwixt candidate or reviewed data frame.

Value

A tibble with columns row_id, assertion_id, component, subject, predicate, and value.


Serialise a Betwixt review

Description

Serialises a reviewed Betwixt dataset as RDF Turtle. The serialisation preserves the candidate and reviewed datasets, review status, provenance, and available Betwixt assertion coordinates.

Usage

serialise_review(
  review,
  prefix,
  filename,
  title = NULL,
  description = NULL,
  reviewer_iri = NULL
)

serialize_review(
  review,
  prefix,
  filename,
  title = NULL,
  description = NULL,
  reviewer_iri = NULL
)

Arguments

review

A Betwixt review object returned by read_review().

prefix

Base IRI for generated resources.

filename

Filename identifying the serialised dataset.

title

Optional dataset title.

description

Optional dataset description.

reviewer_iri

Optional persistent IRI identifying the reviewer.

Details

Each assertion is represented as a btx:Assertion. row_id is serialised as btx:rowId. When assertion_id is available, it is serialised as btx:assertionId.

Value

A character string containing RDF Turtle.

Examples

path <- system.file(
  "examples",
  "muis-garments-review_1-finalised.html",
  package = "betwixt"
)
review <- read_review(path)

ttl <- serialise_review(
  review,
  prefix = "https://usebetwixt.com/examples/",
  filename = "muis-garments-review.ttl",
  title = "MuIS garment terminology review",
  description = "Reviewed terminology assertions for three MuIS garments."
)
cat(ttl)

Small country GDP candidate dataset

Description

A small example candidate dataset containing GDP observations for Iceland and Malta in 2023 and 2024. The dataset demonstrates the Betwixt candidate-data structure using statistical data.

Usage

small_countries_dataset

Format

A data frame with 4 rows and the following variables:

row_id

Stable integer identifier for the candidate row.

input_url

Resolvable DOI of the source Eurostat dataset.

label

Human-readable label for the observation.

description

Human-readable description of the observation.

subject

Human-readable name of the country.

subject_definition

GeoNames URI identifying the country.

country_code

ISO 3166-1 alpha-2 country code.

country_code_definition

URI defining the country-code system.

gdp

Gross domestic product at market prices.

gdp_definition

URI identifying the Eurostat GDP concept B1GQ.

context_year

Reference year of the GDP observation; not reviewed.

context_unit

Unit in which GDP is expressed; not reviewed.

Source

Eurostat, National Accounts. The source dataset is identified by doi:10.2908/NAIDA_10_GDP.

Examples

small_countries_dataset
validate_candidate_dataset(small_countries_dataset)

Validate a Betwixt candidate dataset

Description

Checks the structural requirements of a Betwixt candidate dataset. Resource validation is handled separately.

Usage

validate_candidate_dataset(x)

Arguments

x

A data frame representing a Betwixt candidate dataset.

Value

Invisibly returns x if validation succeeds.

See Also

validate_local_resources(), validate_external_resources()


Validate external resources

Description

Checks that input resource references use HTTP or HTTPS URLs. Pipe-separated resource references are supported.

Usage

validate_external_resources(x)

Arguments

x

A Betwixt candidate dataset.

Value

Invisibly returns x if validation succeeds.


Validate local resources

Description

Checks that local input resources exist and are readable. Relative paths are resolved against path. Pipe-separated resource references are supported.

Usage

validate_local_resources(x, path)

Arguments

x

A Betwixt candidate dataset.

path

Directory containing the local review resources.

Value

Invisibly returns x if validation succeeds.


W3C RDF Data Cube life expectancy data

Description

A small statistical dataset based on the life expectancy example in the W3C RDF Data Cube Vocabulary specification. The observations demonstrate a multidimensional statistical use case that can be transformed into candidate data for human review with Betwixt.

The example contains male life expectancy observations for four Welsh areas during the 2004–2006 reference period.

Usage

w3c_life_expectancy

Format

A data frame with 4 rows and 5 variables:

observation

Identifier of the RDF Data Cube observation.

area

Reference area of the observation.

period

Reference period of the observation.

sex

Sex dimension of the observation.

life_expectancy

Life expectancy, measured in years.

Source

W3C RDF Data Cube Vocabulary, life expectancy example: https://www.w3.org/TR/vocab-data-cube/

References

Cyganiak, R., Reynolds, D., and Tennison, J. (2014). RDF Data Cube Vocabulary. W3C Recommendation, 16 January 2014.

Examples

data(w3c_life_expectancy)
w3c_life_expectancy