jevrecipes

Recipe catalog / text-block-role

Identify a text block’s structure

text-block-role is a Jev recipe from the jev-recipes TypeScript package. Is extracted text a heading, body paragraph, list item, code, table, caption, formula, or other block? Use it when you have already extracted a text block but its structural markup is missing.

Last updated .

Explore this recipe interactively · Source and implementation guide · Markdown version

How do I use text-block-role in TypeScript?

Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.

import { textBlockRole } from 'jev-recipes/text-block-role';

const result = await textBlockRole({
  "text": "Installation",
  "after": "Run npm install to add the package.",
  "minConfidence": 0.8
});
console.log(result);

What input does text-block-role take?

FieldTypeNeeded
textstringRequired
beforestringOptional
afterstringOptional
contextstringOptional
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "text": {
        "type": "string"
      },
      "before": {
        "type": "string"
      },
      "after": {
        "type": "string"
      },
      "context": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "text"
    ]
  },
  "result": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "usage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "status": {
        "type": "string",
        "enum": [
          "ready",
          "review"
        ]
      },
      "verdict": {
        "type": "string",
        "enum": [
          "heading",
          "body",
          "list_item",
          "code",
          "table",
          "caption",
          "formula",
          "other",
          "unclear"
        ]
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "probabilities": {
        "type": "object",
        "propertyNames": {
          "type": "string",
          "enum": [
            "heading",
            "body",
            "list_item",
            "code",
            "table",
            "caption",
            "formula",
            "other",
            "unclear"
          ]
        },
        "additionalProperties": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "required": [
          "heading",
          "body",
          "list_item",
          "code",
          "table",
          "caption",
          "formula",
          "other",
          "unclear"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "verdict",
      "confidence",
      "probabilities"
    ],
    "additionalProperties": false
  }
}

What does a text-block-role result look like?

This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo text-block-role.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "verdict": "heading",
  "confidence": 0.94,
  "probabilities": {
    "heading": 0.94,
    "body": 0.04,
    "list_item": 0,
    "code": 0,
    "table": 0,
    "caption": 0,
    "formula": 0,
    "other": 0,
    "unclear": 0.02
  }
}

Input

See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas. before and after and context are optional and are omitted from the request when absent.

Result

Returns a suggested structural verdict, probabilities, and ready or review status. Unclear always requires review.

Reuse and calls

Uses the shared choice helper for the Jev call and response parsing. This folder owns its question, verdict criteria, and review policy. A live invocation makes one logical Jev request.

Limits

The caller supplies ordered, retained text and owns native tags, extraction, offsets, and rendering. This recipe never deletes or rewrites a block. Experimental: the fixture demonstrates the contract, not accuracy.

Example input

demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo text-block-role shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe text-block-role to inspect the input and result schemas.

Measured accuracy

The public evaluation corpus and reproducible transformations are described in the evaluation guide. The ingestion example preserves original text and offsets while returning a proposal.

How accurate is text-block-role?

Current public-dataset measurement

jev-1.13.0 / 2026-10-04 / 126 development cases

Scoring revision 2.

83%All-case accuracy
34Sent for review
0Failed calls / cases

92 ready decisions, with 97% accuracy among those decisions.

95% case-level interval: 75% to 88%. Related synthetic cases are correlated.

This measures the recorded dataset, not general readiness. Label sources: public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/assert.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/child_process.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/crypto.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/diagnostics_channel.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/dns.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/errors.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/process.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/repl.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/timers.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/tls.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/util.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/vm.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/wasi.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.; public-dataset: https://raw.githubusercontent.com/nodejs/node/v22.20.0/doc/api/webcrypto.md; source Markdown labels, transformed by build-ingestion-cases.mjs; no independent human review; Node.js MIT license.

Use the evaluation guide to measure this decision on your own labeled cases.

What are the limits of text-block-role?