diff --git a/src/engine.py b/src/engine.py index 0cc4201..269fcf6 100644 --- a/src/engine.py +++ b/src/engine.py @@ -745,7 +745,14 @@ class Engine: and topk[0]["intent"] in _SOCIAL_INTENTS and topk[1]["intent"] in _SOCIAL_INTENTS ) - ask_mode = pure_negation or ( + # Tek kelimelik belirsiz sorgu (ör. "Ayarlar", "Sınav") KURAL değil similarity + # ile eşleşiyorsa tam cevap verme -> netleştir + öneri (asla yanlış). + single_word_similarity = ( + not response.fallback + and dec["source"] == "similarity" + and len(effective_query.split()) == 1 + ) + ask_mode = pure_negation or single_word_similarity or ( not response.fallback and dec["source"] == "similarity" and ( diff --git a/src/rules.py b/src/rules.py index 5ea7e0f..f3428c5 100644 --- a/src/rules.py +++ b/src/rules.py @@ -130,7 +130,7 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"intent": "course_create", "groups": [ {"all": ["yeni", "ders"], "none": ["saat", "oturum", "sınav", "öğrenci"]}, {"all": ["ders", "oluştur"], "none": ["saat", "oturum", "sınav", "öğrenci"]}, - {"all": ["ders", "aç"], "none": ["saat", "oturum", "sınav", "öğrenci"]}, + {"all": ["ders", "aç"], "none": ["saat", "oturum", "sınav", "öğrenci", "liste"]}, {"all": ["sınıf", "oluştur"]}, ]}, {"intent": "lesson_session_add", "groups": [ @@ -149,6 +149,20 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"intent": "exam_add_question", "groups": [ {"all": ["soru", "ekle"]}, {"all": ["soru", "oluştur"]}, {"all": ["seçmeli", "soru"]}, + # Öğretmenin doğru şıkkı belirlemesi = soru tanımlama (cevap kaydetme DEĞİL). + {"all": ["doğru", "şık"]}, + ]}, + {"intent": "exam_save_answer", "groups": [ + {"all": ["cevab", "kaydet"]}, {"all": ["cevap", "kaydet"]}, + {"all": ["şık", "seç"]}, {"all": ["işaretle", "cevab"]}, + ]}, + {"intent": "exam_live_monitor", "groups": [ + {"all": ["sınav", "takip"]}, {"all": ["anlık", "takip"]}, + {"all": ["sınav", "izle"]}, {"all": ["canlı", "izle"]}, + ]}, + {"intent": "course_view", "groups": [ + {"all": ["ders", "liste"], "none": ["oluştur", "yeni", "öğrenci", "not"]}, + {"all": ["derslerim"], "none": ["oluştur", "not"]}, ]}, {"intent": "exam_grade_student", "groups": [ {"all": ["öğrenci", "not", "gir"]}, {"all": ["notlandır"]}, @@ -170,6 +184,7 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"intent": "user_role_change", "groups": [ {"all": ["rol", "değiştir"]}, {"all": ["rol", "ata"]}, {"all": ["yetki", "yükselt"]}, {"all": ["kullanıcı", "rol"]}, + {"all": ["kullanıcı", "admin"]}, {"all": ["admin", "yap"], "none": ["beni"]}, ]}, {"intent": "term_manage", "groups": [ {"all": ["dönem", "oluştur"]}, {"all": ["akademik", "dönem"]}, @@ -257,7 +272,8 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ {"intent": "homework_grade", "groups": [ {"all": ["ödev", "notland"]}, {"all": ["ödev", "değerlendir"]}, {"all": ["ödev", "puan"]}, - {"all": ["ödev", "not", "ver"]}, {"all": ["ödev", "not", "gir"]}, + {"all": ["ödev", "not", "ver"], "none": ["bak", "aldı", "nereden"]}, + {"all": ["ödev", "not", "gir"], "none": ["bak", "aldı"]}, ]}, # --- Backend v2: pomodoro / mesajlar / etüt-kulüp / veli --- {"intent": "pomodoro_use", "groups": [ diff --git a/src/safety/toxicity.py b/src/safety/toxicity.py index 5ccbb51..2c348f8 100644 --- a/src/safety/toxicity.py +++ b/src/safety/toxicity.py @@ -414,7 +414,9 @@ def evaluate_input(message: str, role: str = "ziyaretci", authenticated: bool = profanity = _matched_root(prof_tokens, STRONG_PROFANITY) if insult or profanity: # Eğitim/alıntı bağlamı -> izin. - educational = any(m in tokens for m in _EDU_MARKERS) or "'" in message or '"' in message + educational = any(m in tokens for m in _EDU_MARKERS) or any( + q in message for q in ("'", '"', "‘", "’", "“", "”") + ) if educational: return _make(ALLOW, "PROFANITY_EDUCATIONAL", 0, "SAFE-PROF-000", "", matched=[insult or profanity])