<commit_before>﻿namespace AngleSharp.Extensions
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;

    /// <summary>
    /// Some methods for working with bare objects.
    /// </summary>
    [DebuggerStepThrough]
    static class ObjectExtensions
    {
        public static Dictionary<String, T> ToDictionary<T>(this Object values, Func<Object, T> converter)
        {
            var symbols = new Dictionary<String, T>();

            if (values != null)
            {
                var properties = values.GetType().GetProperties();

                foreach (var property in properties)
                {
                    var value = property.GetValue(values, null) ?? String.Empty;
                    symbols.Add(property.Name, converter(value));
                }
            }

            return symbols;
        }

        public static Dictionary<String, Object> ToDictionary(this Object values)
        {
            return values.ToDictionary(m => m);
        }

        public static T? TryGet<T>(this IDictionary<String, Object> values, String key)
            where T : struct
        {
            Object value;
            
            if (values.TryGetValue(key, out value) && value is T)
                return (T)value;

            return null;
        }

        public static Object TryGet(this IDictionary<String, Object> values, String key)
        {
            Object value;

            if (values.TryGetValue(key, out value))
                return value;

            return null;
        }

        public static U GetOrDefault<T, U>(this IDictionary<T, U> values, T key, U defaultValue)
        {
            U value;
            return values.TryGetValue(key, out value) ? value : default(U);
        }

        public static Double Constraint(this Double value, Double min, Double max)
        {
            return value < min ? min : (value > max ? max : value);
        }
    }
}<commit_msg>Return the provided default value<commit_after>﻿namespace AngleSharp.Extensions
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;

    /// <summary>
    /// Some methods for working with bare objects.
    /// </summary>
    [DebuggerStepThrough]
    static class ObjectExtensions
    {
        public static Dictionary<String, T> ToDictionary<T>(this Object values, Func<Object, T> converter)
        {
            var symbols = new Dictionary<String, T>();

            if (values != null)
            {
                var properties = values.GetType().GetProperties();

                foreach (var property in properties)
                {
                    var value = property.GetValue(values, null) ?? String.Empty;
                    symbols.Add(property.Name, converter(value));
                }
            }

            return symbols;
        }

        public static Dictionary<String, Object> ToDictionary(this Object values)
        {
            return values.ToDictionary(m => m);
        }

        public static T? TryGet<T>(this IDictionary<String, Object> values, String key)
            where T : struct
        {
            Object value;
            
            if (values.TryGetValue(key, out value) && value is T)
                return (T)value;

            return null;
        }

        public static Object TryGet(this IDictionary<String, Object> values, String key)
        {
            Object value;

            if (values.TryGetValue(key, out value))
                return value;

            return null;
        }

        public static U GetOrDefault<T, U>(this IDictionary<T, U> values, T key, U defaultValue)
        {
            U value;
            return values.TryGetValue(key, out value) ? value : defaultValue;
        }

        public static Double Constraint(this Double value, Double min, Double max)
        {
            return value < min ? min : (value > max ? max : value);
        }
    }
}
{'fraction_non_alphanumeric': 0.0902672718103883, 'fraction_numerical': 0.0, 'mean_word_length': 1.64290473017988, 'pattern_counts': {'":': 0, '<': 29, '<?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': '6633850', 'n_tokens_mistral': 1012, 'n_tokens_neox': 968, 'n_words': 300}