<commit_before>"""utils.py: Contains useful utilities to be used in other modules."""

__author__ = "<NAME>"
__email__ = "<EMAIL>"


from decorator import decorator
from IPython.terminal.embed import InteractiveShellEmbed

@decorator
def synchronized(func, *args, **kwargs):
    """Function decorator to make function synchronized on ``self._lock``.

    If the first argument to the function (hopefully self) does not have a _lock
    attribute, then this decorator does nothing.
    """
    if not (args and hasattr(args[0], '_lock')):
        return func(*args, **kwargs)
    with args[0]._lock: # pylint: disable=W0212
        return func(*args, **kwargs)

interact = InteractiveShellEmbed(
    banner1="---Starting Interactive Shell---\n",
    exit_msg="---Resuming Program---\n")

# TODO: util for capturing stdout and TEEing it to a file (either concat or overwrite)<commit_msg>Commenting out interaction<commit_after>"""utils.py: Contains useful utilities to be used in other modules."""

__author__ = "<NAME>"
__email__ = "<EMAIL>"


from decorator import decorator
from IPython.terminal.embed import InteractiveShellEmbed

@decorator
def synchronized(func, *args, **kwargs):
    """Function decorator to make function synchronized on ``self._lock``.

    If the first argument to the function (hopefully self) does not have a _lock
    attribute, then this decorator does nothing.
    """
    if not (args and hasattr(args[0], '_lock')):
        return func(*args, **kwargs)
    with args[0]._lock: # pylint: disable=W0212
        return func(*args, **kwargs)

# TODO: figure out why this causes the REPL to change and fix it
# interact = InteractiveShellEmbed(
#     banner1="---Starting Interactive Shell---\n",
#     exit_msg="---Resuming Program---\n")

# TODO: util for capturing stdout and TEEing it to a file (either concat or overwrite)
{'fraction_non_alphanumeric': 0.11704422869471413, 'fraction_numerical': 0.007551240560949299, 'mean_word_length': 4.013513513513513, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2918257', 'n_tokens_mistral': 557, 'n_tokens_neox': 521, 'n_words': 200}