Parser: usar show_chart como referencia para posición del valor

This commit is contained in:
2026-04-16 13:13:49 -03:00
parent 3788202d0c
commit 6c5b4646a0
+3 -7
View File
@@ -726,21 +726,17 @@ for (const linea of lineas) {
const lineaLower = linea.toLowerCase().trim();
for (const [clave, info] of Object.entries(mapeoParametros)) {
console.log('Clave evaluando:', clave, 'incluye?', lineaLower.includes(clave));
if (lineaLower.includes(clave)) {
const cleanLinea = linea.replace(/show_chart|list_alt/g, '').replace(/\t+/g, ' ').replace(/\s+/g, ' ').trim();
const partes = cleanLinea.split(' ');
const searchTerms = [clave.split(' ')[0], clave.split(' ').slice(-1)[0]];
const foundIndex = partes.findIndex(p => searchTerms.some(term => p.toLowerCase().includes(term)));
console.log('SEARCH:', clave, '-> terms:', searchTerms, 'parts:', partes, 'found:', foundIndex);
let idxParam = foundIndex;
if (idxParam === -1) idxParam = 0;
// show_chart está al inicio, el valor está en posicion 1
const hasIcon = linea.includes('show_chart') || linea.includes('list_alt');
let idxParam = hasIcon ? 1 : 0;
for (let i = idxParam + 1; i < partes.length; i++) {
const parte = partes[i].replace(',', '.').replace('³', '').replace('²', '');
const valor = parseFloat(parte);
console.log('TRY Valor:', valor, 'parte:', parte, 'siguiente:', partes[i + 1]);
if (!isNaN(valor) && valor > 0 && valor < 1000) {
const sig = partes[i + 1] || '';
const esRango = sig === '-' || /\d/.test(sig);