<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace(dict,line):
 """ Find and replace the special words according to the dictionary. Parameters ========== dict : Dictionary A dictionary derived from a yaml file. Source language as keys and the target language as values. line : String A string need to be processed. """

    words = line.split()
    new_line = ""

    for word in words:
        fst = word[0]
        last = word[-1]
        # Check if the word ends with a punctuation
        if last == "," or last == ";" or last == ".":
            clean_word = word[0:-1]
            last = last + " "
        elif last == "]":
            clean_word = word[0:-1]
        else:
            clean_word = word
            last = " "

        # Check if the word starts with "["
        if fst == "[":
            clean_word = clean_word[1:]
        else:
            clean_word = clean_word
            fst = ""

        find = dict.get(clean_word)

        if find == None:
            new_line = new_line + fst + str(clean_word) + last
        else:
            new_line = new_line + fst + str(find) + last
            
    return new_line