<commit_before>﻿using ArtificialNeuralNetwork;
using Logging;
using NeuralNetwork.GeneticAlgorithm.Evaluatable;

namespace NeuralNetwork.GeneticAlgorithm
{

    public class TrainingSession : ITrainingSession
    {
        private int _sessionNumber;
        public INeuralNetwork NeuralNet { get; set; }
        private IEvaluatable _evaluatable;
        private bool _hasStoredSessionEval;
        private double _sessionEval;

        public TrainingSession(INeuralNetwork nn, IEvaluatable evaluatable, int sessionNumber)
        {
            NeuralNet = nn;
            _evaluatable = evaluatable;
            _sessionNumber = sessionNumber;
            _hasStoredSessionEval = false;
            _sessionEval = 0;
        }

        public void Run()
        {
            LoggerFactory.GetLogger().Log(LogLevel.Debug, string.Format("Starting training session {0}", _sessionNumber));
            _evaluatable.RunEvaluation();
            LoggerFactory.GetLogger().Log(LogLevel.Debug, string.Format("Stopping training session {0}", _sessionNumber));
        }

        public double GetSessionEvaluation()
        {
           
            if (_hasStoredSessionEval)
            {
                return _sessionEval;
            }
            else
            {
                _sessionEval = _evaluatable.GetEvaluation();
                _hasStoredSessionEval = true;
            }
            return _sessionEval;
        }



    }
}<commit_msg>only run training sessions if they havent been run before<commit_after>﻿using ArtificialNeuralNetwork;
using Logging;
using NeuralNetwork.GeneticAlgorithm.Evaluatable;

namespace NeuralNetwork.GeneticAlgorithm
{

    public class TrainingSession : ITrainingSession
    {
        private int _sessionNumber;
        public INeuralNetwork NeuralNet { get; set; }
        private IEvaluatable _evaluatable;
        private bool _hasStoredSessionEval;
        private double _sessionEval;

        public TrainingSession(INeuralNetwork nn, IEvaluatable evaluatable, int sessionNumber)
        {
            NeuralNet = nn;
            _evaluatable = evaluatable;
            _sessionNumber = sessionNumber;
            _hasStoredSessionEval = false;
            _sessionEval = 0;
        }

        public void Run()
        {
            LoggerFactory.GetLogger().Log(LogLevel.Debug, string.Format("Starting training session {0}", _sessionNumber));
            //only run the session if it hasn't already been run before
            if (!_hasStoredSessionEval)
            {
                _evaluatable.RunEvaluation();
            }
            LoggerFactory.GetLogger().Log(LogLevel.Debug, string.Format("Stopping training session {0}", _sessionNumber));
        }

        public double GetSessionEvaluation()
        {

            if (_hasStoredSessionEval)
            {
                return _sessionEval;
            }
            else
            {
                _sessionEval = _evaluatable.GetEvaluation();
                _hasStoredSessionEval = true;
            }
            return _sessionEval;
        }



    }
}
{'fraction_non_alphanumeric': 0.06742301458670989, 'fraction_numerical': 0.0019448946515397082, 'mean_word_length': 1.9787644787644787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5037720', 'n_tokens_mistral': 780, 'n_tokens_neox': 745, 'n_words': 174}