<commit_before>/*
 * Enfili
 * Project hosted at https://github.com/ryanhosp/enfili/
 * Copyright 2013 <NAME>
 *    
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.r573.enfili.common.io;

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

public class AppConfig {
	private static final String CONFIG_FILE_PATH = "/config.properties";

	private static AppConfig instance;
	private Properties config;

	private AppConfig(String configFilePath) {
		try {
			config = new Properties();
			InputStream is = this.getClass().getResourceAsStream(configFilePath);
			config.load(is);
		} catch (IOException e) {
			throw new RuntimeException("Unable to load config file " + configFilePath);
		}
	}

	public String getConfig(String key) {
		return config.getProperty(key);
	}
	public int getConfigAsInt(String key) {
		return Integer.parseInt(config.getProperty(key));
	}
	public long getConfigAsLong(String key) {
		return Long.parseLong(config.getProperty(key));
	}
	public static AppConfig getInstance() {
		if(instance == null) {
			throw new IllegalStateException("AppConfig needs to be initialized before use by calling one of the init methods");
		}
		return instance;
	}
	
	public static void init(){
		init(CONFIG_FILE_PATH);
	}
	public static void init(String configFilePath){
		instance = new AppConfig(configFilePath);
	}
}<commit_msg>Added some comments to AppConfig<commit_after>/*
 * Enfili
 * Project hosted at https://github.com/ryanhosp/enfili/
 * Copyright 2013 <NAME>
 *    
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.r573.enfili.common.io;

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

/**
 * Loads a config file from the classpath (e.g. file in src/main/resources compiled into the JAR under the Maven directly structure)
 * To load from the root of the classpath, remember to prepend paths with "/"
 * Used as Singleton
 * 
 * @author ryanho
 *
 */
public class AppConfig {
	private static final String CONFIG_FILE_PATH = "/config.properties";

	private static AppConfig instance;
	private Properties config;

	private AppConfig(String configFilePath) {
		try {
			config = new Properties();
			InputStream is = this.getClass().getResourceAsStream(configFilePath);
			config.load(is);
		} catch (IOException e) {
			throw new RuntimeException("Unable to load config file " + configFilePath);
		}
	}

	public String getConfig(String key) {
		return config.getProperty(key);
	}
	public int getConfigAsInt(String key) {
		return Integer.parseInt(config.getProperty(key));
	}
	public long getConfigAsLong(String key) {
		return Long.parseLong(config.getProperty(key));
	}
	public static AppConfig getInstance() {
		if(instance == null) {
			throw new IllegalStateException("AppConfig needs to be initialized before use by calling one of the init methods");
		}
		return instance;
	}
	
	/**
	 * Initializes AppConfig using the default config path "/config.properties"
	 */
	public static void init(){
		init(CONFIG_FILE_PATH);
	}
	public static void init(String configFilePath){
		instance = new AppConfig(configFilePath);
	}
}
{'fraction_non_alphanumeric': 0.0902327813774898, 'fraction_numerical': 0.005279577633789297, 'mean_word_length': 4.203495630461923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4888471', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1141, 'n_words': 426}