def replace_with_phrases(tokens, phrases):
    """Replace applicable tokens in semantically-ordered tokens
       with their corresponding phrase.

    Args:
        tokens (list of str): A list of semantically-ordered tokens.
        phrases (list of str): A list of phrases.

    Returns:
        list of str: A list of tokens which applicable tokens
            are replaced with a corresponding phrase.
    Examples:
        >>> print(tokens)
        ['it', 'is', 'straight', 'forward']

        >>> print(phrases)
        ['straight forward']

        >>> print(replace_with_phrases(tokens, phrases))
        ['it', 'is', 'straight forward']

    """

    tempTokens = tokens.copy()
    for phrase in phrases:
        phraseTokens = phrase.split(' ')
        isPhrase = False
        for i in range(len(tempTokens) + 1 - len(phraseTokens)):
            matches = 0
            for key, token in enumerate(phraseTokens):
                if tempTokens[i + key] == token:
                    matches += 1
            if matches == len(phraseTokens):
                isPhrase = True
                break

        if isPhrase:
            start = tempTokens.index(phraseTokens[0])
            end = start + len(phraseTokens)
            tempTokens[start:end] = [' '.join(phraseTokens)]
    return tempTokens