def apply_remove(self, s):
        if not self.removecheck:
            return s
        if self.remnonwords:
            s = re.sub("\W", "", s, flags=self.ignorecase)
        if self.remsymbols:
            allowed = string.ascii_letters + string.digits + " .-_+"  # []()
            for i in ["utf-8", "latin1"]:
                try:
                    # Convert bytestring to unicode and back.
                    s = "".join(c for c in normalize("NFKD", s.decode(i))
                                if c in allowed).encode("utf-8")
                    break
                except __HOLE__:
                    pass
            else:
                log.debug("Symbols: Could not decode {}.".format(s))
        if self.remdups:
            s = re.sub(r"([-_ .])\1+", r"\1", s, flags=self.ignorecase)
        return s
dataset/ETHPy150Open mikar/demimove/demimove/fileops.py/FileOps.apply_remove