<commit_before>﻿using System.Collections.Concurrent;
using System.IO;
using Stubble.Core.Interfaces;

namespace Stubble.Extensions.Loaders
{
    public class FileSystemLoader : IStubbleLoader
    {
        internal const string DefaultFileType = "mustache";
        internal readonly string Path;
        internal readonly string Extension;
        internal ConcurrentDictionary<string, string> TemplateCache = new ConcurrentDictionary<string, string>();

        public FileSystemLoader(string path) : this(path, DefaultFileType)
        {
        }

        public FileSystemLoader(string path, string extension)
        {
            Path = path.TrimEnd('/');
            Extension = extension;
        }

        public string Load(string name)
        {
            if (TemplateCache.ContainsKey(name)) return TemplateCache[name];

            var fileName = Path + "/name." + Extension;
            if (!File.Exists(fileName)) return null;

            var contents = File.ReadAllText(fileName);
            TemplateCache.AddOrUpdate(name, contents, (s, s1) => contents);
            return contents;
        }
    }
}
<commit_msg>Name should be taken from arguments<commit_after>﻿using System.Collections.Concurrent;
using System.IO;
using Stubble.Core.Interfaces;

namespace Stubble.Extensions.Loaders
{
    public class FileSystemLoader : IStubbleLoader
    {
        internal const string DefaultFileType = "mustache";
        internal readonly string Path;
        internal readonly string Extension;
        internal ConcurrentDictionary<string, string> TemplateCache = new ConcurrentDictionary<string, string>();

        public FileSystemLoader(string path) : this(path, DefaultFileType)
        {
        }

        public FileSystemLoader(string path, string extension)
        {
            Path = path.TrimEnd('/');
            Extension = extension;
        }

        public string Load(string name)
        {
            if (TemplateCache.ContainsKey(name)) return TemplateCache[name];

            var fileName = Path + "/" + name + "." + Extension;
            if (!File.Exists(fileName)) return null;

            var contents = File.ReadAllText(fileName);
            TemplateCache.AddOrUpdate(name, contents, (s, s1) => contents);
            return contents;
        }
    }
}

{'fraction_non_alphanumeric': 0.09027777777777778, 'fraction_numerical': 0.0008680555555555555, 'mean_word_length': 2.4713855421686746, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3622664', 'n_tokens_mistral': 572, 'n_tokens_neox': 560, 'n_words': 151}