def preprocess ( string ) : string = unicode ( string , encoding = "utf-8" ) # convert diacritics to simpler forms string = regex1 . sub ( lambda x : accents [ x . group ( ) ] , string ) # remove all rest of the unwanted characters return regex2 . sub ( '' , string ) . encode ( 'utf-8' )
return the string after removing all alphabets python
Preprocess string to transform all diacritics and remove other special characters than appropriate : param string : : return :
def preprocess(string):
    """
    Preprocess string to transform all diacritics and remove other special characters than appropriate
    
    :param string:
    :return:
    """
    string = unicode(string, encoding="utf-8")
    # convert diacritics to simpler forms
    string = regex1.sub(lambda x: accents[x.group()], string)
    # remove all rest of the unwanted characters
    return regex2.sub('', string).encode('utf-8')