{
"event": "PreToolUse",
"tool_name": "Read",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Docs\/HybridSearchService.php",
"offset": 270,
"limit": 100
}
}
{
"tool_response": {
"type": "text",
"file": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Docs\/HybridSearchService.php",
"content": "\n \/\/ Keyword matching boost\n foreach ($result['keywords'] as $kw) {\n foreach ($queryWords as $w) {\n if (stripos($kw, $w) !== false) {\n $boost += 0.05;\n }\n }\n }\n\n \/\/ Entity matching boost\n foreach ($result['entities'] as $e) {\n if (isset($e['name'])) {\n foreach ($queryWords as $w) {\n if (stripos($e['name'], $w) !== false) {\n $boost += 0.03;\n }\n }\n }\n }\n\n \/\/ Title matching boost\n foreach ($queryWords as $w) {\n if (stripos($result['title'], $w) !== false) {\n $boost += 0.1;\n }\n }\n\n \/\/ Semantic boost based on discourse role\n $discourseRole = $result['discourse_role'] ?? null;\n if ($isDefinitionQuery && $discourseRole === 'definition') {\n $boost += 0.15; \/\/ Strong boost for definitions when asking \"was ist\"\n } elseif ($discourseRole === 'thesis') {\n $boost += 0.08; \/\/ Thesis statements are valuable\n } elseif ($discourseRole === 'evidence') {\n $boost += 0.05; \/\/ Evidence supports claims\n }\n\n \/\/ Intent boost - explanations are generally more useful\n $intent = $result['intent'] ?? null;\n if ($intent === 'explain' || $intent === 'define') {\n $boost += 0.05;\n }\n\n $result['relevance_score'] = min(1.0, $result['score'] + $boost);\n }\n\n usort($results, static fn (array $a, array $b): int => $b['relevance_score'] <=> $a['relevance_score']);\n\n return $results;\n }\n\n \/** Detects if query is asking for a definition. *\/\n private function isDefinitionQuery(string $query): bool\n {\n $patterns = [\n '\/^was\\s+ist\\b\/i',\n '\/^was\\s+sind\\b\/i',\n '\/^was\\s+bedeutet\\b\/i',\n '\/^definition\\b\/i',\n '\/^erkl[äa]r\/i',\n '\/^beschreib\/i',\n ];\n\n foreach ($patterns as $pattern) {\n if (preg_match($pattern, $query)) {\n return true;\n }\n }\n\n return false;\n }\n\n \/** Gets chunk with document data. *\/\n private function getChunkWithDocument(int $chunkId): ?array\n {\n $stmt = $this->pdo->prepare('\n SELECT c.*, d.title as doc_title, d.path as doc_path\n FROM dokumentation_chunks c\n JOIN dokumentation d ON c.dokumentation_id = d.id\n WHERE c.id = :id\n ');\n $stmt->execute(['id' => $chunkId]);\n $result = $stmt->fetch(PDO::FETCH_ASSOC);\n\n return $result !== false ? $result : null;\n }\n}\n",
"numLines": 89,
"startLine": 270,
"totalLines": 358
}
}
}