Files
rar-autopass/tests/test_fix_anvelope_oe8.py
Claude Agent 6674d0e3e1 fix(sugestii): inlocuirea de anvelope -> OE-8 + vot k-NN ponderat pe rang
Seed-ul Haiku eticheta sistematic "INLOCUIT ANVELOPE ..." cu OE-1 (223 vs 17
OE-8), desi RAR are cod dedicat OE-8 (inlocuire sezoniera anvelope), asa ca
votul k-NN propunea OE-1 pentru orice inlocuire de anvelope.

- tools/mapare-llm/fix_anvelope_oe8.py: re-etichetare deterministica (187
  randuri DB + seed JSON -> OE-8; regula exclude singular cu pozitie, D/R,
  janta, vulcanizare) + 13 intrari canonice curate manual pentru formularile
  sezoniere absente din corpus ("MONTAT CAUCIUCURI VARA" etc.); idempotent
- enrich_suggestions: ponderea votului = EMB_VOTE_DECAY^rang (0.7) in loc de
  similaritatea bruta — anizotropia modelului lasa zgomotul de coada (ex.
  INLOCUIT BECURII la 0.934 de INLOCUIRE ANVELOPE) sa invinga vecinii corecti
  de rang 1-2; LOO: precizie egala (93.1%), cod-gresit 4.67% -> 4.63%
- test_fix_anvelope_oe8: gardii pe regula + seed-ul din repo (regresie la
  regenerare); auditul k-NN al dezacordurilor nu a gasit alte erori
  sistematice (curatat=OE-2, reglat=OE-4, bujii/ulei=OE-3 raman apararabile)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 10:26:30 +00:00

59 lines
2.0 KiB
Python

"""Gardii pentru corectia anvelope->OE-8 (tools/mapare-llm/fix_anvelope_oe8.py).
Doua niveluri:
1. Regula `este_inlocuire_anvelope` pe cazuri pozitive/negative.
2. Seed-ul real din repo NU mai contine inlocuiri de anvelope etichetate
altfel decat OE-8 (regresie la o viitoare regenerare a seed-ului).
"""
from __future__ import annotations
import json
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
TOOLS_DIR = os.path.abspath(os.path.join(HERE, "..", "tools", "mapare-llm"))
if TOOLS_DIR not in sys.path:
sys.path.insert(0, TOOLS_DIR)
from fix_anvelope_oe8 import SEED_PATH, este_inlocuire_anvelope # noqa: E402
def test_regula_pozitive():
for t in [
"INLOCUIT ANVELOPE B 55 XMH",
"INLOCUIT ANVELOPE 2 BUC",
"INLOCUIT + ECHILIBRAT ANVELOPE",
"SCHIMBAT ANVELOPE VARA",
"MONTAT ANVELOPE (2)",
"INL ANVELOPE + ECHILIBR",
]:
assert este_inlocuire_anvelope(t), t
def test_regula_negative():
for t in [
"INLOCUIT ANVELOPA DR FATA", # singular cu pozitie = context reparatie
"D/R ANVELOPE(4 BUC)", # demontat/remontat, nu inlocuire
"INLOCUIT ANVELOPA+JANTA", # janta = reparatie
"REPARAT ANVELOPE", # vulcanizare/reparatie
"CHIRIE ANVELOPE AUGUST", # non-operatie (fara verb de inlocuire)
"INLOCUIT PLACUTE FRANA", # alta piesa
"VERIFICAT PRESIUNE ANVELOPE", # verificare, nu inlocuire
]:
assert not este_inlocuire_anvelope(t), t
def test_seed_fara_inlocuiri_anvelope_gresite():
"""Orice intrare de inlocuire anvelope din seed trebuie sa fie OE-8."""
with open(SEED_PATH, encoding="utf-8") as f:
items = json.load(f)
gresite = [
it["denumire_normalizata"]
for it in items
if not it.get("is_nul")
and este_inlocuire_anvelope(it.get("denumire_normalizata") or "")
and it.get("cod") != "OE-8"
]
assert gresite == [], f"{len(gresite)} inlocuiri de anvelope ne-OE-8 in seed: {gresite[:5]}"