<commit_before>namespace Nancy.Localization
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Resources;

    /// <summary>
    /// Resource based implementation of <see cref="ITextResource"/>
    /// </summary>
    public class ResourceBasedTextResource  : ITextResource
    {
        private readonly IAssemblyProvider assemblyProvider;
        private readonly IDictionary<string, ResourceManager> resourceManagers;

        /// <summary>
        /// Initializes a new instance of <see cref="ResourceBasedTextResource"/> to read strings from *.resx files
        /// </summary>
        public ResourceBasedTextResource(IAssemblyProvider assemblyProvider)
        {
            this.assemblyProvider = assemblyProvider;

            var resources = 
                from assembly in this.assemblyProvider.GetAssembliesToScan()
                from resourceName in assembly.GetManifestResourceNames()
                where resourceName.EndsWith(".resources")
                let parts = resourceName.Split(new[] { '.' })
                let name = parts[parts.Length - 2]
                let baseName = resourceName.Replace(".resources", string.Empty)
                select new
                    {<commit_msg>Introduces scan predicate for resource texts<commit_after>namespace Nancy.Localization
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using System.Resources;

    /// <summary>
    /// Resource based implementation of <see cref="ITextResource"/>
    /// </summary>
    public class ResourceBasedTextResource  : ITextResource
    {
        private readonly IAssemblyProvider assemblyProvider;
        private readonly IDictionary<string, ResourceManager> resourceManagers;
        
        /// <summary>
        /// Convention that determins if an Assembly should be scanned for resources.
        /// </summary>
        /// <remarks>The default convention will scan all assemblies that references another assemblies that has a name that starts with Nancy*</remarks>
        public static Func<Assembly, bool> ScanningPredicate = assembly =>
        {
            return assembly.GetReferencedAssemblies().Any(reference =>
            {
                return reference.Name.StartsWith("Nancy", StringComparison.OrdinalIgnoreCase);
            });
        };

        /// <summary>
        /// Initializes a new instance of <see cref="ResourceBasedTextResource"/> to read strings from *.resx files
        /// </summary>
        public ResourceBasedTextResource(IAssemblyProvider assemblyProvider)
        {
            this.assemblyProvider = assemblyProvider;

            var resources = 
                from assembly in this.assemblyProvider.GetAssembliesToScan()
                where ScanningPredicate.Invoke(assembly)
                from resourceName in assembly.GetManifestResourceNames()
                where resourceName.EndsWith(".resources")
                let parts = resourceName.Split(new[] { '.' })
                let name = parts[parts.Length - 2]
                let baseName = resourceName.Replace(".resources", string.Empty)
                select new
                    {
{'fraction_non_alphanumeric': 0.08496124031007751, 'fraction_numerical': 0.00062015503875969, 'mean_word_length': 2.2227772227772227, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 24, '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': '3865812', 'n_tokens_mistral': 742, 'n_tokens_neox': 713, 'n_words': 204}