def remove_entities(status, entitylist):
try:<EOL><INDENT>entities = status.entities<EOL>text = status.text<EOL><DEDENT>except AttributeError:<EOL><INDENT>entities = status.get('<STR_LIT>', dict())<EOL>text = status['<STR_LIT:text>']<EOL><DEDENT>indices = [ent['<STR_LIT>'] for etype, entval in list(entities.items()) for ent in entval if etype in entitylist]<EOL>indices.sort(key=lambda x: x[<NUM_LIT:0>], reverse=True)<EOL>for start, end in indices:<EOL><INDENT>text = text[:start] + text[end:]<EOL><DEDENT>return text<EOL>
Remove entities for a list of items.