<commit_before>package com.demigodsrpg.demigods.classic.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Map;

/**
 * Json file related utility methods.
 */
public class JsonFileUtil {
    // -- CONSTRUCTOR -- //

    /**
     * Private constructor to prevent instance calls.
     */
    private JsonFileUtil() {
    }

    // -- UTILITY METHODS -- //

    /**
     * Get the parent JsonSection from a json file.
     *
     * @param path     Path to the json file.
     * @param fileName The filename (incl. file extension).
     * @return The JsonSection for the entire file.
     */
    public static JsonSection getSection(String path, String fileName) {
        File dataFile = new File(path + fileName);
        if (!(dataFile.exists())) createFile(dataFile);
        return loadSection(dataFile);
    }

    /**
     * Load a JsonSection from a json file.
     *
     * @param dataFile The json file.
     * @return The JsonSectionf for the entire file.
     */
    @SuppressWarnings("unchecked")
    public static JsonSection loadSection(File dataFile) {
        Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
        try {
            FileInputStream inputStream = new FileInputStream(dataFile);
            InputStreamReader reader = new InputStreamReader(inputStream);
            Map<String, Object> sectionData = gson.fromJson(reader, Map.class);
            reader.close();
            return new JsonSection(sectionData);
        } catch (Exception oops) {
            oops.printStackTrace();
        }
        return null;
    }

    /**
     * Create a file and its directory path.
     *
     * @param dataFile The file object.
     */
    @SuppressWarnings("ResultOfMethodCallIgnored")
    public static void createFile(File dataFile) {
        try {
            // Create the directories.
            (dataFile.getParentFile()).mkdirs();

            // Create the new file.
            dataFile.createNewFile();<commit_msg>Fix typo.<commit_after>package com.demigodsrpg.demigods.classic.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Map;

/**
 * Json file related utility methods.
 */
public class JsonFileUtil {
    // -- CONSTRUCTOR -- //

    /**
     * Private constructor to prevent instance calls.
     */
    private JsonFileUtil() {
    }

    // -- UTILITY METHODS -- //

    /**
     * Get the parent JsonSection from a json file.
     *
     * @param path     Path to the json file.
     * @param fileName The filename (incl. file extension).
     * @return The JsonSection for the entire file.
     */
    public static JsonSection getSection(String path, String fileName) {
        File dataFile = new File(path + fileName);
        if (!(dataFile.exists())) createFile(dataFile);
        return loadSection(dataFile);
    }

    /**
     * Load a JsonSection from a json file.
     *
     * @param dataFile The json file.
     * @return The JsonSection for the entire file.
     */
    @SuppressWarnings("unchecked")
    public static JsonSection loadSection(File dataFile) {
        Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create();
        try {
            FileInputStream inputStream = new FileInputStream(dataFile);
            InputStreamReader reader = new InputStreamReader(inputStream);
            Map<String, Object> sectionData = gson.fromJson(reader, Map.class);
            reader.close();
            return new JsonSection(sectionData);
        } catch (Exception oops) {
            oops.printStackTrace();
        }
        return null;
    }

    /**
     * Create a file and its directory path.
     *
     * @param dataFile The file object.
     */
    @SuppressWarnings("ResultOfMethodCallIgnored")
    public static void createFile(File dataFile) {
        try {
            // Create the directories.
            (dataFile.getParentFile()).mkdirs();

            // Create the new file.
            dataFile.createNewFile();
{'fraction_non_alphanumeric': 0.10274135876042909, 'fraction_numerical': 0.0, 'mean_word_length': 2.2909803921568628, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6988484', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1131, 'n_words': 320}