'$1 ', // "j'ai combien de X" → "combien X" '/\bj[\' ]?ai\s+(combien|nombre|total)\s+(?:de\s+|des\s+|du\s+|d[\' ])?\b/iu' => '$1 ', // "mes/mon/ma X" entre combien et entité '/\b(combien|nombre|total|quantit[eé])\s+(?:de\s+|des\s+)?(?:mes|mon|ma|mon\s+pipeline|mes\s+actuels?)\s+\b/iu' => '$1 ', // Articles résiduels '/\b(combien|nombre|total)\s+(?:de\s+|des\s+|du\s+|d[\' ])\s+\b/iu' => '$1 ', ]; $__normalized = $__orig; foreach ($__patterns as $__pat => $__rep) { $__normalized = preg_replace($__pat, $__rep, $__normalized); } // Si normalisation a changé quelque chose, update $_mam pour le bloc suivant if ($__normalized !== $__orig) { // Log pour audit trail @file_put_contents( '/var/log/weval/wevia-nl-normalizer.log', date('c') . " NORMALIZED: '$__orig' → '$__normalized'\n", FILE_APPEND | LOCK_EX ); $_mam = $__normalized; // $_wm aussi (shared global) if (isset($_wm)) $_wm = $__normalized; } }