def get_regex(keyword, template):
    """
    Turn a keyword into a regex, according to a template id:
    - template 0 is for stems
    - template 1 is for one-word expressions
    - template 2 is for two-word expressions; the two words can appear in the sentence in different order with optional other words in between them

    Parameters
    ----------
    keyword: str
    template: int

    Returns
    -------
    regex: str
    """
    if template == 0:
        return rf"\b{keyword}.*?\b"
    elif template == 1:
        return rf"\b{keyword}\b"
    elif template == 2:
        kwd1, kwd2 = keyword.split(' ')
        return rf"\b{kwd1}\b[^.]*?\b{kwd2}\b|\b{kwd2}\b[^.]*?\b{kwd1}\b"