def filter_title(title, target_words, filter_words, filter_mode):
    """
    :param title is string of announcement's title
    :param target_words
    :param filter_words
    :param filter_mode can take 'AND' or 'OR'
    """
    if filter_mode == 'OR':
        for w_positive in target_words:
            if w_positive in title:
                for w_negative in filter_words:
                    if w_negative in title:
                        return False
                return True
        return False
    elif filter_mode == 'AND':
        for w_positive in target_words:
            if w_positive not in title:
                return False
        for w_negative in filter_words:
            if w_negative in title:
                return False
        return True
