This commit is contained in:
Lars 2025-12-12 10:30:38 +01:00
parent 69617802c3
commit a2856bfe87

View File

@ -14,7 +14,6 @@ import logging
try: try:
from app.services.semantic_analyzer import SemanticAnalyzer, SemanticChunkResult from app.services.semantic_analyzer import SemanticAnalyzer, SemanticChunkResult
except ImportError: except ImportError:
# Fallback für Tests, wenn der Service noch nicht auf dem Pfad ist
print("WARNUNG: SemanticAnalyzer Service nicht gefunden.") print("WARNUNG: SemanticAnalyzer Service nicht gefunden.")
class SemanticAnalyzer: class SemanticAnalyzer:
async def analyze_and_chunk(self, text, type): return [SemanticChunkResult(content=text, suggested_edges=[])] async def analyze_and_chunk(self, text, type): return [SemanticChunkResult(content=text, suggested_edges=[])]
@ -80,19 +79,12 @@ def get_sizes(note_type: str):
# 3. DATA CLASSES & HELPERS # 3. DATA CLASSES & HELPERS
# ========================================== # ==========================================
_SENT_SPLIT = re.compile(r'(?<=[.!?])\s+(?=[A-ZÄÖÜ0-9„(])') _SENT_SPLIT = re.compile(r'(?<=[.!?])\s+(?=[A-ZÄÖÜ0-9„(])'); _WS = re.compile(r'\s+')
_WS = re.compile(r'\s+')
def estimate_tokens(text: str) -> int: def estimate_tokens(text: str) -> int:
t = len(text.strip()); return max(1, math.ceil(t / 4)) t = len(text.strip()); return max(1, math.ceil(t / 4))
# FIX: Kurzschreibweise aufgelöst, um Linter-Fehler zu vermeiden
def split_sentences(text: str) -> list[str]: def split_sentences(text: str) -> list[str]:
text = _WS.sub(' ', text.strip()) text = _WS.sub(' ', text.strip())
if not text: return []
if not text:
return []
parts = _SENT_SPLIT.split(text) parts = _SENT_SPLIT.split(text)
return [p.strip() for p in parts if p.strip()] return [p.strip() for p in parts if p.strip()]
@ -215,10 +207,11 @@ def _extract_all_edges_from_md(md_text: str, note_id: str, note_type: str) -> Li
Ruft die Edge-Derivation auf Note-Ebene auf und gibt die Kanten im Format "kind:Target" zurück. Ruft die Edge-Derivation auf Note-Ebene auf und gibt die Kanten im Format "kind:Target" zurück.
""" """
# Korrigierte Argumentreihenfolge (Positionale und Keyword-Argumente getrennt)
raw_edges: List[Dict] = build_edges_for_note( raw_edges: List[Dict] = build_edges_for_note(
md_text, md_text,
note_id, note_id=note_id,
note_type, note_type=note_type,
chunks=[], chunks=[],
note_level_references=[], note_level_references=[],
include_note_scope_refs=False include_note_scope_refs=False
@ -262,7 +255,7 @@ async def _strategy_smart_edge_allocation(md_text: str, config: Dict, note_id: s
task = analyzer.analyze_and_chunk( task = analyzer.analyze_and_chunk(
text=chunk.text, text=chunk.text,
source_type=note_type, source_type=note_type,
all_note_edges=all_note_edges_list, # all_note_edges und target_type_resolver werden im SemanticAnalyzer benötigt
) )
llm_tasks.append(task) llm_tasks.append(task)