def preprocess(
    text,
    min_token_len=2,
    irrelevant_pos=["ADV", "PRON", "CCONJ", "PUNCT", "PART", "DET", "ADP", "SPACE"],
):
    """
    Given text, min_token_len, and irrelevant_pos carry out preprocessing of the text
    and return a preprocessed string.

    Parameters
    -------------
    text : (str)
        text to be preprocessed
    min_token_len : (int)
        minimum token length required to keep a token in the preprocessed text
    irrelevant_pos : (list)
        a list of irrelevant pos tags

    Returns
    -------------
    (str) the preprocessed text
    """
    clean_text = []

    for token in text:
        if (
            token.is_stop == False                # Check if it's not a stopword
            and len(token) > min_token_len        # Check if the word meets minimum threshold
            and token.pos_ not in irrelevant_pos  # Check if the POS is in the acceptable POS tags
            and not token.like_email              # Check if it's not an email
            and not token.like_url                # Check if it's not a url
            and token.is_alpha                    # Check if consist of alphabetic characters
            
        
        ):           
            lemma = token.lemma_                  # Take the lemma of the word
            clean_text.append(lemma.lower())
    return " ".join(clean_text)