Actualizar index2.html
This commit is contained in:
104
index2.html
104
index2.html
@@ -807,57 +807,75 @@
|
|||||||
function summarizeDescription(rawText) {
|
function summarizeDescription(rawText) {
|
||||||
if (!rawText) return "Revisión técnica en el domicilio.";
|
if (!rawText) return "Revisión técnica en el domicilio.";
|
||||||
|
|
||||||
// 1. Limpieza inicial de saltos de línea
|
let text = String(rawText);
|
||||||
let text = String(rawText).replace(/(\r\n|\n|\r)/gm, " ");
|
|
||||||
|
|
||||||
// 2. Eliminar fechas, horas y marcas automáticas de los CRM (ej. 27/02/2026 - 15:44)
|
// 1. Limpieza inicial: Quitar fechas y coletillas exactas que ensucian el corte
|
||||||
text = text.replace(/\(?\d{2}\/\d{2}\/\d{4}.{0,12}\d{2}:\d{2}\)?/g, " ");
|
text = text.replace(/\(?\d{2}\/\d{2}\/\d{4}.{0,12}\d{2}:\d{2}\)?\s*-?/g, " "); // (23/02/2026 - 11:42)
|
||||||
text = text.replace(/\d{2}\/\d{2}\/\d{4}\s*-\s*/g, " ");
|
text = text.replace(/\d{2}\/\d{2}\/\d{4}\s*-\s*/g, " "); // 17/02/2026 -
|
||||||
|
text = text.replace(/Descripción de la Averia/gi, " ");
|
||||||
|
text = text.replace(/Suceso:/gi, " ");
|
||||||
text = text.replace(/Texto manual/gi, " ");
|
text = text.replace(/Texto manual/gi, " ");
|
||||||
|
text = text.replace(/DAñO_[0-9]:/gi, " ");
|
||||||
|
text = text.replace(/\(posible cobertura\)/gi, " ");
|
||||||
|
|
||||||
// 3. Extracción de paja: Condiciones de seguros, notas internas, seguimientos y operadoras
|
// 2. Separar por saltos de línea reales O por dobles barras (//) típicas de Multiasistencia
|
||||||
const paja = [
|
let lines = text.split(/[\n]|(?:\/\/?)/);
|
||||||
/COBERTURA.*?PROFESIONAL/gi,
|
|
||||||
/INDICO DEBE FACILITAR MATERIAL.*?REPARACIÓN/gi,
|
let validLines = [];
|
||||||
/INFO SERVICIOS DISPONIBLES/gi,
|
|
||||||
/CONFORME/gi,
|
// 3. LISTA NEGRA: Si la línea tiene alguna de estas palabras, es basura interna y se borra entera
|
||||||
/SERVICIOS PRESTADOS:?/gi,
|
const junkKeywords = [
|
||||||
/Primer contacto con cliente.*?(\.|$)/gi,
|
"cobro banco", "cobro contado", "servicio asignado", "sms", "enviado sms",
|
||||||
/Por seguimiento se desasigna.*?(\.|$)/gi,
|
"cambio de estado", "este servicio requiere", "atención: el importe",
|
||||||
/Cliente llama.*?(\.|$)/gi,
|
"el tipo de cobro", "siniestro comunicado", "cita confirmada", "visita al cliente",
|
||||||
/LLAMA TOMADOR/gi,
|
"introducción ptto", "aplazamiento pte", "fecha y hora", "para el ofrecimiento",
|
||||||
/SOLICITA SERVICIO DE /gi,
|
"enviar factura", "declarante", "aviso nocita", "límite máximo", "importante",
|
||||||
/Enviar factura.*?Madrid/gi,
|
"conectese via", "servicio con prof", "servicio sin prof", "servicio con la fecha",
|
||||||
/\[PROPUESTA.*?\]/gi,
|
"servicio desasignado", "comentario de desasignacion", "webservice", "alta servicio",
|
||||||
/Aver[ií]a:?/gi, /Descripci[oó]n:?/gi, /Motivo:?/gi, /Siniestro:?/gi, /Detalle:?/gi,
|
"alta avería", "alta reparación", "alta daños", "alta sin luz", "alta cambio",
|
||||||
/\bM\.O\.?\b/gi, /\bMATERIALES?\b/gi, /\bASEGURADO\b/gi, /\bFRANQUICIA\b/gi,
|
"contacto con cliente", "fin previsto", "entrega presupuesto", "reparación con expediente",
|
||||||
/TEL[EÉ]FONO\s*\d+/gi, /\b[6789]\d{8}\b/g // Elimina teléfonos sueltos
|
"abierta reclamación", "llamada autom", "voicebot", "cliente informado por whatsapp",
|
||||||
|
"a espera de cita", "llamada entrante", "llamada saliente", "se ha introducido un importe",
|
||||||
|
"intento de llamada", "llamada de asegurado", "llama asegurad", "llamo a",
|
||||||
|
"servicio generado por proceso automático", "cubre", "cobertura", "daños propios",
|
||||||
|
"tipo de averia", "franja horaria", "agente", "oficina bbva", "repasar",
|
||||||
|
"revisado por perito", "perito tasa", "cita deseada", "rango horario"
|
||||||
];
|
];
|
||||||
|
|
||||||
paja.forEach(regex => {
|
for (let line of lines) {
|
||||||
text = text.replace(regex, " ");
|
let cleanLine = line.trim();
|
||||||
});
|
if (cleanLine.length < 12) continue; // Ignorar códigos o números sueltos
|
||||||
|
|
||||||
// 4. Limpiar símbolos sobrantes (barras, guiones o comas repetidas tras la limpieza)
|
let isJunk = junkKeywords.some(keyword => cleanLine.toLowerCase().includes(keyword));
|
||||||
text = text.replace(/[\/]+/g, ", ");
|
if (!isJunk) {
|
||||||
text = text.replace(/[-_]{2,}/g, " ");
|
// Limpiar asteriscos y basura suelta
|
||||||
text = text.replace(/\s{2,}/g, " ").trim();
|
cleanLine = cleanLine.replace(/[\*\_]+/g, "").trim();
|
||||||
text = text.replace(/^[,.\s]+/, "");
|
if(cleanLine.length > 5) validLines.push(cleanLine);
|
||||||
|
}
|
||||||
// Si al limpiar todo se nos ha quedado vacío, ponemos un texto por defecto
|
|
||||||
if (text.length < 5) return "Revisión técnica en el domicilio.";
|
|
||||||
|
|
||||||
// 5. Toque IA: Convertir los gritos (TODO MAYÚSCULAS) en un texto agradable y humano
|
|
||||||
text = text.toLowerCase();
|
|
||||||
text = text.replace(/(^\w|\.\s*\w)/g, match => match.toUpperCase());
|
|
||||||
|
|
||||||
// 6. Ya no cortamos a 20 palabras, dejamos toda la información útil.
|
|
||||||
// Solo aplicamos un cortafuegos si el texto es escandalosamente gigante (más de 300 caracteres).
|
|
||||||
if (text.length > 300) {
|
|
||||||
text = text.substring(0, 300).trim() + "...";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.endsWith('.') || text.endsWith('...') ? text : text + ".";
|
// Si después de la escabechina nos quedamos sin nada, ponemos el texto base
|
||||||
|
if (validLines.length === 0) return "Revisión técnica en el domicilio.";
|
||||||
|
|
||||||
|
// 4. EL MAGO: Nos quedamos única y exclusivamente con la primera frase válida
|
||||||
|
let finalSummary = validLines[0];
|
||||||
|
|
||||||
|
// Limpieza estética final
|
||||||
|
finalSummary = finalSummary.replace(/[\/]+/g, ", ")
|
||||||
|
.replace(/[-_]{2,}/g, " ")
|
||||||
|
.replace(/\s{2,}/g, " ")
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
// Transformar MAYÚSCULAS en texto normal para que no parezca que gritamos
|
||||||
|
finalSummary = finalSummary.toLowerCase();
|
||||||
|
finalSummary = finalSummary.charAt(0).toUpperCase() + finalSummary.slice(1);
|
||||||
|
|
||||||
|
// Cortar si es escandalosamente largo (más de 150 caracteres)
|
||||||
|
if (finalSummary.length > 150) {
|
||||||
|
finalSummary = finalSummary.substring(0, 150).trim() + "...";
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalSummary.endsWith('.') || finalSummary.endsWith('...') ? finalSummary : finalSummary + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOneHour(timeStr) {
|
function addOneHour(timeStr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user