<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DatabaseSchemaReader.DataSchema;
using Slp.Evi.Storage.Query;
using TCode.r2rml4net.Mapping;

namespace Slp.Evi.Storage.Utils
{
    public static class MappingExtensions
    {
        /// <summary>
        /// Gets type resolver for passed <see cref="ITermMap"/>.
        /// </summary>
        public static Func<string, DataType> GetTypeResolver(this ITermMap termMap, IQueryContext context)
        {
            var triplesMap = termMap.GetTriplesMapConfiguration();

            if (triplesMap == null)
            {
                // TODO: Remove this, replace by better solution, it happens only in tests
                return x => null;
            }
            else if (triplesMap.TableName != null)
            {
                var tableInfo = context.SchemaProvider.GetTableInfo(triplesMap.TableName);
                return x => tableInfo.FindColumn(x).DataType;
            }
            else
            {
                throw new NotImplementedException();
            }
        }
    }
}
<commit_msg>Extensions for mapping classes (codedoc)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DatabaseSchemaReader.DataSchema;
using Slp.Evi.Storage.Query;
using TCode.r2rml4net.Mapping;

namespace Slp.Evi.Storage.Utils
{
    /// <summary>
    /// Extensions for mapping classes.
    /// </summary>
    public static class MappingExtensions
    {
        /// <summary>
        /// Gets type resolver for passed <see cref="ITermMap"/>.
        /// </summary>
        public static Func<string, DataType> GetTypeResolver(this ITermMap termMap, IQueryContext context)
        {
            var triplesMap = termMap.GetTriplesMapConfiguration();

            if (triplesMap == null)
            {
                // TODO: Remove this, replace by better solution, it happens only in tests
                return x => null;
            }
            else if (triplesMap.TableName != null)
            {
                var tableInfo = context.SchemaProvider.GetTableInfo(triplesMap.TableName);
                return x => tableInfo.FindColumn(x).DataType;
            }
            else
            {
                throw new NotImplementedException();
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.09372419488026425, 'fraction_numerical': 0.0016515276630883566, 'mean_word_length': 1.9298669891172915, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '7486500', 'n_tokens_mistral': 646, 'n_tokens_neox': 637, 'n_words': 160}