<commit_before>package big.marketing;

import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Settings {
	static Logger logger = Logger.getLogger(Settings.class);

	private static Properties properties = new Properties();
	private static final String configFile = "eyeNet.properties";

	public static String get(String key) {
		return properties.getProperty(key);
	}

	public static int getInt(String key) {
		return Integer.parseInt(get(key));
	}

	public static void loadConfig() {
		try {
			properties.load(new FileReader(configFile));
			logger.info("Successfully read config from file " + configFile);
		} catch (IOException e) {
			logger.error("Could not load Settings from " + configFile + "! Exiting...");
			System.exit(1);
		}
	}

}<commit_msg>hierarchical configs only changed settings have to be in eyeNet.properties, all other settings are taken from the template<commit_after>package big.marketing;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Settings {
	static Logger logger = Logger.getLogger(Settings.class);

	private static Properties properties = new Properties();
	private static final String configFile = "eyeNet.properties";
	private static final String defaultConfigFile = "eyeNet.properties.template";

	public static String get(String key) {
		return properties.getProperty(key);
	}

	public static int getInt(String key) {
		return Integer.parseInt(get(key));
	}

	public static void loadConfig() {

		boolean defaultConfigOK = loadConfigFile(defaultConfigFile);

		// this enables hierarchical properties:
		// eyeNet.properties doesn't have to contain all settings, only the ones different from default
		// settings not existing in eyeNet.properties are getting the default value
		properties = new Properties(properties);

		boolean userConfigOK = loadConfigFile(configFile);

		if (!userConfigOK) {

			if (!defaultConfigOK) {
				logger.fatal("Could not load any config, exiting...");
				System.exit(1);
			} else {
				// no user config file existing, saving default config as user config
				try {
					properties.store(new FileWriter(configFile), "");
				} catch (IOException e) {
					logger.warn("Could not write config file to " + configFile);
				}
			}

		}

	}

	private static boolean loadConfigFile(String fileName) {
		try {
			properties.load(new FileReader(fileName));
			logger.info("Successfully read config from file " + fileName);
			return true;
		} catch (IOException e) {
			logger.warn("Could not load Settings from " + fileName);
			return false;
		}
	}

}
{'fraction_non_alphanumeric': 0.09900258588843738, 'fraction_numerical': 0.0014776505356483192, 'mean_word_length': 4.278752436647173, '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': '5193625', 'n_tokens_mistral': 829, 'n_tokens_neox': 744, 'n_words': 238}