def clean_whitespace(chatbot, statement):
 import re
 statement.text = statement.text.replace('\n', ' ').replace('\r', ' ').replace(' DCTB ', ' ')
 statement.text = statement.text.strip()
 statement.text = re.sub(' +', ' ', statement.text)
 return statement

def clean_whitespace ( chatbot , statement ) : import re statement . text = statement . text . replace ( '\n' , ' ' ) . replace ( '\r' , ' ' ) . replace ( ' DCTB ' , ' ' ) statement . text = statement . text . strip ( ) statement . text = re . sub ( ' +' , ' ' , statement . text ) return statement
remove any consecutive whitespace characters from the statement text .