Cuts the bundled example document (gr_example()) with one registered
segmenter and reports which rules of the segmenter contract it breaks.
Nothing is refused: a segmenter that fails a rule stays registered and runs
as before. Use it on a segmenter of your own after
gr_register_segmenter().
Arguments
- segmenter
A registered segmenter's name; see
gr_segmenters().- client
A
gr_clientto read with.NULL(the default) uses agr_mock_client()whose reply to a request with a JSON schema is an object of that schema's shape, and a fixed sentence otherwise.
Value
An hr_conformance data frame; see hr_check_module().
Details
The spec is gr_segment_spec(method = segmenter, max_tokens = 150, context_source = "llm"), so contextual writes its context lines with
the model. A client you pass is used whatever the segmenter declares, so
calls_declared sees every call it makes with one. With none, a
segmenter that needs a client, or declares calls, is given the offline one.
Rules
is_function,runsThe segmenter's
fnis a function, andgr_segment()with it finishes without an error.chunks_classIt returns a gr_chunks whose
chunksis a data frame.chunk_columnschunkshas the columns gr_chunks documents:chunk_id,text,tokens,chars,page,sectionandblock_id.chunk_textEvery chunk has text that is not blank.
chunk_idsChunk ids are unique and not
NA.within_capNo chunk the segmenter returned was over
max_tokens.gr_segment()splits an oversized chunk and records it inextra$cap_enforced, and the segmenter is reported for each one it had to split.calls_declaredThe label of every model call in the trace is covered by a stem the segmenter declared in
calls, by the rule aneffortmap is checked with.
See also
hr_check_module(), gr_check_reader(), gr_register_segmenter()
Other segmentation functions:
gr_chunk_stats(),
gr_chunks,
gr_register_segmenter(),
gr_segment(),
gr_segment_spec(),
gr_segmenters(),
new_chunks()
Examples
gr_check_segmenter("paragraph")
#> Using cached ingestion for this document + settings.
#> Segmenting with 'paragraph' (cap 150 tokens, overlap 0).
#> <hr_conformance> segmenter 'paragraph', contract 0.1
#> passes all 8 rules
#> ok is_function
#> ok runs
#> ok chunks_class
#> ok chunk_columns
#> ok chunk_text
#> ok chunk_ids
#> ok within_cap
#> ok calls_declared: no model calls