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

namespace PureCat.Context
{
    public class CatContext : IEnumerable<KeyValuePair<string, string>>
    {
        private Dictionary<string, string> _dict = new Dictionary<string, string>();

        private const string _catRootId = "X-Cat-RootId";
        private const string _catParentId = "X-Cat-ParentId";
        private const string _catChildId = "X-Cat-Id";

        public string CatRootId { get { return this[_catRootId]; } set { this[_catRootId] = value; } }
        public string CatParentId { get { return this[_catParentId]; } set { this[_catParentId] = value; } }
        public string CatChildId { get { return this[_catChildId]; } set { this[_catChildId] = value; } }
        public string ContextName { get; private set; }

        public CatContext(string contextName = null)
        {
            ContextName = contextName ?? Environment.MachineName;
        }

        public string this[string key]
        {
            get { return _dict.ContainsKey(key) ? _dict[key] : null; }
            set { _dict[key] = value; }
        }

        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
        {
            foreach (var item in _dict)
                yield return item;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}<commit_msg>fix CatContext Serialize<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace PureCat.Context
{
    public class CatContext
    {
        private Dictionary<string, string> _dict = new Dictionary<string, string>();

        private const string _catRootId = "X-Cat-RootId";
        private const string _catParentId = "X-Cat-ParentId";
        private const string _catChildId = "X-Cat-Id";

        public string CatRootId { get { return this[_catRootId]; } set { this[_catRootId] = value; } }
        public string CatParentId { get { return this[_catParentId]; } set { this[_catParentId] = value; } }
        public string CatChildId { get { return this[_catChildId]; } set { this[_catChildId] = value; } }
        public string ContextName { get; private set; }

        public CatContext(string contextName = null)
        {
            ContextName = contextName ?? Environment.MachineName;
        }

        public string this[string key]
        {
            get { return _dict.ContainsKey(key) ? _dict[key] : null; }
            set { _dict[key] = value; }
        }

        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
        {
            foreach (var item in _dict)
                yield return item;
        }
    }
}
{'fraction_non_alphanumeric': 0.09868421052631579, 'fraction_numerical': 0.0, 'mean_word_length': 2.4384422110552766, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '790009', 'n_tokens_mistral': 757, 'n_tokens_neox': 747, 'n_words': 202}