format_conll()

One document as CoNLL lines (ending with a blank line).

Usage

Source

format_conll(
    doc,
    *,
    scheme="bio",
    tokenizer=regex_tokenizer,
    alignment="strict",
    on_conflict="raise",
    on_unrepresentable="raise",
    lossy="warn"
)

Tokens and sentences come from the document’s token and sentence segments when present; otherwise tokenizer splits the text and the document is one sentence.

Parameters

doc: Document

The document.

scheme: Scheme = "bio"

The tag scheme to write.

tokenizer: Tokenizer = regex_tokenizer

text -> (start, end) token spans, used without token segments.

alignment: Alignment = "strict"

An entity boundary inside a token: "strict" raises, "expand" takes the whole token, "contract" drops the partial token (both warn).

on_conflict: OnConflict = "raise"

Entities sharing a token: "raise", keep the "outermost" or "innermost", or "skip" every entity involved (all but raise warn).

on_unrepresentable: OnUnrepresentable = "raise"

Discontinuous, unlabelled or sentence-crossing entities: "raise", "first" span, "hull", "split" into one entity per span, or "skip" (all but raise warn; entities with label problems are skipped).

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