WP13b Refactoring ingestion und Chunker
This commit is contained in:
1 parent
cf302e8334
commit
94e5ebf577
13 files changed
+607
-762
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
FILE: app/core/chunking/chunking_propagation.py
|
||||
DESCRIPTION: Vererbung von Kanten (Inheritance) über Sektions-Pfade.
|
||||
"""
|
||||
from typing import List, Dict, Set
|
||||
from .chunking_models import Chunk, RawBlock
|
||||
from .chunking_parser import parse_edges_robust
|
||||
|
||||
def propagate_section_edges(chunks: List[Chunk], blocks: List[RawBlock]) -> List[Chunk]:
|
||||
"""WP-15b: Kanten aus Headings werden an Sub-Chunks vererbt."""
|
||||
section_inheritance: Dict[str, Set[str]] = {}
|
||||
for b in blocks:
|
||||
if b.kind == "heading":
|
||||
edges = parse_edges_robust(b.text)
|
||||
if edges:
|
||||
if b.section_path not in section_inheritance:
|
||||
section_inheritance[b.section_path] = set()
|
||||
section_inheritance[b.section_path].update(edges)
|
||||
|
||||
for ch in chunks:
|
||||
inherited = section_inheritance.get(ch.section_path, set())
|
||||
for e_str in inherited:
|
||||
kind, target = e_str.split(':', 1)
|
||||
ch.candidate_pool.append({"kind": kind, "to": target, "provenance": "inherited"})
|
||||
return chunks
|
||||
Reference in new issue
Block a user