Skip to main content

Module contracts

Module contracts 

Source
Expand description

Versioned annotation contracts and caller-buffered document views (NLP-100).

v1 ABI (honest): in-process Rust records. Views may contain &'static str interned lexicon pointers and usize counts (native pointer width). They are not a C FFI layout. #[repr(C)] is not applied to fat-pointer views. Cross-language ABI notes belong to NLP-900.

v1 span model: half-open UTF-8 byte crate::nlp::span::DocSpan on the immutable source. Distinct UTF-16 / code-point / grapheme / model-subtoken types and reversible alignment maps are NLP-101. Token layering (MWT) is NLP-103. Nested/discontinuous mention lists are NLP-405.

v1 state: AnalysisState::Complete is the only constructed success state. Other variants are reserved for later processors; they are not emitted here. Oversize input on the buffered path is NlpContractError::SourceTooLarge, not a BudgetExceeded summary.

Hot-path records borrow the immutable source through DocSpan. Owned strings stay on the cold analyze_document adapter.

Structs§

DocumentCapacities
Slot counts a caller must supply for analyze_document_into on source.
DocumentSummary
Filled counts for a successful buffered analysis.
DocumentViewBuffers
Caller-owned output slices. Overflow is a typed error; counts are not written as a successful summary when any channel is short.
HitView
Gazetteer hit; IRI and surface are interned lexicon pointers (fat pointers).
PlanView
Span plan without owned String surfaces. Interned &'static str is not C ABI.
SentenceView
Sentence borrowed from the original source. In-process Rust; not a C ABI.
TokenView
Token borrowed from the original source. In-process Rust; not a C ABI.

Enums§

AnalysisState
Typed processor outcome. Empty success is AnalysisState::Complete with zero counts; it is not an error and is not an unavailable processor.
BufferChannel
Which caller slice ran out of room.
NlpContractError
Failures for the buffered contract API. Never converted into empty success.
NormView
Date / number view. Values are fixed-width; units are interned.

Constants§

ANNOTATION_CONTRACT_VERSION
Contract schema version for these view records.
NORM_INDEX_NONE
Token with no overlapping normalized value.
SENTENCE_ID_NONE
Token with no containing sentence.

Functions§

analyze_document
Cold Vec adapter. Same year-one pipeline as analyze_document_into.
analyze_document_into
Caller-buffered year-one analysis. Source cap is crate::nlp::budget::MAX_SOURCE_BYTES.
required_capacities
Capacities for a successful analyze_document_into of source.
slice_source
Half-open UTF-8 byte span against source, or NlpContractError::SpanInvalid.