Пример #1
0
        /// <summary>
        /// Método para mostrar el modulo de justificación de la inferencia
        /// </summary>
        private void mostrarModuloDeJustificación()
        {
            dialogo = new FormDialogoPanel(ventana_justificacion);
            List <string> log = new List <string>();

            if (tipo_de_encadenamiento == ENCADENAMIENTO_HACIA_ATRAS)
            {
                log = motor_atras.loggeo_inferencia;
            }
            else
            {
                log = motor_adelante.loggeo_inferencia;
            }
            for (int i = 0; i < log.Count; i++)
            {
                string texto = _procesador_log_inferencia.ProcesarLineaDeLoggeo(log[i]);
                if (texto != null)
                {
                    ventana_justificacion.agregarLineaLog(texto);
                }
            }

            // ventana_justificacion.agregarLineaLog(log[i]);
            dialogo.FormClosing += dialogo_justificacion_FormClosing;
            ventana_justificacion.evento_guardar       += ventana_justificacion_evento_guardar;
            ventana_justificacion.evento_ventana_lista += evento_ventana_respuesta_lista;
            dialogo.ShowDialog(ventana_padre);
            dialogo = null;
        }
Пример #2
0
        private bool escribirLogEnArchivo(List <string> log, ProcesadorLogInferencia procesador, bool guardar_variables, bool guardar_hechos, bool guardar_reglas, string ruta_archivo)
        {
            StringBuilder texto_archivo = new StringBuilder();

            for (int i = 0; i < log.Count; i++)
            {
                string linea_log = procesador.ProcesarLineaDeLoggeo(log[i]);
                if (linea_log != null)
                {
                    texto_archivo.AppendLine(linea_log);
                }
            }
            if (guardar_reglas)
            {
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("-----------------------------------------------------");
                texto_archivo.AppendLine("-----------   Reglas     ----------------------------");
                texto_archivo.AppendLine("-----------------------------------------------------");
                string[] lista_de_reglas = base_conocimiento.listarReglas();
                for (int i = 0; i < lista_de_reglas.Length; i++)
                {
                    Regla regla = base_conocimiento.leerRegla(lista_de_reglas[i]);
                    texto_archivo.AppendLine("ID " + regla.id_regla + " | " + regla);
                }
            }
            if (guardar_hechos)
            {
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("-----------------------------------------------------");
                texto_archivo.AppendLine("-----------  Hechos      ----------------------------");
                texto_archivo.AppendLine("-----------------------------------------------------");
                string[] lista_de_hechos = base_conocimiento.listarHechos();
                for (int i = 0; i < lista_de_hechos.Length; i++)
                {
                    Hecho hecho = base_conocimiento.leerHecho(lista_de_hechos[i]);
                    texto_archivo.AppendLine("ID " + hecho.id_hecho + "  (ID variable " + hecho.id_variable + ") | " + hecho);
                }
            }
            if (guardar_variables)
            {
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("");
                texto_archivo.AppendLine("-----------------------------------------------------");
                texto_archivo.AppendLine("-----------  Variables   ----------------------------");
                texto_archivo.AppendLine("-----------------------------------------------------");
                string[] lista_de_variables = base_conocimiento.listarVariables();
                for (int i = 0; i < lista_de_variables.Length; i++)
                {
                    texto_archivo.AppendLine(extraerDetalleVariable(base_conocimiento.leerVariable(lista_de_variables[i])));
                }
            }
            return(generarArchivoDeTexto(texto_archivo, ruta_archivo));
        }