<commit_before>package com.serebit.autotitan.data

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import java.io.File

val serializer: Gson = GsonBuilder().apply {
    serializeNulls()
}.create()

class DataManager(type: Class<*>) {
    private val parentFolder = File(DataManager::class.java.protectionDomain.codeSource.location.toURI()).parentFile
    val dataFolder = File("$parentFolder/data/${type.simpleName}").apply { mkdirs() }

    inline fun <reified T> read(fileName: String): T? {
        val file = File("$dataFolder/$fileName")
        return if (file.exists()) serializer.fromJson(file.readText(), T::class.java) else null
    }

    fun write(fileName: String, obj: Any) {<commit_msg>Split read function into two functions, allowing dataFolder to become private<commit_after>package com.serebit.autotitan.data

import com.google.gson.Gson
import com.google.gson.GsonBuilder
import java.io.File

val serializer: Gson = GsonBuilder().apply {
    serializeNulls()
}.create()

class DataManager(type: Class<*>) {
    private val parentFolder = File(DataManager::class.java.protectionDomain.codeSource.location.toURI()).parentFile
    private val dataFolder = File("$parentFolder/data/${type.simpleName}").apply { mkdirs() }

    inline fun <reified T : Any> read(fileName: String): T? = read(fileName, T::class.java)

    fun <T : Any> read(fileName: String, type: Class<T>): T? {
        val file = File("$dataFolder/$fileName")
        return if (file.exists()) serializer.fromJson(file.readText(), type) else null
    }

    fun write(fileName: String, obj: Any) {
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.0, 'mean_word_length': 4.484536082474227, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6076435', 'n_tokens_mistral': 497, 'n_tokens_neox': 497, 'n_words': 116}