def recapitalize(text):
 text = text.lower()
 capsRE = re.compile('(?:^|(?<=[\\.\\?\\!] ))([a-z])')
 text = capsRE.sub((lambda x: x.group(1).upper()), text)
 return text

def recapitalize ( text ) : text = text . lower ( ) capsRE = re . compile ( '(?:^|(?<=[\\.\\?\\!] ))([a-z])' ) text = capsRE . sub ( ( lambda x : x . group ( 1 ) . upper ( ) ) , text ) return text
recapitalizes text .