Implement Stage Learning Goal Features in Planning Exercise
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m13s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m13s
- Added `semantic_brief_for_stage` function to enhance semantic briefs with stage learning goals for improved roadmap matching. - Introduced `exercise_passes_stage_learning_goal_gate` to validate exercises against stage learning goals, enhancing relevance checks. - Updated path retrieval and scoring logic to incorporate stage learning goals, allowing for more nuanced exercise selection. - Enhanced UI to indicate weak matches with stage learning goals, improving user feedback on exercise relevance. - Incremented application version to reflect these updates.
This commit is contained in:
1 parent
48d51c07c5
commit
18547613ea
8 files changed
+339
-44
No files matched your search
@@ -604,6 +604,103 @@ def apply_path_retrieval_weights(brief: PlanningSemanticBrief) -> Dict[str, floa
|
||||
}
|
||||
|
||||
|
||||
_STAGE_GOAL_STOPWORDS = _QUERY_STOPWORDS | frozenset(
|
||||
{
|
||||
"stufe",
|
||||
"phase",
|
||||
"lernziel",
|
||||
"grundlage",
|
||||
"vertiefung",
|
||||
"anwendung",
|
||||
"perfektion",
|
||||
"einstieg",
|
||||
"sicher",
|
||||
"sauber",
|
||||
"korrekt",
|
||||
"technik",
|
||||
"training",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _significant_stage_tokens(learning_goal: str) -> List[str]:
|
||||
"""Wörter aus Stufen-Lernziel für Text-Match (ohne Füllwörter)."""
|
||||
raw = re.findall(r"[a-zäöüß]{4,}", _normalize_phrase(learning_goal), flags=re.IGNORECASE)
|
||||
out: List[str] = []
|
||||
for w in raw:
|
||||
low = w.lower().replace("ä", "ae").replace("ö", "oe").replace("ü", "ue")
|
||||
if low in _STAGE_GOAL_STOPWORDS:
|
||||
continue
|
||||
if low not in out:
|
||||
out.append(low)
|
||||
return out[:10]
|
||||
|
||||
|
||||
def semantic_brief_for_stage(
|
||||
brief: PlanningSemanticBrief,
|
||||
*,
|
||||
learning_goal: str,
|
||||
phase: Optional[str] = None,
|
||||
) -> PlanningSemanticBrief:
|
||||
"""Brief um Stufen-Lernziel erweitern — für Roadmap-Match pro Major Step."""
|
||||
lg = _normalize_phrase(learning_goal)
|
||||
if not lg:
|
||||
return brief
|
||||
must = list(brief.must_phrases or [])
|
||||
if lg not in must:
|
||||
must.insert(0, lg[:120])
|
||||
arc = list(brief.development_arc or [])
|
||||
ph = (phase or "").strip().lower()
|
||||
if ph and ph not in arc:
|
||||
arc = [ph, *arc]
|
||||
strength = max(float(brief.semantic_strength or 0.0), 0.58)
|
||||
return brief.model_copy(
|
||||
update={
|
||||
"must_phrases": must[:12],
|
||||
"development_arc": arc[:8],
|
||||
"semantic_strength": min(1.0, strength),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def exercise_passes_stage_learning_goal_gate(
|
||||
*,
|
||||
learning_goal: str,
|
||||
title: str,
|
||||
summary: str = "",
|
||||
goal: str = "",
|
||||
semantic_score: float = 0.0,
|
||||
min_semantic: float = 0.20,
|
||||
relaxed: bool = False,
|
||||
) -> bool:
|
||||
"""Roadmap-Stufe: Übung muss zum Stufen-Lernziel passen, nicht nur zum Gesamtthema."""
|
||||
lg = (learning_goal or "").strip()
|
||||
if len(lg) < 3:
|
||||
return True
|
||||
|
||||
blob = _blob_from_fields(title, summary, goal, [])
|
||||
norm_lg = _normalize_phrase(lg)
|
||||
if _phrase_in_blob(norm_lg, blob):
|
||||
return True
|
||||
|
||||
tokens = _significant_stage_tokens(lg)
|
||||
if not tokens:
|
||||
threshold = 0.12 if relaxed else min_semantic
|
||||
return semantic_score >= threshold
|
||||
|
||||
hits = sum(1 for t in tokens if _phrase_in_blob(t, blob))
|
||||
if len(tokens) <= 2:
|
||||
required = 1
|
||||
else:
|
||||
required = max(2, (len(tokens) + 1) // 2)
|
||||
|
||||
if hits >= required:
|
||||
return True
|
||||
|
||||
threshold = 0.14 if relaxed else min_semantic
|
||||
return semantic_score >= threshold
|
||||
|
||||
|
||||
def exercise_passes_path_semantic_gate(
|
||||
*,
|
||||
semantic_score: float,
|
||||
@@ -641,11 +738,15 @@ def pick_best_path_hit(
|
||||
used_exercise_ids: Set[int],
|
||||
*,
|
||||
semantic_brief: Optional[PlanningSemanticBrief] = None,
|
||||
stage_learning_goal: Optional[str] = None,
|
||||
roadmap_stage_match: bool = False,
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""Gestufte Auswahl: strikt → relaxed → bester Semantik-Score."""
|
||||
"""Gestufte Auswahl: strikt → relaxed → optional Notfall-Fallback."""
|
||||
if not hits:
|
||||
return None
|
||||
|
||||
stage_goal = (stage_learning_goal or "").strip()
|
||||
|
||||
def _scan(*, strict: bool) -> Optional[Dict[str, Any]]:
|
||||
best: Optional[Dict[str, Any]] = None
|
||||
best_key: Tuple[float, float] = (-1.0, -1.0)
|
||||
@@ -654,15 +755,25 @@ def pick_best_path_hit(
|
||||
if eid in used_exercise_ids:
|
||||
continue
|
||||
sem = float(hit.get("semantic_score") or 0.0)
|
||||
title = str(hit.get("title") or "")
|
||||
summary = str(hit.get("summary") or "")
|
||||
if semantic_brief and not exercise_passes_path_semantic_gate(
|
||||
semantic_score=sem,
|
||||
title=str(hit.get("title") or ""),
|
||||
summary=str(hit.get("summary") or ""),
|
||||
title=title,
|
||||
summary=summary,
|
||||
goal="",
|
||||
brief=semantic_brief,
|
||||
strict=strict,
|
||||
):
|
||||
continue
|
||||
if stage_goal and not exercise_passes_stage_learning_goal_gate(
|
||||
learning_goal=stage_goal,
|
||||
title=title,
|
||||
summary=summary,
|
||||
semantic_score=sem,
|
||||
relaxed=not strict,
|
||||
):
|
||||
continue
|
||||
score = float(hit.get("score") or 0.0)
|
||||
key = (sem, score)
|
||||
if key > best_key:
|
||||
@@ -677,7 +788,10 @@ def pick_best_path_hit(
|
||||
if chosen:
|
||||
return chosen
|
||||
|
||||
# Notfall: bester verbleibender Treffer mit Semantik > 0 (Thema trotzdem priorisieren)
|
||||
if roadmap_stage_match:
|
||||
return None
|
||||
|
||||
# Notfall (nur retrieval-first / Brücken): bester verbleibender Treffer
|
||||
fallback: Optional[Dict[str, Any]] = None
|
||||
fallback_key: Tuple[float, float] = (-1.0, -1.0)
|
||||
for hit in hits:
|
||||
@@ -706,8 +820,10 @@ __all__ = [
|
||||
"build_semantic_brief",
|
||||
"enrich_target_with_semantic_expectations",
|
||||
"exercise_passes_path_semantic_gate",
|
||||
"exercise_passes_stage_learning_goal_gate",
|
||||
"merge_semantic_brief_llm",
|
||||
"pick_best_path_hit",
|
||||
"semantic_brief_for_stage",
|
||||
"resolve_semantic_skill_weights",
|
||||
"score_exercise_semantic_relevance",
|
||||
"semantic_core_phrases",
|
||||
|
||||
Reference in new issue
Block a user