import re


def _apply_numbers_pipeline(text):
    """
    Applies a the number substitution pipeline to a text.

    Parameters
    ----------
    text : str
        Text to preprocess.

    Returns
    -------
    text : str
        Preprocessed text.
    additional_metric : float
        Preprocessing amount metric.

    """
    additional_metric = len(re.findall('[0-9]', text)) / max(len(text), 1)
    text = re.sub('0', 'o', text)
    text = re.sub('1', 'i', text)
    text = re.sub('2', 'z', text)
    text = re.sub('3', 'e', text)
    text = re.sub('4', 'a', text)
    text = re.sub('5', 's', text)
    text = re.sub('7', 't', text)
    text = re.sub('8', 'ate', text)
    return text, additional_metric