<commit_before>﻿/*
The X11 License
NX - extension objects and methods of C#
Copyright(c) 2015 cannorin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace NX
{
    public class TComparer<T> : IComparer<T>
    {
        public Func<T, T, int> Comparer { get; private set; }

        public TComparer(Func<T, T, int> f)
        {
            Comparer = f;
        }

        public int Compare(T x, T y)
        {
            return Comparer(x, y);
        }
    }

    public class TEquialityComparer<T> : IEqualityComparer<T>
    {
        public Func<T, T, bool> Comparer { get; private set; }

        public TEquialityComparer(Func<T, T, bool> f)
        {
            Comparer = f;
        }

        public bool Equals(T a, T b)
        {
            return Comparer(a, b);
        }

        public int GetHashCode(T a)
        {
            return a.GetHashCode();
        }
    }

    public static class ExprNX
    {
        public static T Block<T>(Func<T> f)
        {
            return f();
        }
    }

    public static class New
    {
        public static T[] Array<T>(params T[] ts)
        {
            return ts;
        }

        public static IEnumerable<T> Seq<T>(params T[] ts)
        {
            return ts;
        }
    }

    public static class Seq
    {
        public static IEnumerable<string> EnumerateLines(this StreamReader sr)
        {<commit_msg>Add StringNX<commit_after>﻿/*
The X11 License
NX - extension objects and methods of C#
Copyright(c) 2015 cannorin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;

namespace NX
{
    public class TComparer<T> : IComparer<T>
    {
        public Func<T, T, int> Comparer { get; private set; }

        public TComparer(Func<T, T, int> f)
        {
            Comparer = f;
        }

        public int Compare(T x, T y)
        {
            return Comparer(x, y);
        }
    }

    public class TEquialityComparer<T> : IEqualityComparer<T>
    {
        public Func<T, T, bool> Comparer { get; private set; }

        public TEquialityComparer(Func<T, T, bool> f)
        {
            Comparer = f;
        }

        public bool Equals(T a, T b)
        {
            return Comparer(a, b);
        }

        public int GetHashCode(T a)
        {
            return a.GetHashCode();
        }
    }

    public static class ExprNX
    {
        public static T Block<T>(Func<T> f)
        {
            return f();
        }
    }

    public static class StringNX
    {
        public static string[] Split(this string s, bool removeEmptyEntries, params string[] seps)
        {
            return s.Split(seps, removeEmptyEntries ? StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None);
        }
    }

    public static class New
    {
        public static T[] Array<T>(params T[] ts)
        {
            return ts;
        }

        public static IEnumerable<T> Seq<T>(params T[] ts)
        {
            return ts;
        }
    }

    public static class Seq
    {
        public static IEnumerable<string> EnumerateLines(this StreamReader sr)
        {
{'fraction_non_alphanumeric': 0.0708114199849737, 'fraction_numerical': 0.002253944402704733, 'mean_word_length': 2.4332688588007736, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '1096334', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1455, 'n_words': 609}