'Provides a mechanism for sanitizing user input before presenting the
value to the backend.
A basic (override-able) implementation is provided.'

def clean(self, query_fragment):

    if (not isinstance(query_fragment, six.string_types)):
        return query_fragment
    words = query_fragment.split()
    cleaned_words = []
    for word in words:
        if (word in self.backend.RESERVED_WORDS):
            word = word.replace(word, word.lower())
        for char in self.backend.RESERVED_CHARACTERS:
            word = word.replace(char, (u'\\%s' % char))
        cleaned_words.append(word)
    return u'    '.join(cleaned_words)
