Coverage_gap %5->%100 (10 sayfa/bolum intent'i + rule-only mekanizma)
Browse files at this commitec4d3b0a0a00e70b49d36abe750af9b5e4a9fb57Parent: d75e3d8- feat
- coverage_gap %5->%100 (10 sayfa/bolum intent'i + rule-only mekanizma)
10 changed files +373 -8
- data/benchmark.jsonl +31 -0
- src/catalog.py +214 -0
- src/decision.py +3 -2
- src/domain.py +2 -1
- src/engine.py +46 -0
- src/role_spaces.py +15 -1
- src/rules.py +40 -0
- src/similarity.py +2 -1
- tests/e2e/test_behavior_matrix.py +11 -0
- tests/unit/test_similarity.py +9 -3
data/benchmark.jsonlmodified+31 -0
| @@ -193,3 +193,34 @@ | |||
| 193 | {"question": "Öğrencinin ödevine nasıl not veririm", "expected_intent": "homework_grade", "role": "ogretmen"} | 193 | {"question": "Öğrencinin ödevine nasıl not veririm", "expected_intent": "homework_grade", "role": "ogretmen"} |
| 194 | {"question": "Ödev teslimini değerlendirmek istiyorum", "expected_intent": "homework_grade", "role": "ogretmen"} | 194 | {"question": "Ödev teslimini değerlendirmek istiyorum", "expected_intent": "homework_grade", "role": "ogretmen"} |
| 195 | {"question": "Teslim edilen ödeve puan vermek istiyorum", "expected_intent": "homework_grade", "role": "ogretmen"} | 195 | {"question": "Teslim edilen ödeve puan vermek istiyorum", "expected_intent": "homework_grade", "role": "ogretmen"} |
| 196 | + | ||
| 197 | +{"question": "Ücret ödemelerimi nerede takip ederim?", "expected_intent": "fees_info", "role": "ogrenci"} | ||
| 198 | +{"question": "Okul ücreti hangi sayfada?", "expected_intent": "fees_info", "role": "ogrenci"} | ||
| 199 | +{"question": "Ödeme durumumu nereden görürüm?", "expected_intent": "fees_info", "role": "ogrenci"} | ||
| 200 | +{"question": "Şube bilgimi nereden öğrenirim?", "expected_intent": "branches_info", "role": "ogrenci"} | ||
| 201 | +{"question": "Okulun şubeleri hangi sayfada?", "expected_intent": "branches_info", "role": "ogrenci"} | ||
| 202 | +{"question": "Şube listesi nerede?", "expected_intent": "branches_info", "role": "ogrenci"} | ||
| 203 | +{"question": "Takvimi nereden açarım?", "expected_intent": "calendar_info", "role": "ogrenci"} | ||
| 204 | +{"question": "Haftalık programım nerede görünür?", "expected_intent": "calendar_info", "role": "ogrenci"} | ||
| 205 | +{"question": "Ders programını nasıl görürüm?", "expected_intent": "calendar_info", "role": "ogrenci"} | ||
| 206 | +{"question": "Ana panel neyi gösterir?", "expected_intent": "today_info", "role": "ogrenci"} | ||
| 207 | +{"question": "Bugün paneli neleri listeler?", "expected_intent": "today_info", "role": "ogrenci"} | ||
| 208 | +{"question": "Ana paneldeki özet nedir?", "expected_intent": "today_info", "role": "ogrenci"} | ||
| 209 | +{"question": "Soru bankasına nasıl ulaşırım?", "expected_intent": "question_bank_info", "role": "ogretmen"} | ||
| 210 | +{"question": "Soru bankası ne demek?", "expected_intent": "question_bank_info", "role": "ogretmen"} | ||
| 211 | +{"question": "Soru bankası hangi sayfada?", "expected_intent": "question_bank_info", "role": "ogretmen"} | ||
| 212 | +{"question": "Bildirimleri nereden yönetirim?", "expected_intent": "notification_settings_info", "role": "ogrenci"} | ||
| 213 | +{"question": "Bildirim tercihlerimi değiştirmek istiyorum", "expected_intent": "notification_settings_info", "role": "ogrenci"} | ||
| 214 | +{"question": "Bildirim sesini nasıl kapatırım?", "expected_intent": "notification_settings_info", "role": "ogrenci"} | ||
| 215 | +{"question": "Yönetim menüsünde ne var?", "expected_intent": "nav_overview", "role": "yonetici"} | ||
| 216 | +{"question": "Akademik altında hangi sayfalar var?", "expected_intent": "nav_overview", "role": "yonetici"} | ||
| 217 | +{"question": "ADMIN bölümünde neler var?", "expected_intent": "nav_overview", "role": "yonetici"} | ||
| 218 | +{"question": "Etkinlik listesi nerede?", "expected_intent": "event_view", "role": "ogrenci"} | ||
| 219 | +{"question": "Yaklaşan etkinlikleri nereden görürüm?", "expected_intent": "event_view", "role": "ogrenci"} | ||
| 220 | +{"question": "Etkinlik listemi görmek istiyorum", "expected_intent": "event_view", "role": "ogrenci"} | ||
| 221 | +{"question": "Sınav takvimi hangi sayfada?", "expected_intent": "exam_schedule_info", "role": "ogrenci"} | ||
| 222 | +{"question": "Sınav tarihlerini nereden görürüm?", "expected_intent": "exam_schedule_info", "role": "ogrenci"} | ||
| 223 | +{"question": "Yaklaşan sınavların tarihi nerede?", "expected_intent": "exam_schedule_info", "role": "ogrenci"} | ||
| 224 | +{"question": "Ders dosyaları hangi sayfada?", "expected_intent": "course_materials_info", "role": "ogrenci"} | ||
| 225 | +{"question": "Öğretmenin PDF dosyaları nerede?", "expected_intent": "course_materials_info", "role": "ogrenci"} | ||
| 226 | +{"question": "Ders notu dosyalarını nereden indiririm?", "expected_intent": "course_materials_info", "role": "ogrenci"} | ||
src/catalog.pymodified+214 -0
| @@ -1410,9 +1410,208 @@ INTENTS: Final[list[dict[str, Any]]] = [ | |||
| 1410 | ], | 1410 | ], |
| 1411 | "must_not_match": ["roles_permissions"], | 1411 | "must_not_match": ["roles_permissions"], |
| 1412 | }, | 1412 | }, |
| 1413 | + # --- Kapsam genişletme: menüdeki sayfa/bölüm açıklama intent'leri ----------- | ||
| 1414 | + { | ||
| 1415 | + "intent": "fees_info", | ||
| 1416 | + "category": "school", | ||
| 1417 | + "description": "Okul ücretleri/ödeme bilgisinin nerede görüleceği.", | ||
| 1418 | + "response_id": "fees_info_message", | ||
| 1419 | + "response_template": ( | ||
| 1420 | + "Okul **ücretleri** ve ödeme bilgilerini menüdeki **Ücretler** " | ||
| 1421 | + "sayfasından görürsün; borç ve ödeme durumu burada listelenir." | ||
| 1422 | + ), | ||
| 1423 | + "auth_required": False, | ||
| 1424 | + "min_role": "ziyaretci", | ||
| 1425 | + "example_questions": [ | ||
| 1426 | + "Okul ücretlerini nereden görürüm?", | ||
| 1427 | + "Ödeme bilgilerim nerede?", | ||
| 1428 | + "Ücretler sayfası nerede?", | ||
| 1429 | + ], | ||
| 1430 | + "must_not_match": ["report_card_view", "exam_finish_result"], | ||
| 1431 | + }, | ||
| 1432 | + { | ||
| 1433 | + "intent": "branches_info", | ||
| 1434 | + "category": "school", | ||
| 1435 | + "description": "Şubeler (şube/sınıf) sayfası ne işe yarar.", | ||
| 1436 | + "response_id": "branches_info_message", | ||
| 1437 | + "response_template": ( | ||
| 1438 | + "**Şubeler** sayfasında okulun şubeleri/sınıfları listelenir; hangi " | ||
| 1439 | + "**şube**de olduğunu ve şubenin ders/öğrenci bilgisini buradan görürsün." | ||
| 1440 | + ), | ||
| 1441 | + "auth_required": False, | ||
| 1442 | + "min_role": "ziyaretci", | ||
| 1443 | + "example_questions": [ | ||
| 1444 | + "Şubeler sayfası nerede?", | ||
| 1445 | + "Hangi şubedeyim?", | ||
| 1446 | + "Şube listesini nereden görürüm?", | ||
| 1447 | + ], | ||
| 1448 | + "must_not_match": [], | ||
| 1449 | + }, | ||
| 1450 | + { | ||
| 1451 | + "intent": "calendar_info", | ||
| 1452 | + "category": "general", | ||
| 1453 | + "description": "Takvim / haftalık ders programı sayfası.", | ||
| 1454 | + "response_id": "calendar_info_message", | ||
| 1455 | + "response_template": ( | ||
| 1456 | + "**Takvim** sayfasında etkinlikler, ders oturumları ve haftalık " | ||
| 1457 | + "**program** takvim görünümünde listelenir; günlere göre planı buradan izlersin." | ||
| 1458 | + ), | ||
| 1459 | + "auth_required": False, | ||
| 1460 | + "min_role": "ziyaretci", | ||
| 1461 | + "example_questions": [ | ||
| 1462 | + "Takvim sayfasını nasıl açarım?", | ||
| 1463 | + "Haftalık ders programım nerede?", | ||
| 1464 | + "Takvimi nereden görürüm?", | ||
| 1465 | + ], | ||
| 1466 | + "must_not_match": ["report_card_view", "exam_schedule_info"], | ||
| 1467 | + }, | ||
| 1468 | + { | ||
| 1469 | + "intent": "today_info", | ||
| 1470 | + "category": "general", | ||
| 1471 | + "description": "Bugün / ana panel ne gösterir.", | ||
| 1472 | + "response_id": "today_info_message", | ||
| 1473 | + "response_template": ( | ||
| 1474 | + "**Bugün** panelinde günün özeti bir arada görünür: yaklaşan sınavlar, " | ||
| 1475 | + "ödevler ve etkinlikler tek ekranda listelenir." | ||
| 1476 | + ), | ||
| 1477 | + "auth_required": False, | ||
| 1478 | + "min_role": "ziyaretci", | ||
| 1479 | + "example_questions": [ | ||
| 1480 | + "Bugün panelinde neleri görürüm?", | ||
| 1481 | + "Bugün paneli ne işe yarar?", | ||
| 1482 | + "Ana panelde ne var?", | ||
| 1483 | + ], | ||
| 1484 | + "must_not_match": ["roles_permissions", "help_capabilities"], | ||
| 1485 | + }, | ||
| 1486 | + { | ||
| 1487 | + "intent": "question_bank_info", | ||
| 1488 | + "category": "exams", | ||
| 1489 | + "description": "Soru bankası nedir / ne işe yarar.", | ||
| 1490 | + "response_id": "question_bank_info_message", | ||
| 1491 | + "response_template": ( | ||
| 1492 | + "**Soru bankası**, öğretmenlerin hazır soru şablonlarını saklayıp " | ||
| 1493 | + "sınavlara eklediği depodur; tekrar kullanılabilir sorular burada tutulur." | ||
| 1494 | + ), | ||
| 1495 | + "auth_required": False, | ||
| 1496 | + "min_role": "ziyaretci", | ||
| 1497 | + "example_questions": [ | ||
| 1498 | + "Soru bankası ne işe yarar?", | ||
| 1499 | + "Soru bankası nerede?", | ||
| 1500 | + "Hazır sorular nerede saklanır?", | ||
| 1501 | + ], | ||
| 1502 | + "must_not_match": ["exam_add_question", "parent_info"], | ||
| 1503 | + }, | ||
| 1504 | + { | ||
| 1505 | + "intent": "notification_settings_info", | ||
| 1506 | + "category": "account", | ||
| 1507 | + "description": "Bildirim ayarlarının nereden değiştirileceği.", | ||
| 1508 | + "response_id": "notification_settings_message", | ||
| 1509 | + "response_template": ( | ||
| 1510 | + "**Bildirim** tercihlerini ayarlar bölümünden düzenleyebilirsin; hangi " | ||
| 1511 | + "olaylarda bildirim alacağını buradan seçer veya kapatırsın." | ||
| 1512 | + ), | ||
| 1513 | + "auth_required": False, | ||
| 1514 | + "min_role": "ziyaretci", | ||
| 1515 | + "example_questions": [ | ||
| 1516 | + "Bildirim ayarlarını nereden değiştiririm?", | ||
| 1517 | + "Bildirimleri nasıl kapatırım?", | ||
| 1518 | + "Bildirim tercihleri nerede?", | ||
| 1519 | + ], | ||
| 1520 | + "must_not_match": ["school_settings", "language_theme"], | ||
| 1521 | + }, | ||
| 1522 | + { | ||
| 1523 | + "intent": "nav_overview", | ||
| 1524 | + "category": "general", | ||
| 1525 | + "description": "Menü bölümlerinin genel özeti (hangi bölümde ne var).", | ||
| 1526 | + "response_id": "nav_overview_message", | ||
| 1527 | + "response_template": ( | ||
| 1528 | + "Sol menü şu bölümlerden oluşur: **Bugün**; **Eğitim** (Takvim); " | ||
| 1529 | + "**Akademik** (Ödevler, Sınavlar, Soru bankası); **Planlama** " | ||
| 1530 | + "(Etkinlikler, Randevular); **Çalışma alanı** (Defter, Beyaz tahtalar); " | ||
| 1531 | + "**Öğrenci yönetimi** (Şubeler, Öğrenci notları/yoklamaları); **Okul " | ||
| 1532 | + "hizmetleri** (Yemekler); **Topluluk** (Mesajlar, Soru havuzu); **Okul " | ||
| 1533 | + "yönetimi** / Yönetim (Personel mesaisi); **Ayarlar** (Dönemler, " | ||
| 1534 | + "Ücretler, Kullanıcılar). **ADMIN** ek olarak kullanıcı ve rol " | ||
| 1535 | + "yönetimi yapar. Hangi bölümü açmak istediğini yazarsan yolunu veririm." | ||
| 1536 | + ), | ||
| 1537 | + "auth_required": False, | ||
| 1538 | + "min_role": "ziyaretci", | ||
| 1539 | + "example_questions": [ | ||
| 1540 | + "Menüde hangi bölümler var?", | ||
| 1541 | + "Öğrenci yönetimi bölümü ne işe yarar?", | ||
| 1542 | + "Akademik bölümü altında neler var?", | ||
| 1543 | + "Yönetim menüsünü kısaca anlatır mısın?", | ||
| 1544 | + "ADMIN bölümünde hangi sayfalar var?", | ||
| 1545 | + ], | ||
| 1546 | + "must_not_match": ["help_capabilities", "parent_info", "navigation_help"], | ||
| 1547 | + }, | ||
| 1548 | + { | ||
| 1549 | + "intent": "event_view", | ||
| 1550 | + "category": "events", | ||
| 1551 | + "description": "Etkinliklerin nerede görüntüleneceği.", | ||
| 1552 | + "response_id": "event_view_message", | ||
| 1553 | + "response_template": ( | ||
| 1554 | + "Okuldaki **etkinlikleri** menüdeki **Etkinlikler** (`/events`) " | ||
| 1555 | + "sayfasından görürsün; yaklaşan ve katılacağın etkinlikler burada listelenir." | ||
| 1556 | + ), | ||
| 1557 | + "auth_required": False, | ||
| 1558 | + "min_role": "ziyaretci", | ||
| 1559 | + "example_questions": [ | ||
| 1560 | + "Etkinlikleri nerede görürüm?", | ||
| 1561 | + "Etkinlikler sayfası nerede?", | ||
| 1562 | + "Yaklaşan etkinlikler nerede listelenir?", | ||
| 1563 | + ], | ||
| 1564 | + "must_not_match": ["event_create", "homework_view", "event_attendance_mark"], | ||
| 1565 | + }, | ||
| 1566 | + { | ||
| 1567 | + "intent": "exam_schedule_info", | ||
| 1568 | + "category": "exams", | ||
| 1569 | + "description": "Sınav takvimi / sınav tarihleri nerede.", | ||
| 1570 | + "response_id": "exam_schedule_message", | ||
| 1571 | + "response_template": ( | ||
| 1572 | + "**Sınav** takvimini ve **tarih**lerini **Sınavlar** (`/exams`) " | ||
| 1573 | + "sayfasından görürsün; yaklaşan sınavların tarihleri burada listelenir." | ||
| 1574 | + ), | ||
| 1575 | + "auth_required": False, | ||
| 1576 | + "min_role": "ziyaretci", | ||
| 1577 | + "example_questions": [ | ||
| 1578 | + "Sınav tarihleri nerede yazıyor?", | ||
| 1579 | + "Sınav takvimimi nereden görürüm?", | ||
| 1580 | + "Sınavlarımın tarihi nerede?", | ||
| 1581 | + ], | ||
| 1582 | + "must_not_match": ["exam_create", "homework_view", "calendar_info"], | ||
| 1583 | + }, | ||
| 1584 | + { | ||
| 1585 | + "intent": "course_materials_info", | ||
| 1586 | + "category": "courses", | ||
| 1587 | + "description": "Ders notları / öğretmenin yüklediği dosyalar (course-notes).", | ||
| 1588 | + "response_id": "course_materials_message", | ||
| 1589 | + "response_template": ( | ||
| 1590 | + "Öğretmenin yüklediği **ders notları** ve **PDF/dosya**lar ilgili " | ||
| 1591 | + "dersin sayfasındadır: **Dersler** (`/courses`) → ders → Ders notları." | ||
| 1592 | + ), | ||
| 1593 | + "auth_required": False, | ||
| 1594 | + "min_role": "ziyaretci", | ||
| 1595 | + "example_questions": [ | ||
| 1596 | + "Ders notları nerede?", | ||
| 1597 | + "Öğretmenin yüklediği PDF nerede?", | ||
| 1598 | + "Ders dosyalarını nereden indiririm?", | ||
| 1599 | + ], | ||
| 1600 | + "must_not_match": ["note_create", "report_card_view"], | ||
| 1601 | + }, | ||
| 1413 | ] | 1602 | ] |
| 1414 | 1603 | ||
| 1415 | 1604 | ||
| 1605 | +# Yalnız KURAL ile tetiklenen intent'ler: benzerlik (TF-IDF) havuzuna ALINMAZLAR. | ||
| 1606 | +# Ortak kelimeleri (bugün, menü, program, panel...) IDF'i kirletip OOS ayrımını | ||
| 1607 | +# bozuyordu; sayfa-arama/bölüm-özeti intent'leri deterministik kuralla kapsanır. | ||
| 1608 | +RULE_ONLY_INTENTS: Final[frozenset[str]] = frozenset({ | ||
| 1609 | + "fees_info", "branches_info", "calendar_info", "today_info", | ||
| 1610 | + "question_bank_info", "notification_settings_info", "nav_overview", | ||
| 1611 | + "event_view", "exam_schedule_info", "course_materials_info", | ||
| 1612 | +}) | ||
| 1613 | + | ||
| 1614 | + | ||
| 1416 | FALLBACK: Final[dict[str, str]] = { | 1615 | FALLBACK: Final[dict[str, str]] = { |
| 1417 | "response_id": "fallback_clarification", | 1616 | "response_id": "fallback_clarification", |
| 1418 | "response_template": ( | 1617 | "response_template": ( |
| @@ -1487,6 +1686,17 @@ INTENT_ROUTES: Final[dict[str, str | None]] = { | |||
| 1487 | "messages_use": "/messages", | 1686 | "messages_use": "/messages", |
| 1488 | "study_club_info": "/studies", | 1687 | "study_club_info": "/studies", |
| 1489 | "parent_info": None, | 1688 | "parent_info": None, |
| 1689 | + # Kapsam genişletme: | ||
| 1690 | + "fees_info": "/payments", | ||
| 1691 | + "branches_info": "/classes", | ||
| 1692 | + "calendar_info": "/calendar", | ||
| 1693 | + "today_info": "/", | ||
| 1694 | + "question_bank_info": "/bank-questions", | ||
| 1695 | + "notification_settings_info": None, | ||
| 1696 | + "nav_overview": None, | ||
| 1697 | + "event_view": "/events", | ||
| 1698 | + "exam_schedule_info": "/exams", | ||
| 1699 | + "course_materials_info": "/courses", | ||
| 1490 | } | 1700 | } |
| 1491 | 1701 | ||
| 1492 | # Yol -> arayüzde görünen sayfa adı (buton etiketi için). Rehber §4'teki TR etiketler. | 1702 | # Yol -> arayüzde görünen sayfa adı (buton etiketi için). Rehber §4'teki TR etiketler. |
| @@ -1515,6 +1725,10 @@ ROUTE_LABELS: Final[dict[str, str]] = { | |||
| 1515 | "/management/settings": "Ayarlar", | 1725 | "/management/settings": "Ayarlar", |
| 1516 | "/management/terms": "Dönemler", | 1726 | "/management/terms": "Dönemler", |
| 1517 | "/admin/users": "Kullanıcılar", | 1727 | "/admin/users": "Kullanıcılar", |
| 1728 | + "/payments": "Ücretler", | ||
| 1729 | + "/classes": "Şubeler", | ||
| 1730 | + "/calendar": "Takvim", | ||
| 1731 | + "/bank-questions": "Soru bankası", | ||
| 1518 | } | 1732 | } |
| 1519 | 1733 | ||
| 1520 | 1734 | ||
src/decision.pymodified+3 -2
| @@ -27,8 +27,9 @@ from .similarity import ScoredIntent, SimilarityMatcher, get_default_matcher | |||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | # Varsayılan parametreler (Aşama 11'de benchmark taramasıyla seçildi). | 29 | # Varsayılan parametreler (Aşama 11'de benchmark taramasıyla seçildi). |
| 30 | -# 0.18 + domain-gate: coverage %100, acc-on-covered ~%80, OOS recall ~%78, | 30 | +# 0.18 + domain-gate. Kapsam genişletme intent'leri (catalog.RULE_ONLY_INTENTS) |
| 31 | -# false-fallback 0. (Domain-gate olmadan OOS recall yalnızca ~%44'tü.) | 31 | +# benzerlik (TF-IDF) havuzuna ALINMAZ; bu sayede ortak kelimeleri (bugün/menü/ |
| 32 | +# program...) IDF'i kirletmez ve OOS ayrımı bozulmadan eşik 0.18'de kalır. | ||
| 32 | DEFAULT_THRESHOLD: Final[float] = 0.18 | 33 | DEFAULT_THRESHOLD: Final[float] = 0.18 |
| 33 | DEFAULT_TIE_MARGIN: Final[float] = 0.05 | 34 | DEFAULT_TIE_MARGIN: Final[float] = 0.05 |
| 34 | DEFAULT_TOP_K: Final[int] = 3 | 35 | DEFAULT_TOP_K: Final[int] = 3 |
src/domain.pymodified+2 -1
| @@ -15,7 +15,7 @@ from __future__ import annotations | |||
| 15 | 15 | ||
| 16 | from typing import Final, Iterable | 16 | from typing import Final, Iterable |
| 17 | 17 | ||
| 18 | -from .catalog import INTENTS | 18 | +from .catalog import INTENTS, RULE_ONLY_INTENTS |
| 19 | from .normalize import folded_tokens | 19 | from .normalize import folded_tokens |
| 20 | 20 | ||
| 21 | 21 | ||
| @@ -68,6 +68,7 @@ def build_domain_vocab(examples: Iterable[str] | None = None) -> set[str]: | |||
| 68 | source = ( | 68 | source = ( |
| 69 | question | 69 | question |
| 70 | for item in INTENTS | 70 | for item in INTENTS |
| 71 | + if item["intent"] not in RULE_ONLY_INTENTS | ||
| 71 | for question in item["example_questions"] | 72 | for question in item["example_questions"] |
| 72 | ) | 73 | ) |
| 73 | for question in source: | 74 | for question in source: |
src/engine.pymodified+46 -0
| @@ -206,6 +206,29 @@ def _resolve_negation(query: str) -> str: | |||
| 206 | return ", ".join(kept) | 206 | return ", ".join(kept) |
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | +# --- Henüz canlı olmayan / bulunmayan özellikler ---------------------------- | ||
| 210 | +# Bu anahtarlar bir sayfaya YANLIŞ yönlendirmek yerine dürüstçe "henüz | ||
| 211 | +# kullanılamıyor" der (asla yanlış). T1 (randevu/yemek/soru-havuzu/beyaz-tahta) | ||
| 212 | +# canlıya alınınca ilgili anahtar bu listeden çıkarılır; duyuru diye bir özellik | ||
| 213 | +# hiç yoktur. | ||
| 214 | +_UNAVAILABLE_FEATURES: tuple[tuple[str, str], ...] = ( | ||
| 215 | + ("randevu", "Randevular"), | ||
| 216 | + ("yemek", "Yemekler"), | ||
| 217 | + ("havuz", "Soru havuzu"), | ||
| 218 | + ("beyaz tahta", "Beyaz tahtalar"), | ||
| 219 | + ("tahta", "Beyaz tahtalar"), | ||
| 220 | + ("duyuru", "Duyurular"), | ||
| 221 | +) | ||
| 222 | + | ||
| 223 | + | ||
| 224 | +def _unavailable_feature(query: str) -> str | None: | ||
| 225 | + low = query.casefold() | ||
| 226 | + for keyword, label in _UNAVAILABLE_FEATURES: | ||
| 227 | + if keyword in low: | ||
| 228 | + return label | ||
| 229 | + return None | ||
| 230 | + | ||
| 231 | + | ||
| 209 | def _build_navigation( | 232 | def _build_navigation( |
| 210 | intent: str | None, | 233 | intent: str | None, |
| 211 | auth_action: str | None, | 234 | auth_action: str | None, |
| @@ -586,6 +609,29 @@ class Engine: | |||
| 586 | if not pure_negation and _neg_resolved != effective_query: | 609 | if not pure_negation and _neg_resolved != effective_query: |
| 587 | effective_query = _neg_resolved | 610 | effective_query = _neg_resolved |
| 588 | 611 | ||
| 612 | + # 1.57) Henüz canlı olmayan/bulunmayan özellik -> yanlış yönlendirme YOK, | ||
| 613 | + # dürüstçe "henüz kullanılamıyor" (intent None, nav yok). | ||
| 614 | + _unavail = _unavailable_feature(effective_query) | ||
| 615 | + if _unavail is not None: | ||
| 616 | + result = { | ||
| 617 | + "trace_id": trace_id, | ||
| 618 | + "response_id": "feature_unavailable", | ||
| 619 | + "text": _with_brand_note( | ||
| 620 | + f"**{_unavail}** özelliği şu an henüz aktif değil; bu sayfa " | ||
| 621 | + "kullanılamıyor. Eklenince burada yardımcı olacağım.", query), | ||
| 622 | + "intent": None, | ||
| 623 | + "confidence": 0.0, | ||
| 624 | + "fallback": False, | ||
| 625 | + "auth_action": None, | ||
| 626 | + "required_role": None, | ||
| 627 | + "navigation": None, | ||
| 628 | + "clarification": None, | ||
| 629 | + "answers": None, | ||
| 630 | + "suggestions": [], | ||
| 631 | + "safety": safety_info, | ||
| 632 | + } | ||
| 633 | + return _attach_assistant_meta(result, role) | ||
| 634 | + | ||
| 589 | # 1.6) Çoklu istek ('X ve Y'): her bağımsız parça ayrı yanıtlanır. | 635 | # 1.6) Çoklu istek ('X ve Y'): her bağımsız parça ayrı yanıtlanır. |
| 590 | segments = _multi_intent_segments(effective_query, role) | 636 | segments = _multi_intent_segments(effective_query, role) |
| 591 | if segments is not None: | 637 | if segments is not None: |
src/role_spaces.pymodified+15 -1
| @@ -20,7 +20,7 @@ from .access import ( | |||
| 20 | ReasonCode, | 20 | ReasonCode, |
| 21 | RoleIntentView, | 21 | RoleIntentView, |
| 22 | ) | 22 | ) |
| 23 | -from .catalog import INTENTS, ROLE_HIERARCHY | 23 | +from .catalog import INTENTS, ROLE_HIERARCHY, RULE_ONLY_INTENTS |
| 24 | from .domain import build_domain_vocab | 24 | from .domain import build_domain_vocab |
| 25 | from .rules import RuleMatcher | 25 | from .rules import RuleMatcher |
| 26 | from .similarity import SimilarityMatcher | 26 | from .similarity import SimilarityMatcher |
| @@ -147,6 +147,17 @@ _ACTION_BY_INTENT: Final[dict[str, str]] = { | |||
| 147 | "messages_use": "messages.use", | 147 | "messages_use": "messages.use", |
| 148 | "study_club_info": "platform.help", | 148 | "study_club_info": "platform.help", |
| 149 | "parent_info": "platform.help", | 149 | "parent_info": "platform.help", |
| 150 | + # Kapsam genişletme: bilgi/açıklama intent'leri (herkese açık, ALLOW). | ||
| 151 | + "fees_info": "platform.help", | ||
| 152 | + "branches_info": "platform.help", | ||
| 153 | + "calendar_info": "platform.help", | ||
| 154 | + "today_info": "platform.help", | ||
| 155 | + "question_bank_info": "platform.help", | ||
| 156 | + "notification_settings_info": "platform.help", | ||
| 157 | + "nav_overview": "platform.help", | ||
| 158 | + "event_view": "platform.help", | ||
| 159 | + "exam_schedule_info": "platform.help", | ||
| 160 | + "course_materials_info": "platform.help", | ||
| 150 | } | 161 | } |
| 151 | 162 | ||
| 152 | _OWN_REPORT_RESPONSES: Final[dict[str, str]] = { | 163 | _OWN_REPORT_RESPONSES: Final[dict[str, str]] = { |
| @@ -267,9 +278,12 @@ def get_role_space(role: str) -> CompiledRoleSpace: | |||
| 267 | views = {item["intent"]: _view(item, role) for item in INTENTS} | 278 | views = {item["intent"]: _view(item, role) for item in INTENTS} |
| 268 | content_hash = _hash_views(role, views) | 279 | content_hash = _hash_views(role, views) |
| 269 | space_id = f"{ROLE_SPACE_VERSION}:{role}:{content_hash[:12]}" | 280 | space_id = f"{ROLE_SPACE_VERSION}:{role}:{content_hash[:12]}" |
| 281 | + # RULE_ONLY_INTENTS benzerlik + domain-vocab havuzuna GİRMEZ (ortak kelimeleri | ||
| 282 | + # IDF/OOS ayrımını bozuyordu); yalnız kuralla tetiklenirler. | ||
| 270 | examples = [ | 283 | examples = [ |
| 271 | (view.intent, question) | 284 | (view.intent, question) |
| 272 | for view in views.values() | 285 | for view in views.values() |
| 286 | + if view.intent not in RULE_ONLY_INTENTS | ||
| 273 | for question in view.examples | 287 | for question in view.examples |
| 274 | ] | 288 | ] |
| 275 | return CompiledRoleSpace( | 289 | return CompiledRoleSpace( |
src/rules.pymodified+40 -0
| @@ -286,6 +286,46 @@ _RAW_RULES: Final[list[dict[str, Any]]] = [ | |||
| 286 | {"intent": "parent_info", "groups": [ | 286 | {"intent": "parent_info", "groups": [ |
| 287 | {"all": ["veli"]}, {"all": ["ebeveyn"]}, | 287 | {"all": ["veli"]}, {"all": ["ebeveyn"]}, |
| 288 | ]}, | 288 | ]}, |
| 289 | + # --- Kapsam genişletme: menü sayfa/bölüm açıklama intent'leri --- | ||
| 290 | + {"intent": "fees_info", "groups": [ | ||
| 291 | + {"all": ["ücret"]}, {"all": ["ödeme"], "none": ["sınav", "ödev"]}, | ||
| 292 | + ]}, | ||
| 293 | + {"intent": "branches_info", "groups": [ | ||
| 294 | + {"all": ["şube"]}, | ||
| 295 | + ]}, | ||
| 296 | + {"intent": "calendar_info", "groups": [ | ||
| 297 | + {"all": ["takvim"], "none": ["sınav"]}, | ||
| 298 | + {"all": ["haftalık", "program"]}, {"all": ["ders", "program"]}, | ||
| 299 | + ]}, | ||
| 300 | + {"intent": "today_info", "groups": [ | ||
| 301 | + {"all": ["bugün", "panel"]}, {"all": ["ana", "panel"]}, | ||
| 302 | + ]}, | ||
| 303 | + {"intent": "question_bank_info", "groups": [ | ||
| 304 | + {"all": ["soru", "banka"]}, | ||
| 305 | + ]}, | ||
| 306 | + {"intent": "notification_settings_info", "groups": [ | ||
| 307 | + {"all": ["bildirim"]}, | ||
| 308 | + ]}, | ||
| 309 | + {"intent": "nav_overview", "groups": [ | ||
| 310 | + {"all": ["akademik"], "none": ["dönem"]}, | ||
| 311 | + {"all": ["öğrenci", "yönetim", "bölüm"]}, | ||
| 312 | + {"all": ["yönetim", "menü"]}, {"all": ["admin", "bölüm"]}, | ||
| 313 | + {"all": ["admin", "sayfa"]}, {"all": ["bölüm", "neler"]}, | ||
| 314 | + {"all": ["menü", "bölüm", "var"]}, {"all": ["menü", "anlat"]}, | ||
| 315 | + {"all": ["hangi", "bölüm", "var"]}, | ||
| 316 | + ]}, | ||
| 317 | + {"intent": "event_view", "groups": [ | ||
| 318 | + {"all": ["etkinlik", "nerede"], "none": ["oluştur", "ekle", "planla", "katıl", "yoklama", "işaretle"]}, | ||
| 319 | + {"all": ["etkinlik", "gör"], "none": ["oluştur", "ekle", "planla", "katıl", "yoklama"]}, | ||
| 320 | + {"all": ["etkinlik", "liste"], "none": ["oluştur", "ekle"]}, | ||
| 321 | + ]}, | ||
| 322 | + {"intent": "exam_schedule_info", "groups": [ | ||
| 323 | + {"all": ["sınav", "takvim"]}, {"all": ["sınav", "tarih"]}, | ||
| 324 | + ]}, | ||
| 325 | + {"intent": "course_materials_info", "groups": [ | ||
| 326 | + {"all": ["ders", "not", "pdf"]}, {"all": ["ders", "not", "dosya"]}, | ||
| 327 | + {"all": ["öğretmen", "pdf"]}, {"all": ["ders", "dosya"], "none": ["defter"]}, | ||
| 328 | + ]}, | ||
| 289 | ] | 329 | ] |
| 290 | 330 | ||
| 291 | 331 | ||
src/similarity.pymodified+2 -1
| @@ -23,7 +23,7 @@ from collections import Counter | |||
| 23 | from dataclasses import dataclass | 23 | from dataclasses import dataclass |
| 24 | from typing import Final, Iterable, Protocol, runtime_checkable | 24 | from typing import Final, Iterable, Protocol, runtime_checkable |
| 25 | 25 | ||
| 26 | -from .catalog import INTENTS | 26 | +from .catalog import INTENTS, RULE_ONLY_INTENTS |
| 27 | from .normalize import fold_accents, folded_tokens, normalize | 27 | from .normalize import fold_accents, folded_tokens, normalize |
| 28 | 28 | ||
| 29 | 29 | ||
| @@ -128,6 +128,7 @@ class SimilarityMatcher: | |||
| 128 | examples = [ | 128 | examples = [ |
| 129 | (item["intent"], question) | 129 | (item["intent"], question) |
| 130 | for item in INTENTS | 130 | for item in INTENTS |
| 131 | + if item["intent"] not in RULE_ONLY_INTENTS | ||
| 131 | for question in item["example_questions"] | 132 | for question in item["example_questions"] |
| 132 | ] | 133 | ] |
| 133 | return cls(examples, ns=ns) | 134 | return cls(examples, ns=ns) |
tests/e2e/test_behavior_matrix.pymodified+11 -0
| @@ -101,6 +101,17 @@ INTENT_MATRIX: list[tuple[str, str, str]] = [ | |||
| 101 | ("ogrenci", "mesajlarım nerede", "messages_use"), | 101 | ("ogrenci", "mesajlarım nerede", "messages_use"), |
| 102 | ("ogrenci", "etüt ile ders arasında fark var mı", "study_club_info"), | 102 | ("ogrenci", "etüt ile ders arasında fark var mı", "study_club_info"), |
| 103 | ("ogrenci", "veli hesabı ne işe yarar", "parent_info"), | 103 | ("ogrenci", "veli hesabı ne işe yarar", "parent_info"), |
| 104 | + # --- kapsam genişletme --- | ||
| 105 | + ("ogrenci", "okul ücretlerini nereden görürüm", "fees_info"), | ||
| 106 | + ("ogrenci", "şubeler sayfası nerede", "branches_info"), | ||
| 107 | + ("ogrenci", "takvim sayfasını nasıl açarım", "calendar_info"), | ||
| 108 | + ("ogrenci", "bugün panelinde neleri görürüm", "today_info"), | ||
| 109 | + ("ogretmen", "soru bankası ne işe yarar", "question_bank_info"), | ||
| 110 | + ("ogrenci", "bildirim ayarlarını nereden değiştiririm", "notification_settings_info"), | ||
| 111 | + ("yonetici", "menüde hangi bölümler var", "nav_overview"), | ||
| 112 | + ("ogrenci", "etkinlikleri nerede görürüm", "event_view"), | ||
| 113 | + ("ogrenci", "sınav tarihleri nerede yazıyor", "exam_schedule_info"), | ||
| 114 | + ("ogrenci", "ders notları ve öğretmenin yüklediği pdf nerede", "course_materials_info"), | ||
| 104 | ] | 115 | ] |
| 105 | 116 | ||
| 106 | 117 | ||
tests/unit/test_similarity.pymodified+9 -3
| @@ -33,9 +33,15 @@ class SimilarityMatcherTests(unittest.TestCase): | |||
| 33 | cls.matcher = SimilarityMatcher.from_catalog() | 33 | cls.matcher = SimilarityMatcher.from_catalog() |
| 34 | 34 | ||
| 35 | def test_indexed_all_examples(self) -> None: | 35 | def test_indexed_all_examples(self) -> None: |
| 36 | - from src.catalog import INTENTS | 36 | + # RULE_ONLY_INTENTS benzerlik havuzuna alınmaz (yalnız kuralla tetiklenir); |
| 37 | - | 37 | + # indeks bu intent'lerin örneklerini içermez. |
| 38 | - expected = sum(len(i["example_questions"]) for i in INTENTS) | 38 | + from src.catalog import INTENTS, RULE_ONLY_INTENTS |
| 39 | + | ||
| 40 | + expected = sum( | ||
| 41 | + len(i["example_questions"]) | ||
| 42 | + for i in INTENTS | ||
| 43 | + if i["intent"] not in RULE_ONLY_INTENTS | ||
| 44 | + ) | ||
| 39 | self.assertEqual(self.matcher.size, expected) | 45 | self.assertEqual(self.matcher.size, expected) |
| 40 | 46 | ||
| 41 | def test_rank_sorted_descending(self) -> None: | 47 | def test_rank_sorted_descending(self) -> None: |