Example #1
0
def parse_args():
    r""" Parse the command line arguments """
    args = ArgumentParser()
    args.add_argument("train",
                      help="Path from where to read the training file")
    args.add_argument("test", help="Path from where to read the test file")
    args.add_argument("out", help="Path write the generated labels")
    args.add_argument("--smooth",
                      help="Perform add-1 smoothing",
                      action="store_true")
    args = args.parse_args()

    for fld in ["train", "test"]:
        path = Path(args.__getattribute__(fld))
        if not path.is_file(): raise ValueError(f"Unknown {fld} file {path}")
        args.__setattr__(fld, path)
    args.out = Path(args.out)
    if args.out.exists() and not args.out.is_file():
        raise ValueError(
            f"Out file \"{args.out}\" appears not to be a file.  Cannot overwrite"
        )
    return args