From 47b5a23fe27c911b124446f29ab7599aeecc3e0e Mon Sep 17 00:00:00 2001 From: Malo Revel <malo.revel@irisa.fr> Date: Thu, 20 Apr 2023 17:33:56 +0200 Subject: [PATCH] Add main --- main.py | 33 +++++++++++++++++++++++++++++++++ scorer.py | 6 ++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..fae8593 --- /dev/null +++ b/main.py @@ -0,0 +1,33 @@ +import stats +import scorer + +import os +import sys + +if __name__ == "__main__": + + if len(sys.argv) < 4: + print(f"Usage:\n\t$ python3 {sys.argv[0]} <corpus_sentences_path> <corpus_odrl_path> <output_odrl_path>") + print("Where:\n\t<corpus_sentences_path> is the path to the .txt source of the corpus") + print("\t<corpus_odrl_path> is the path to the .ttl data of the corpus") + print("\t<output_odrl_path> is the path to the .ttl output of the system on the corpus source") + exit(1) + + path_sentences = sys.argv[1] + if path_sentences[-1] != "/": path_sentences += "/" + path_target = sys.argv[2] + if path_target[-1] != "/": path_target += "/" + path_output = sys.argv[3] + if path_output[-1] != "/": path_output += "/" + + statistics = stats.main_stats(path_sentences, path_target) + + scores_modalities, scores_actions, scores_global = scorer.main_scorer(path_target, path_output) + + print(f"Corpus source: {path_sentences}\nCorpus data: {path_target}\nSystem output: {path_output}\n") + print("############ STATS ############\n") + print(statistics) + print("\n############ SCORES ###########\n") + print(f"# Modality scores:\n{scores_modalities}") + print(f"# Actions scores:\n{scores_actions}") + print(f"# Global scores:\n{scores_global}") diff --git a/scorer.py b/scorer.py index 513e3ad..5c4ce1f 100644 --- a/scorer.py +++ b/scorer.py @@ -163,11 +163,11 @@ def main_scorer(path_target, path_output): scores_actions = Scores() scores_global = Scores() - for fname in os.listdir(path_odrl): + for fname in os.listdir(path_target): if fname.endswith(".ttl"): odrl_target = ODRL() - odrl_target.parse(path_odrl + fname) + odrl_target.parse(path_target + fname) odrl_output = ODRL() odrl_output.parse(path_output + fname) @@ -186,7 +186,9 @@ if __name__ == "__main__": exit(1) path_target = sys.argv[1] + if path_target[-1] != "/": path_target += "/" path_output = sys.argv[2] + if path_output[-1] != "/": path_output += "/" scores_modalities, scores_actions, scores_global = main_scorer(path_target, path_output) -- GitLab