Skip to content
Snippets Groups Projects
Commit 083a9d89 authored by Charlotte Mauvezin's avatar Charlotte Mauvezin
Browse files

Correctif Chaza

parent 1eed43c8
No related branches found
No related tags found
1 merge request!10Multiple input
Pipeline #103824 passed
...@@ -568,7 +568,7 @@ def run_multiple(file_csv, folder, threshold): ...@@ -568,7 +568,7 @@ def run_multiple(file_csv, folder, threshold):
else: else:
raise f"No file found for files {annot}, {predict}" raise f"No file found for files {annot}, {predict}"
else: else:
raise "This is no folder" raise Exception("the path indicated does not lead to a folder.")
def threshold_float_type(arg): def threshold_float_type(arg):
...@@ -588,23 +588,27 @@ def main(): ...@@ -588,23 +588,27 @@ def main():
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(description="Compute score of NER on predict.") parser = argparse.ArgumentParser(description="Compute score of NER on predict.")
parser.add_argument(
"-m",
"--multiple",
help="Single if 1, multiple 2",
type=int,
required=True,
)
parser.add_argument( parser.add_argument(
"-a", "-a",
"--annot", "--annot",
help="Annotation in BIO format.", help="Annotation in BIO format.",
required=False,
) )
parser.add_argument( parser.add_argument(
"-p", "-p",
"--predict", "--predict",
help="Prediction in BIO format.", help="Prediction in BIO format.",
required=False,
) )
parser.add_argument( parser.add_argument(
"-t", "-t",
"--threshold", "--threshold",
help="Set a distance threshold for the match between gold and predicted entity.", help="Set a distance threshold for the match between gold and predicted entity.",
required=False,
default=THRESHOLD, default=THRESHOLD,
type=threshold_float_type, type=threshold_float_type,
) )
...@@ -612,24 +616,33 @@ def main(): ...@@ -612,24 +616,33 @@ def main():
"-c", "-c",
"--csv", "--csv",
help="Csv with the correlation between the annotation bio files and the predict bio files", help="Csv with the correlation between the annotation bio files and the predict bio files",
required=False,
type=Path, type=Path,
) )
parser.add_argument( parser.add_argument(
"-f", "-f",
"--folder", "--folder",
help="Folder containing the bio files referred to in the csv file", help="Folder containing the bio files referred to in the csv file",
required=False,
type=Path, type=Path,
) )
args = parser.parse_args() args = parser.parse_args()
if args.csv and args.folder: if args.multiple == 1 or args.multiple == 2:
run_multiple(args.csv, args.folder, args.threshold) if args.multiple == 2:
elif args.annot and args.predict: if not args.folder:
run(args.annot, args.predict, args.threshold) raise argparse.ArgumentError(args.folder, "-f must be given if -m is 2")
if not args.csv:
raise argparse.ArgumentError(args.folder, "-c must be given if -m is 2")
if args.folder and args.csv:
run_multiple(args.csv, args.folder, args.threshold)
if args.multiple == 1:
if not args.annot:
raise argparse.ArgumentError(args.folder, "-a must be given if -m is 1")
if not args.predict:
raise argparse.ArgumentError(args.folder, "-p must be given if -m is 1")
if args.annot and args.predict:
run(args.annot, args.predict, args.threshold)
else: else:
raise "You did not give the proper input" raise argparse.ArgumentTypeError("Value has to be 1 or 2")
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment