<commit_before>## Miscellaneous Helpful Functions
# Written by <NAME>

try:
    import configparser
except ImportError:
    import ConfigParser as configparser
import inspect
import os.path
from os.path import abspath, dirname, expanduser, realpath

def get_called_script_dir():
    """
    Return the directory that the top-level running script is in.
    """
    bottom_stack_frame = inspect.stack()[-1][0]
    called_script_path = inspect.getfile(bottom_stack_frame)
    return realpath(abspath(dirname(called_script_path)))

def get_config_path(filename):
    """
    Return the full path to a config file named <filename> in the same
    directory as the top-level running script.
    """
    config_dir = get_called_script_dir()
    config_path = os.path.join(config_dir, filename)
    config_path = realpath(abspath(expanduser(config_path)))
    return config_path

def read_config(filename):
    """
    Read a config file named <filename>, from the same directory as
    the top-level running script, using configparser.
    """
    config_path = get_config_path(filename)
    config = configparser.ConfigParser()
    config.read(config_path)
    return config

def save_config(config, filename):
    config_dir = get_called_script_dir()
    config_path = os.path.join(config_dir, filename)
    with open(config_path, 'w') as f:
        config.write(f)<commit_msg>MINOR: Add docstring<commit_after>## Miscellaneous Helpful Functions
# Written by <NAME>

try:
    import configparser
except ImportError:
    import ConfigParser as configparser
import inspect
import os.path
from os.path import abspath, dirname, expanduser, realpath

def get_called_script_dir():
    """
    Return the directory that the top-level running script is in.
    """
    bottom_stack_frame = inspect.stack()[-1][0]
    called_script_path = inspect.getfile(bottom_stack_frame)
    return realpath(abspath(dirname(called_script_path)))

def get_config_path(filename):
    """
    Return the full path to a config file named <filename> in the same
    directory as the top-level running script.
    """
    config_dir = get_called_script_dir()
    config_path = os.path.join(config_dir, filename)
    config_path = realpath(abspath(expanduser(config_path)))
    return config_path

def read_config(filename):
    """
    Read a config file named <filename>, from the same directory as
    the top-level running script, using configparser.
    """
    config_path = get_config_path(filename)
    config = configparser.ConfigParser()
    config.read(config_path)
    return config

def save_config(config, filename):
    """
    Save a configparser configuration to <filename>, in the same
    directory as the top-level running script.
    """
    config_dir = get_called_script_dir()
    config_path = os.path.join(config_dir, filename)
    with open(config_path, 'w') as f:
        config.write(f)
{'fraction_non_alphanumeric': 0.08816383200277682, 'fraction_numerical': 0.0013884068031933356, 'mean_word_length': 4.003472222222222, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '6143006', 'n_tokens_mistral': 853, 'n_tokens_neox': 847, 'n_words': 246}