<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_filter(filter_or_string, *args, **kwargs):
 """ Overloaded filter construction. If ``filter_or_string`` is a string we look up it's corresponding class in the filter registry and return it. Otherwise, assume ``filter_or_string`` is an instance of a filter. :return: :class:`~es_fluent.filters.Filter` """

    if isinstance(filter_or_string, basestring):
        # Names that start with `~` indicate a negated filter.
        if filter_or_string.startswith('~'):
            filter_name = filter_or_string[1:]
            return ~FILTER_REGISTRY[filter_name](*args, **kwargs)
        else:
            filter_name = filter_or_string
            return FILTER_REGISTRY[filter_name](*args, **kwargs)
    else:
        return filter_or_string