<commit_before>package net.rphp.TIGameBase;

import java.util.ArrayList;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Settings
{
	private HashMap<String, String> settings;
	private static Settings instance = null;

	private Settings(String filename)// throws ...
	{
		settings = new HashMap<String, String>();
		try {
			BufferedReader br = new BufferedReader(new FileReader(filename));
			String line;

			while((line = br.readLine()) != null) {
				if(line.matches("^\\s*|\\s*;.*"))
					continue;

				String[] setting = new String[2];
				setting = line.split("\\s*=\\s*");
				settings.put(setting[0], setting[1]);
			}

			br.close();
		}catch(FileNotFoundException e) {
			System.out.print(e.getMessage());
			e.printStackTrace();
		}catch(IOException e) {
			System.out.print("e");
		}
	}

	public static Settings loadSettings(String filename)
	{
		if(instance == null)
			instance = new Settings(filename);

		return instance;
	}

	public HashMap<String, String> getSettings()
	{
		return settings;
	}
}<commit_msg>Validates settings file to give missing settings a default value<commit_after>package net.rphp.TIGameBase;

import java.util.ArrayList;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Settings
{
	private HashMap<String, String> settings;
	private static Settings instance = null;

	private Settings(String filename)// throws ...
	{
		settings = new HashMap<String, String>();

		try {
			BufferedReader br = new BufferedReader(new FileReader(filename));
			String line;
			String[] setting = new String[2];

			while((line = br.readLine()) != null) {
				if(line.matches("^\\s*|\\s*;.*"))
					continue;

				setting = line.split("\\s*=\\s*");
				settings.put(setting[0], setting[1]);
			}

			br.close();
		}catch(FileNotFoundException e) {
			System.out.print(e.getMessage());
			e.printStackTrace();
		}catch(IOException e) {
			System.out.print("e");
		}

		validateSettings();
	}

	public static Settings loadSettings(String filename)
	{
		if(instance == null)
			instance = new Settings(filename);

		return instance;
	}

	private void validateSettings()
	{
		HashMap<String, String> defaultSettings = new HashMap<String, String>();

		defaultSettings.put("pregame", "true");

		for(String settingName : defaultSettings.keySet()) {
			if(!settings.containsKey(settingName)) {
				settings.put(settingName, defaultSettings.get(settingName));
			}
		}
	}

	public HashMap<String, String> getSettings()
	{
		return settings;
	}
}
{'fraction_non_alphanumeric': 0.14413075780089152, 'fraction_numerical': 0.002228826151560178, 'mean_word_length': 4.159003831417625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3614309', 'n_tokens_mistral': 940, 'n_tokens_neox': 829, 'n_words': 189}