feat(ingestion): add opt-in best-effort document admission
Freeze temporary partial-extraction admission in new uploads. Bypass manual approval, retain recognition warnings, and accept ambiguous legal references during bounded chunking. Preserve strict defaults, immutable evidence and atomic publication. Expose effective policy and safe failure categories with regression coverage.
This commit is contained in:
@@ -4,7 +4,7 @@ import re
|
||||
import unicodedata
|
||||
|
||||
from .extraction import ExtractionError, RULE, PLACEHOLDER, HEADING
|
||||
from .extraction_artifacts import validate_artifact, serialize_artifact
|
||||
from .extraction_artifacts import validate_artifact, serialize_artifact, allow_partial_extraction
|
||||
from .normalization import normalize_search_text
|
||||
from .types import ChunkDraft
|
||||
|
||||
@@ -348,7 +348,9 @@ def chunk_extraction(envelope, processing_profile, *, corpus_purpose="source_doc
|
||||
if any(PLACEHOLDER.search(b.text) for b in blocks):
|
||||
raise ExtractionError("Placeholder is not authoritative knowledge")
|
||||
chunks = []
|
||||
for group, blocks, atomic in associate_dependencies(units):
|
||||
# Temporary admission keeps source order without rejecting ambiguous legal references.
|
||||
associated = units if allow_partial_extraction(profile) else associate_dependencies(units)
|
||||
for group, blocks, atomic in associated:
|
||||
parts = []
|
||||
for index, block in enumerate(blocks):
|
||||
if (index and not blocks[index - 1].text.endswith(("\n", "\r"))
|
||||
@@ -370,7 +372,7 @@ def chunk_extraction(envelope, processing_profile, *, corpus_purpose="source_doc
|
||||
r"تبصره|استثنا|مگر|مشروط|به\s+شرط|نمی|نباید|نیست|"
|
||||
r"\b(?:except|unless|provided|condition|not|exclusion|note)\b", text, re.I))
|
||||
normalized = normalize_search_text(text, profile["normalizer"])
|
||||
if protected and len(normalized) > size:
|
||||
if protected and len(normalized) > size and not allow_partial_extraction(profile):
|
||||
raise ExtractionError("Semantic group exceeds chunk bound; cannot separate required context")
|
||||
if len(normalized) <= size:
|
||||
chunks.append(ChunkDraft(len(chunks), text, page, section))
|
||||
|
||||
Reference in New Issue
Block a user