<commit_before>﻿using OctgnArtReplacer.Octgn;
using OctgnArtReplacer.Octgn.Mtg;
using OctgnArtReplacer.Octgn.Schema;
using OctgnArtReplacer.Octgn.SchemaExtensions;
using OctgnArtReplacer.Replacer.Images;
using OctgnArtReplacer.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OctgnArtReplacer.Replacer
{
    class ArtReplacer
    {
        private readonly string _imageSourcePath;
        private readonly string _imageOutputPath;
        private readonly string _setName;

        private readonly OctgnContext _octgnContext;
        private readonly ImageSource _imageSource;

        private IEnumerable<Image> _images;
        private Set _set;


        public ArtReplacer(string imageSourcePath, string imageOutputPath, string setName)
        {
            _imageSourcePath = imageSourcePath;
            _imageOutputPath = imageOutputPath;
            _setName = setName;

            _octgnContext = new MtgContext(); // TODO: support more than mtg
            _imageSource = new ImageSource(_imageSourcePath);
        }

        public async Task<VerificationResult> Verify()
        {
            if (!_octgnContext.IsOctgnInstalled)
            {
                Log.Error("Error: OCTGN is not installed");
                return VerificationResult.Fail;
            }

            if (!_octgnContext.IsInstalled)
            {
                Log.Error("Error: Game definition is not installed");
                return VerificationResult.Fail;
            }

            var setList = await _octgnContext.GetSetsAsync();
            _set = setList
                .FirstOrDefault(s => string.Equals(s.Name, _setName, StringComparison.OrdinalIgnoreCase));
            
            if (_set == null)
            {
                Log.Error($"Error: Unable to find set with the name \"{_setName}\"");
                Log.Info("Available Sets:");

                foreach (var set in setList)
                {
                    Log.Info($"  {set.Name}");
                }

                return VerificationResult.Fail;
            }

            _images = await _imageSource.GetImagesAsync();

            bool hasWarning = false,<commit_msg>More minor verifications.<commit_after>﻿using OctgnArtReplacer.Octgn;
using OctgnArtReplacer.Octgn.Mtg;
using OctgnArtReplacer.Octgn.Schema;
using OctgnArtReplacer.Octgn.SchemaExtensions;
using OctgnArtReplacer.Replacer.Images;
using OctgnArtReplacer.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OctgnArtReplacer.Replacer
{
    class ArtReplacer
    {
        private readonly string _imageSourcePath;
        private readonly string _imageOutputPath;
        private readonly string _setName;

        private readonly OctgnContext _octgnContext;
        private readonly ImageSource _imageSource;

        private IEnumerable<Image> _images;
        private Set _set;


        public ArtReplacer(string imageSourcePath, string imageOutputPath, string setName)
        {
            _imageSourcePath = imageSourcePath;
            _imageOutputPath = imageOutputPath;
            _setName = setName;

            _octgnContext = new MtgContext(); // TODO: support more than mtg
            _imageSource = new ImageSource(_imageSourcePath);
        }

        public async Task<VerificationResult> Verify()
        {
            if (!Directory.Exists(_imageSourcePath))
            {
                Log.Error("Error: Unable to find image source path");
                return VerificationResult.Fail;
            }

            if (!_octgnContext.IsOctgnInstalled)
            {
                Log.Error("Error: OCTGN is not installed");
                return VerificationResult.Fail;
            }

            if (!_octgnContext.IsInstalled)
            {
                Log.Error("Error: Game definition is not installed");
                return VerificationResult.Fail;
            }

            var setList = await _octgnContext.GetSetsAsync();
            _set = setList
                .FirstOrDefault(s => string.Equals(s.Name, _setName, StringComparison.OrdinalIgnoreCase));
            
            if (_set == null)
            {
                Log.Error($"Error: Unable to find set with the name \"{_setName}\"");
                Log.Info("Available Sets:");

                foreach (var set in setList.OrderBy(s => s.Name))
                {
                    Log.Info($"  {set.Name}");
                }

                return VerificationResult.Fail;
            }

            _images = await _imageSource.GetImagesAsync();

            bool hasWarning = false,
{'fraction_non_alphanumeric': 0.0772804054054054, 'fraction_numerical': 0.0, 'mean_word_length': 1.9943109987357774, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '3419483', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1212, 'n_words': 291}