format_bioc_json()

Documents as one BioC JSON collection.

Usage

Source

format_bioc_json(
    docs,
    *,
    offset_unit="utf8",
    label_key="type",
    concept_key="identifier",
    indent=None,
    lossy="warn"
)

Annotations and relations go back where they were read from (bioc_level); everything else is placed in the passage containing its start, or at document level.

Parameters

docs: Iterable[Document]

The documents.

offset_unit: OffsetUnit = "utf8"

The unit to write offsets in (UTF-8 bytes per the specification).

label_key: str = "type"

The annotation infon for the label.

concept_key: str = "identifier"

The infon for concepts that did not come from BioC.

indent: int | None = None

JSON indentation; one line when None.

lossy: Literal["warn", "ignore"] = "warn"
"warn" once about information BioC cannot carry, or "ignore".