'Return a function to preprocess the text before tokenization'

def build_preprocessor(self):

    if (self.preprocessor is not None):
        return self.preprocessor
    noop = (lambda x: x)
    if (not self.strip_accents):
        strip_accents = noop
    elif callable(self.strip_accents):
        strip_accents = self.strip_accents
    elif (self.strip_accents == u'ascii'):
        strip_accents = strip_accents_ascii
    elif (self.strip_accents == u'unicode'):
        strip_accents = strip_accents_unicode
    else:
        raise ValueError((u'Invalid    value    for    "strip_accents":    %s' % self.strip_accents))
    if self.lowercase:
        return (lambda x: strip_accents(x.lower()))
    else:
        return strip_accents
