Enhance chunking strategies and graph utilities for section-type transitions and block ID extraction
- Implemented WP-26 v1.1: Section-Type-Wechsel erzwingt Split auch in SMART MODE (Schritt 2) zur Verbesserung der Chunking-Logik. - Updated `parse_link_target` to extract block IDs from section strings, ensuring accurate handling of links with block references. - Added unit tests to validate section-type change behavior and block ID extraction functionality, enhancing overall reliability.
This commit is contained in:
1 parent
af3cc0a254
commit
52fdc425f7
3 files changed
+121
No files matched your search
@@ -131,6 +131,12 @@ def parse_link_target(raw: str, current_note_id: Optional[str] = None) -> Tuple[
|
||||
Trennt einen Obsidian-Link [[Target#Section]] in seine Bestandteile Target und Section.
|
||||
Behandelt Self-Links (z.B. [[#Ziele]]), indem die aktuelle note_id eingesetzt wird.
|
||||
|
||||
WP-26 v1.1: Extrahiert Block-ID aus Section-Strings.
|
||||
- Wenn Section "^block-id" enthält, wird nur der Block-ID-Teil extrahiert
|
||||
- Beispiel: "📖 Diagnose: Glioblastom ^kontext" -> section = "kontext"
|
||||
- Beispiel: "^learning" -> section = "learning"
|
||||
- Beispiel: " ^sit" (nur Block-ID) -> section = "sit"
|
||||
|
||||
Returns:
|
||||
Tuple (target_id, target_section)
|
||||
"""
|
||||
@@ -141,6 +147,16 @@ def parse_link_target(raw: str, current_note_id: Optional[str] = None) -> Tuple[
|
||||
target = parts[0].strip()
|
||||
section = parts[1].strip() if len(parts) > 1 else None
|
||||
|
||||
# WP-26 v1.1: Block-ID-Extraktion aus Section
|
||||
# Wenn die Section ein "^" enthält, extrahiere nur den Block-ID-Teil
|
||||
if section and "^" in section:
|
||||
# Finde den ^block-id Teil
|
||||
import re
|
||||
block_id_match = re.search(r'\^([a-zA-Z0-9_-]+)', section)
|
||||
if block_id_match:
|
||||
# Ersetze die gesamte Section durch nur die Block-ID
|
||||
section = block_id_match.group(1)
|
||||
|
||||
# Spezialfall: Self-Link innerhalb derselben Datei
|
||||
if not target and section and current_note_id:
|
||||
target = current_note_id
|
||||
|
||||
Reference in new issue
Block a user