firstwe define range of frequent emoticons and their replacements in dictionary although we could find more distinct replacementswe go with obvious positive or negative words to help the classifieremo_repl positive emoticons "&lt; "good "": "good ": in lower case ":dd"good ":dd in lower case " )"good "":-)"good "":)"good "";)"good ""(-:"good ""(:"good "negative emoticons":/"bad "":&gt;"sad "":')"sad "":-("bad "":("bad "": "bad "":- "bad "make sure that :dd is replaced before : emo_repl_order [ for (k_len,kin reversed(sorted([(len( ),kfor in emo_repl keys()]))thenwe define abbreviations as regular expressions together with their expansions (\ marks the word boundary)re_repl "\br\ ""are" "\bu\ ""you" "\bhaha\ ""ha" "\bhahaha\ ""ha" "\bdon' \ ""do not" "\bdoesn' \ ""does not" "\bdidn' \ ""did not" "\bhasn' \ ""has not" "\bhaven' \ ""have not" "\bhadn' \ ""had not" "\bwon' \ ""will not"