{
"event": "PostToolUse",
"tool_name": "Read",
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/scripts\/pipeline\/chunk.py",
"content": "\"\"\"\nSemantic chunking for KI-System Pipeline\nSplits documents into meaningful chunks preserving hierarchy.\n\"\"\"\n\nimport re\n\nfrom config import CHUNK_OVERLAP_PERCENT, MAX_CHUNK_SIZE, MIN_CHUNK_SIZE\n\n\ndef split_into_sentences(text):\n \"\"\"Split text into sentences.\"\"\"\n # German-aware sentence splitting\n pattern = r\"(?<=[.!?])\\s+(?=[A-ZÄÖÜ])\"\n sentences = re.split(pattern, text)\n return [s.strip() for s in sentences if s.strip()]\n\n\ndef calculate_overlap(chunk_size):\n \"\"\"Calculate overlap size based on chunk size.\"\"\"\n return int(chunk_size * CHUNK_OVERLAP_PERCENT \/ 100)\n\n\ndef chunk_by_structure(extraction_result):\n \"\"\"\n Chunk document based on its structure.\n Preserves heading hierarchy in metadata.\n \"\"\"\n chunks = []\n file_type = extraction_result[\"file_type\"]",
"numLines": 30,
"startLine": 1,
"totalLines": 408
}
}
}