Skip to content
Snippets Groups Projects
Select Git revision
  • e97f5706948ff455b61b3942afb5f389b783aad3
  • master default protected
  • deanonimzer
  • v2 protected
  • v1 protected
  • develop protected
6 results

cli.py

Blame
  • cli.py 1.25 KiB
    """Script for running the anonymizer from the command line.
    
    Example usage:
    ```bash
    python3 cli.py input.ccl output.txt --replace-method tag --language pl \
        --configuration ccl
    ```
    """
    
    import argparse
    
    from src.worker import Worker
    
    if __name__ == "__main__":
        parser = argparse.ArgumentParser(description="anonymizer")
        parser.add_argument("input_path", type=str, help="Path to the input file")
        parser.add_argument("output_path", type=str, help="Path to the output file")
        parser.add_argument(
            "--replace-method",
            type=str,
            default="tag",
            choices=["delete", "tag", "pseudo"],
            help="Method of replacing tokens",
        )
        parser.add_argument(
            "--language",
            type=str,
            default="pl",
            choices=["pl"],
            help="Language of the input text",
        )
        parser.add_argument(
            "--configuration",
            type=str,
            default="ccl",
            choices=["ccl", "wiktorner_jsonl"],
            help="Configuration of the anonymizer",
        )
        args = parser.parse_args()
    
        worker = Worker(configuration=args.configuration)
        worker.process(
            args.input_path,
            {"method": args.replace_method, "language": args.language},
            args.output_path,
        )
        print("Done")