<commit_before>﻿using System;
using System.IO;

namespace Archimedes.Framework.Configuration
{
    public class ConfigurationLoader
    {
        public Properties LoadConfiguration(string[] commandLineArgs = null)
        {
            return LoadConfigurationFromPropertiesFile()
                .Merge(LoadConfigurationFromCommandLine(commandLineArgs));
        }

        private Properties LoadConfigurationFromCommandLine(string[] commandLineArgs)
        {
            var cmdProps = new Properties();

            if (commandLineArgs != null && commandLineArgs.Length != 0)
            {
                var argsCmd = CommandLineParser.ParseCommandLineArgs(commandLineArgs);
                cmdProps.Merge(argsCmd.ToParameterMap());
            }

            return cmdProps;
        }

        private Properties LoadConfigurationFromPropertiesFile()
        {
            var cmdProps = new Properties();

            var path = AppDomain.CurrentDomain.BaseDirectory + @"\application.properties";
            if (File.Exists(path))
            {
                var properties = PropertiesParser.Parse(path);
                cmdProps.Merge(properties);
            }
            return cmdProps;
        }
    }
}
<commit_msg>support loading configuration from AppData folder<commit_after>﻿using System;
using System.IO;
using Archimedes.Patterns.Utils;

namespace Archimedes.Framework.Configuration
{
    public class ConfigurationLoader
    {
        public Properties LoadConfiguration(string[] commandLineArgs = null)
        {
            return LoadConfigurationFromPropertiesFile()
                .Merge(LoadConfigurationFromCommandLine(commandLineArgs));
        }

        private Properties LoadConfigurationFromCommandLine(string[] commandLineArgs)
        {
            var cmdProps = new Properties();

            if (commandLineArgs != null && commandLineArgs.Length != 0)
            {
                var argsCmd = CommandLineParser.ParseCommandLineArgs(commandLineArgs);
                cmdProps.Merge(argsCmd.ToParameterMap());
            }

            return cmdProps;
        }

        private Properties LoadConfigurationFromPropertiesFile()
        {
            const string propertiesFileName = "application.properties";

            var levelOnePath = AppUtil.ApplicaitonBinaryFolder + @"\" + propertiesFileName;
            var levelTwoPath = AppUtil.AppDataFolder + @"\" + propertiesFileName;

            return LoadProperties(levelOnePath).Merge(LoadProperties(levelTwoPath));
        }

        private Properties LoadProperties(string path)
        {
            var properties = new Properties();

            if (File.Exists(path))
            {
                var tmp = PropertiesParser.Parse(path);
                properties.Merge(tmp);
            }

            return properties;
        }
    }
}

{'fraction_non_alphanumeric': 0.07778556412053259, 'fraction_numerical': 0.000700770847932726, 'mean_word_length': 2.120218579234973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3952622', 'n_tokens_mistral': 657, 'n_tokens_neox': 628, 'n_words': 131}