Speeding up the replace_missing_word function by memoization.