diff --git a/plugin/archivar/room_map.py b/plugin/archivar/room_map.py index da8b4b3..eb293f0 100644 --- a/plugin/archivar/room_map.py +++ b/plugin/archivar/room_map.py @@ -137,15 +137,17 @@ class RoomMap: # ── Lookup Methods ──────────────────────────────────────────────── - def find_room_by_keywords(self, text: str) -> Optional[RoomEntry]: + def find_room_by_keywords(self, text: str, min_score: int = 2) -> 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). Returns: The ``RoomEntry`` with the highest match score, or ``None`` - if no room has any matching keywords. + if no room has any matching keywords or if the best score + is below the minimum threshold. """ best_room: Optional[RoomEntry] = None best_score: int = 0 @@ -158,7 +160,9 @@ class RoomMap: best_score = score best_room = room - return best_room + if best_room is not None and best_score >= min_score: + return best_room + return None def is_excluded(self, room_id: str) -> bool: """True if *room_id* is in the excluded list (e.g. Multi-Agent-Raum)."""