<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wodsoft.ComBoost.AspNetCore
{
    public class HttpValueKeyCollection : ValueKeyCollection
    {
        private Dictionary<string, string> lowerKeys;

        public HttpValueKeyCollection(IEnumerable<string> keys, bool ignoreCase) : base(keys)
        {
            if (ignoreCase)
                lowerKeys = keys.ToDictionary(t => t.ToLower(), t => t);
        }

        public override bool ContainsKey(string key)
        {
            if (lowerKeys != null)
                return lowerKeys.ContainsKey(key.ToLower());
            return base.ContainsKey(key);
        }

        public override bool ContainsPrefix(string prefix, params char[] separators)
        {
            if (lowerKeys != null)
            {
                prefix = prefix.ToLower();
                return lowerKeys.Keys.Any(t => t == prefix || separators.Any(x => t.StartsWith(prefix + x)));
            }
            return base.ContainsPrefix(prefix, separators);
        }

        public override IDictionary<string, string> GetKeysFromPrefix(string prefix, params char[] separators)
        {
            if (lowerKeys != null)
            {
                prefix = prefix.ToLower();
                var data = lowerKeys.Where(t => separators.Any(x => t.Key.StartsWith(prefix + x))).ToDictionary(t =>
                {
                    var text = t.Value.Substring(prefix.Length);
                    int i = text.IndexOfAny(separators, 1);<commit_msg>修复字符串小写一样时的错误<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wodsoft.ComBoost.AspNetCore
{
    public class HttpValueKeyCollection : ValueKeyCollection
    {
        private Dictionary<string, string> lowerKeys;

        public HttpValueKeyCollection(IEnumerable<string> keys, bool ignoreCase) : base(keys)
        {
            if (ignoreCase)
            {
                lowerKeys = new Dictionary<string, string>();
                foreach (var key in keys)
                {
                    var lower = key.ToLower();
                    if (lowerKeys.ContainsKey(lower))
                        continue;
                    lowerKeys.Add(lower, key);
                }
            }
        }

        public override bool ContainsKey(string key)
        {
            if (lowerKeys != null)
                return lowerKeys.ContainsKey(key.ToLower());
            return base.ContainsKey(key);
        }

        public override bool ContainsPrefix(string prefix, params char[] separators)
        {
            if (lowerKeys != null)
            {
                prefix = prefix.ToLower();
                return lowerKeys.Keys.Any(t => t == prefix || separators.Any(x => t.StartsWith(prefix + x)));
            }
            return base.ContainsPrefix(prefix, separators);
        }

        public override IDictionary<string, string> GetKeysFromPrefix(string prefix, params char[] separators)
        {
            if (lowerKeys != null)
            {
                prefix = prefix.ToLower();
                var data = lowerKeys.Where(t => separators.Any(x => t.Key.StartsWith(prefix + x))).ToDictionary(t =>
                {
                    var text = t.Value.Substring(prefix.Length);
                    int i = text.IndexOfAny(separators, 1);
{'fraction_non_alphanumeric': 0.09921671018276762, 'fraction_numerical': 0.0005802146794313896, 'mean_word_length': 1.8146938775510204, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 22, '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': '7246865', 'n_tokens_mistral': 899, 'n_tokens_neox': 878, 'n_words': 201}