fastrag.normalization#
Extensible source-preserving normalization separate from ingestion parsers.
Classes
|
Instance-local format routing with lazily constructed built-in adapters. |
Conservative whole-source text block without MIME sniffing. |
- class fastrag.normalization.CoverageUnit(id, node_id, span)[source]#
Bases:
objectA nonoverlapping retained source interval owned by a structural node.
- Parameters:
id (str)
node_id (str)
span (SourceSpan)
- class fastrag.normalization.Diagnostic(code, message, span=None)[source]#
Bases:
objectStable normalization diagnostic; no timing or secret values.
- Parameters:
code (str)
message (str)
span (SourceSpan | None)
- class fastrag.normalization.Exclusion(span, reason)[source]#
Bases:
objectExplicitly omitted source with the policy reason.
- Parameters:
span (SourceSpan)
reason (str)
- class fastrag.normalization.HtmlNormalizer(*, exclude_tags=('script', 'style'), exclude_hidden=False)[source]#
Bases:
objectRecover HTML while retaining tabs and explicitly recording exclusions.
- class fastrag.normalization.MarkdownNormalizer(*, tables=True)[source]#
Bases:
objectParse Markdown using markdown-it-py without rendering or execution.
- Parameters:
tables (bool)
- class fastrag.normalization.NormalizedDocument(document, source_format, roots, units, exclusions=(), diagnostics=())[source]#
Bases:
objectTree and independent exact source coverage partition.
- Parameters:
document (Document)
source_format (str)
roots (tuple[NormalizedNode, ...])
units (tuple[CoverageUnit, ...])
diagnostics (tuple[Diagnostic, ...])
- class fastrag.normalization.NormalizedNode(id, kind, content, spans, children=(), parent_id=None, level=None, title=None, metadata=<factory>)[source]#
Bases:
objectOrdered structure; content is original syntax, not rewritten prose.
- Parameters:
- class fastrag.normalization.Normalizer(*args, **kwargs)[source]#
Bases:
ProtocolInjectable format adapter with stable nonsecret cache identity.
- class fastrag.normalization.NormalizerRegistry(*, builtins=True)[source]#
Bases:
objectInstance-local format routing with lazily constructed built-in adapters.
- Parameters:
builtins (bool)
- register(content_format, adapter, *, replace=False)[source]#
Register a custom adapter; duplicates require explicit replacement.
- Parameters:
content_format (str)
adapter (Normalizer)
replace (bool)
- Return type:
None
- property formats: frozenset[str]#
Registered representations, without loading optional dependencies.
- adapter(content_format)[source]#
Resolve one adapter, with actionable dependency/unknown-format errors.
- Parameters:
content_format (str)
- Return type:
- class fastrag.normalization.RstNormalizer[source]#
Bases:
objectUse the RST parser directly with local/remote file insertion disabled.
- class fastrag.normalization.SourceSpan(start_offset, end_offset)[source]#
Bases:
objectHalf-open Unicode offsets into the original Document content.
- class fastrag.normalization.TextNormalizer[source]#
Bases:
objectConservative whole-source text block without MIME sniffing.
- identity = 'text:original:v1'#
Modules
HTML structural normalization with precise source policy exclusions. |
|
CommonMark with pipe tables, exact block source, and inline metadata. |
|
Source-preserving structural models independent of ingestion and packing. |
|
Safe Docutils structural adapter retaining unsupported directive source. |