<commit_before>﻿namespace Colorful
{
    using System;
    using System.Drawing;

    /// <summary>
    /// <see cref="Color"/> extension methods.
    /// </summary>
    public static class ColorExtensions
    {
        /// <summary>
        /// Converts the specified <see cref="Color"/> to it's nearest <see cref="ConsoleColor"/> equivalent.
        /// </summary>
        /// <remarks>Code taken from <NAME> at https://stackoverflow.com/questions/1988833/converting-color-to-consolecolor</remarks>
        public static ConsoleColor ToNearestConsoleColor(this Color color)
        {
            ConsoleColor closestConsoleColor = 0;
            double delta = double.MaxValue;

            foreach (ConsoleColor consoleColor in Enum.GetValues(typeof(ConsoleColor)))
            {
                string consoleColorName = Enum.GetName(typeof(ConsoleColor), consoleColor);
                Color rgbColor = System.Drawing.Color.FromName(consoleColorName == "DarkYellow" ? "Orange" : consoleColorName);
                double sum = Math.Pow(rgbColor.R - color.R, 2.0) + Math.Pow(rgbColor.G - color.G, 2.0) + Math.Pow(rgbColor.B - color.B, 2.0);

                if (sum == 0.0)
                {
                    return consoleColor;
                }
                else if (sum < delta)
                {
                    delta = sum;
                    closestConsoleColor = consoleColor;
                }
            }

            return closestConsoleColor;
        }
    }
}
<commit_msg>Refactor<commit_after>﻿namespace Colorful
{
    using System;
    using System.Drawing;

    /// <summary>
    /// <see cref="Color"/> extension methods.
    /// </summary>
    public static class ColorExtensions
    {
        /// <summary>
        /// Converts the specified <see cref="Color"/> to it's nearest <see cref="ConsoleColor"/> equivalent.
        /// </summary>
        /// <remarks>Code taken from <NAME> at https://stackoverflow.com/questions/1988833/converting-color-to-consolecolor</remarks>
        public static ConsoleColor ToNearestConsoleColor(this Color color)
        {
            ConsoleColor closestConsoleColor = 0;
            double delta = double.MaxValue;

            foreach (ConsoleColor consoleColor in Enum.GetValues(typeof(ConsoleColor)))
            {
                string consoleColorName = Enum.GetName(typeof(ConsoleColor), consoleColor);
                consoleColorName = string.Equals(consoleColorName, nameof(ConsoleColor.DarkYellow), StringComparison.Ordinal) ?
                    nameof(Color.Orange) :
                    consoleColorName;
                Color rgbColor = Color.FromName(consoleColorName);
                double sum =
                    Math.Pow(rgbColor.R - color.R, 2.0) +
                    Math.Pow(rgbColor.G - color.G, 2.0) +
                    Math.Pow(rgbColor.B - color.B, 2.0);

                if (sum == 0.0)
                {
                    return consoleColor;
                }
                else if (sum < delta)
                {
                    delta = sum;
                    closestConsoleColor = consoleColor;
                }
            }

            return closestConsoleColor;
        }
    }
}

{'fraction_non_alphanumeric': 0.10595200997195388, 'fraction_numerical': 0.009971953879713306, 'mean_word_length': 1.6140065146579805, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 2, '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': '1773952', 'n_tokens_mistral': 867, 'n_tokens_neox': 800, 'n_words': 179}