feat(archivar): Origin-Priorität im Keyword-Matcher + Architekturskizzen
- room_map.py: find_room_by_keywords() prüft zuerst Ursprungsraum (Origin-First) - router.py: reicht origin_room_id an Keyword-Matcher durch - docs/keyword-matcher-origin-priority.md: Architekturskizze (Rainer) - docs/move-request-button-ux.md: Architekturskizze Button-UX (Rainer) - docs/keyword-evidence-system.md: Architekturskizze Evidenz-System (Rainer)
This commit is contained in:
@@ -137,18 +137,30 @@ class RoomMap:
|
||||
|
||||
# ── Lookup Methods ────────────────────────────────────────────────
|
||||
|
||||
def find_room_by_keywords(self, text: str, min_score: int = 2) -> Optional[RoomEntry]:
|
||||
def find_room_by_keywords(self, text: str, min_score: int = 2, origin_room_id: Optional[str] = None) -> Optional[RoomEntry]:
|
||||
"""Find the room with the most keyword matches for *text*.
|
||||
|
||||
Args:
|
||||
text: The message text to classify.
|
||||
min_score: Minimum score required to return a room (default: 2).
|
||||
origin_room_id: Optional room ID of the message origin for priority matching.
|
||||
|
||||
Returns:
|
||||
The ``RoomEntry`` with the highest match score, or ``None``
|
||||
if no room has any matching keywords or if the best score
|
||||
is below the minimum threshold.
|
||||
"""
|
||||
# Origin-First-Prinzip: Wenn ein Ursprungsraum angegeben ist, prüfe zuerst diesen
|
||||
if origin_room_id is not None and origin_room_id in self._rooms:
|
||||
origin_room = self._rooms[origin_room_id]
|
||||
# Nur prüfen, wenn es kein Catch-All-Raum ist (die haben keine Keywords)
|
||||
if not origin_room.catch_all:
|
||||
origin_score = origin_room.match_score(text)
|
||||
# Wenn der Ursprungsraum den Mindestscore erreicht, wird er ausgewählt
|
||||
if origin_score >= min_score:
|
||||
return origin_room
|
||||
|
||||
# Globaler Scan wie bisher
|
||||
best_room: Optional[RoomEntry] = None
|
||||
best_score: int = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user