<commit_before>﻿// Copyright 2005-2015 <NAME> & Contributors. All rights reserved. See doc/License.md in the project root for license information.

using System.Collections.Generic;
using System.Linq;
using CommandLine.Infrastructure;

namespace CommandLine.Core
{
    internal static class KeyValuePairHelper
    {
        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForSwitch(
            IEnumerable<Token> tokens)
        {
            return tokens.Select(t => Create(t.Text, "true"));
        }

        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForScalar(
            IEnumerable<Token> tokens)
        {
            return tokens.Pairwise((f, s) => Create(f.Text, s.Text));
        }

        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForSequence(
            IEnumerable<Token> tokens)
        {
            return from t in tokens.Pairwise(
                (f, s) =>
                        f.IsName()
                            ? Create(f.Text, tokens.SkipWhile(t => t.Equals(f)).TakeWhile(v => v.IsValue()).Select(x => x.Text).ToArray())
                            : Create(string.Empty))
                   where t.Key.Length > 0 && t.Value.Any()
                   select t;
        }

        private static KeyValuePair<string, IEnumerable<string>> Create(string value, params string[] values)
        {
            return new KeyValuePair<string, IEnumerable<string>>(value, values);
        }
    }
}
<commit_msg>Renaming private method and making it an extension m.<commit_after>﻿// Copyright 2005-2015 <NAME> & Contributors. All rights reserved. See doc/License.md in the project root for license information.

using System.Collections.Generic;
using System.Linq;
using CommandLine.Infrastructure;

namespace CommandLine.Core
{
    internal static class KeyValuePairHelper
    {
        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForSwitch(
            IEnumerable<Token> tokens)
        {
            return tokens.Select(t => t.Text.ToKeyValuePair("true"));
        }

        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForScalar(
            IEnumerable<Token> tokens)
        {
            return tokens.Pairwise((f, s) => f.Text.ToKeyValuePair(s.Text));
        }

        public static IEnumerable<KeyValuePair<string, IEnumerable<string>>> ForSequence(
            IEnumerable<Token> tokens)
        {
            return from t in tokens.Pairwise(
                (f, s) =>
                        f.IsName()
                            ? f.Text.ToKeyValuePair(tokens.SkipWhile(t => t.Equals(f)).TakeWhile(v => v.IsValue()).Select(x => x.Text).ToArray())
                            : string.Empty.ToKeyValuePair())
                   where t.Key.Length > 0 && t.Value.Any()
                   select t;
        }

        private static KeyValuePair<string, IEnumerable<string>> ToKeyValuePair(this string value, params string[] values)
        {
            return new KeyValuePair<string, IEnumerable<string>>(value, values);
        }
    }
}

{'fraction_non_alphanumeric': 0.106055851898337, 'fraction_numerical': 0.005647944775651083, 'mean_word_length': 2.03041825095057, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 51, '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': '121619', 'n_tokens_mistral': 859, 'n_tokens_neox': 817, 'n_words': 192}