<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using IronPython.Runtime;

[assembly: PythonModule("unicodedata", typeof(IronPython.Modules.unicodedata))]

namespace IronPython.Modules
{
    public static class unicodedata
    {
        private const string UnicodedataResourceName = "IronPython.Modules.unicodedata.IPyUnicodeData.txt.gz";

        private static Dictionary<int, CharInfo> database;
        private static List<RangeInfo> ranges;
        private static Dictionary<string, int> nameLookup;

        [SpecialName]
        public static void PerformModuleReload(PythonContext/*!*/ context, IDictionary/*!*/ dict)
        {
            EnsureLoaded();
        }

        public static char lookup(string name)
        {
            EnsureLoaded();

            return (char)nameLookup[name];
        }

        public static string name(char unichr, string @default = null)
        {
            try
            {
                return GetInfo(unichr).Name;
            }
            catch(KeyNotFoundException)
            {
                if(@default != null)
                    return @default;
                else
                    throw;
            }
        }

        public static int @decimal(char unichr, int? @default = null)
        {
            try
            {
                int? d = GetInfo(unichr).Numeric_Value_Decimal;
                if(d.HasValue)
                {
                    return d.Value;
                }
                else
                {
                    if(@default.HasValue)
                        return @default.Value;
                    else<commit_msg>unicodedata.lookup should return a string, not a char.<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using IronPython.Runtime;

[assembly: PythonModule("unicodedata", typeof(IronPython.Modules.unicodedata))]

namespace IronPython.Modules
{
    public static class unicodedata
    {
        private const string UnicodedataResourceName = "IronPython.Modules.unicodedata.IPyUnicodeData.txt.gz";

        private static Dictionary<int, CharInfo> database;
        private static List<RangeInfo> ranges;
        private static Dictionary<string, int> nameLookup;

        [SpecialName]
        public static void PerformModuleReload(PythonContext/*!*/ context, IDictionary/*!*/ dict)
        {
            EnsureLoaded();
        }

        public static string lookup(string name)
        {
            EnsureLoaded();

            return Convert.ToChar(nameLookup[name]).ToString();
        }

        public static string name(char unichr, string @default = null)
        {
            try
            {
                return GetInfo(unichr).Name;
            }
            catch(KeyNotFoundException)
            {
                if(@default != null)
                    return @default;
                else
                    throw;
            }
        }

        public static int @decimal(char unichr, int? @default = null)
        {
            try
            {
                int? d = GetInfo(unichr).Numeric_Value_Decimal;
                if(d.HasValue)
                {
                    return d.Value;
                }
                else
                {
                    if(@default.HasValue)
                        return @default.Value;
                    else
{'fraction_non_alphanumeric': 0.08185721953837896, 'fraction_numerical': 0.0, 'mean_word_length': 1.6432624113475178, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6267433', 'n_tokens_mistral': 959, 'n_tokens_neox': 925, 'n_words': 212}