Skip to content

API Reference parrot.security.groundedness.extractors

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.security.groundedness.extractors

View source

Deterministic hard-data atom extraction for groundedness scoring.

Implements FEAT-398 spec Module 1: extract verifiable hard-data atoms (money, percent, number, date, identifier) from free text, with span de-overlap so a money hit ($1,243,500) is never double-counted as a bare number. Stdlib only (re, datetime, unicodedata).

Alias Atom

Re-exported from parrot.security.groundedness.models.Atom.

Alias AtomKind

Re-exported from parrot.security.groundedness.models.AtomKind.

Attribute DEFAULT_MIN_NUMBER_DIGITS

Function extract_atoms

Extract verifiable hard-data atoms from text.

Runs the five stdlib atom extractors in claim-priority order — money, percent, date, identifier, then number — so a value like $1,243,500 yields exactly one money atom, never a money atom plus a bare-number atom. An NFKC Unicode pre-pass is applied first so fullwidth digits/currency signs are recognized. Money/percent/number literals accept an optional leading - sign so a sign flip ("+15.3%" vs "-15.3%") is preserved rather than silently discarded.

extract_atoms(text: str, min_number_digits: int = DEFAULT_MIN_NUMBER_DIGITS) -> list[Atom]

Parameter Type Default Description
text str The source text to extract atoms from (an agent answer or a tool-result value rendered to text).
min_number_digits int DEFAULT_MIN_NUMBER_DIGITS Bare integers/decimals with fewer digit characters than this are skipped as noise. Default 4.

Returns: list[Atom] — The extracted atoms, ordered by their start offset in the NFKC-normalized text.

Attribute logger

Alias nfkc_normalize

Re-exported from parrot.security.groundedness.normalize.nfkc_normalize.

Alias normalize_date

Re-exported from parrot.security.groundedness.normalize.normalize_date.

Alias normalize_identifier

Re-exported from parrot.security.groundedness.normalize.normalize_identifier.

Alias normalize_number

Re-exported from parrot.security.groundedness.normalize.normalize_number.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally