pseudodepseudonimizer_2.py 653 B

12345678910111213141516171819
  1. def dots2numberedDots(all_text, replace_string="..."):
  2. replace_string = re.escape(replace_string)
  3. dots_regex = re.compile(r"(\s)[A-Z]?\[?({})\]?(\s)".format(replace_string))
  4. all_text = dots_regex.sub(dots_repl, all_text)
  5. return all_text
  6. if __name__ == '__main__':
  7. parser = argopt(__doc__).parse_args()
  8. input_path = parser.i
  9. output_path = parser.o
  10. string_to_replace = parser.s
  11. with open(input_path, "r") as filo:
  12. all_text = filo.read()
  13. numbered_dots_text = dots2numberedDots(all_text, replace_string=string_to_replace)
  14. with open(output_path, "w") as filo:
  15. filo.write(numbered_dots_text)