<commit_before># Author: <NAME>
# Content: Functions to interact with the user


def read_integer(msg=None, error_msg=None):
    """
    Asks the user for an integer value (int or long)
    :param msg: The message, displayed to the user.
    :param error_msg: The message, displayed to the user, in case he did not entered a valid int or long.
    :return: An int or a long from the user.
    """
    res = raw_input(msg)
    if isinstance(res, int):
        return int(res)
    if isinstance(res, long):
        return long(res)

    if error_msg is not None:
        print(error_msg)
    return read_integer(msg)


def read_yesno(msg="[Y/n]", error_msg="Unrecognized input!"):
    """
    Asks the user to input yes or no.
    :param msg: The message, displayed to the user.
    :param error_msg: The message, displayed to the user, in case he did not entered "y", "yes", "n" or "no".
    :return: True if he entered "y" or "yes"; otherwise False.
    """
    res = input(msg)
    if res.lower() in ["y", "yes"]:
        return True
    if res.lower() in ["n", "no"]:
        return False

    if error_msg is not None:
        print(error_msg)
    return read_yesno(msg, error_msg)<commit_msg>read_yesno default_input param<commit_after># Author: <NAME>
# Content: Functions to interact with the user (ui = User Interface)


def read_integer(msg=None, error_msg=None):
    """
    Asks the user for an integer value (int or long)
    :param msg: The message, displayed to the user.
    :param error_msg: The message, displayed to the user, in case he did not entered a valid int or long.
    :return: An int or a long from the user.
    """
    res = raw_input(msg)
    if isinstance(res, int):
        return int(res)
    if isinstance(res, long):
        return long(res)

    if error_msg is not None:
        print(error_msg)
    return read_integer(msg)


def read_yesno(msg="[Y/n]", error_msg="Unrecognized input!", default_input=None):
    """
    Asks the user to input yes or no.
    :param msg: The message, displayed to the user.
    :param error_msg: The message, displayed to the user, in case he did not entered "y", "yes", "n" or "no".
    :param default_input: The value to return, in case the user entered "". Pass None to ask the user again.
    :return: True if he entered "y" or "yes"; otherwise False.
    """
    res = input(msg)
    if res.lower() in ["y", "yes"]:
        return True
    if res.lower() in ["n", "no"]:
        return False
    if default_input is not None and res == "":
        return default_input

    if error_msg is not None:
        print(error_msg)
    return read_yesno(msg, error_msg)
{'fraction_non_alphanumeric': 0.1080773606370876, 'fraction_numerical': 0.0, 'mean_word_length': 2.8908554572271385, 'pattern_counts': {'":': 1, '<': 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': '1818382', 'n_tokens_mistral': 831, 'n_tokens_neox': 816, 'n_words': 338}