-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix name score according model. colorize message
- Loading branch information
Showing
6 changed files
with
106 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,89 @@ | ||
import json, sys | ||
|
||
from llm_semantic_annotator import get_retention_dir | ||
from llm_semantic_annotator import main_populate_owl_tag_embeddings | ||
from llm_semantic_annotator import main_populate_abstract_embeddings | ||
from llm_semantic_annotator import main_populate_gbif_taxon_tag_embeddings | ||
from llm_semantic_annotator import main_populate_ncbi_taxon_tag_embeddings | ||
from llm_semantic_annotator import main_compute_tag_chunk_similarities | ||
from llm_semantic_annotator import similarity_evaluator_main | ||
from llm_semantic_annotator import main_display_summary | ||
from llm_semantic_annotator import main_build_graph | ||
from llm_semantic_annotator import main_build_dataset_abstracts_annotation | ||
|
||
import json | ||
import sys | ||
import os | ||
from rich import print | ||
import argparse | ||
|
||
from llm_semantic_annotator import ( | ||
get_retention_dir, | ||
main_populate_owl_tag_embeddings, | ||
main_populate_abstract_embeddings, | ||
main_populate_gbif_taxon_tag_embeddings, | ||
main_populate_ncbi_taxon_tag_embeddings, | ||
main_compute_tag_chunk_similarities, | ||
similarity_evaluator_main, | ||
main_display_summary, | ||
main_build_graph, | ||
main_build_dataset_abstracts_annotation | ||
) | ||
|
||
def load_config(config_file): | ||
"""Charge la configuration à partir d'un fichier JSON.""" | ||
"""Load configuration from a JSON file.""" | ||
try: | ||
with open(config_file, 'r') as f: | ||
return json.load(f) | ||
except FileNotFoundError: | ||
print(f"Le fichier de configuration {config_file} est introuvable.") | ||
print(f"[bold red]Error:[/bold red] Configuration file {config_file} not found.") | ||
sys.exit(1) | ||
except json.JSONDecodeError: | ||
print(f"Erreur de décodage JSON dans le fichier {config_file}.") | ||
print(f"[bold red]Error:[/bold red] JSON decoding error in file {config_file}.") | ||
sys.exit(1) | ||
|
||
def parse_arguments(): | ||
"""Analyse les arguments de la ligne de commande.""" | ||
parser = argparse.ArgumentParser(description="Programme avec plusieurs types d'exécution.") | ||
"""Parse command line arguments.""" | ||
parser = argparse.ArgumentParser(description="Program with multiple execution types.") | ||
parser.add_argument( | ||
"config_file", | ||
help="Chemin vers le fichier de configuration JSON." | ||
help="Path to the JSON configuration file." | ||
) | ||
parser.add_argument( | ||
"execution_type", | ||
choices=["populate_owl_tag_embeddings", | ||
"populate_gbif_taxon_tag_embeddings", | ||
"populate_ncbi_taxon_tag_embeddings", | ||
"populate_abstract_embeddings", | ||
"compute_tag_chunk_similarities", | ||
"display_summary", | ||
"build_rdf_graph", | ||
"build_dataset_abstracts_annotations", | ||
"evaluate_encoder"], | ||
help="Type d'exécution à effectuer." | ||
choices=[ | ||
"populate_owl_tag_embeddings", | ||
"populate_gbif_taxon_tag_embeddings", | ||
"populate_ncbi_taxon_tag_embeddings", | ||
"populate_abstract_embeddings", | ||
"compute_tag_chunk_similarities", | ||
"display_summary", | ||
"build_rdf_graph", | ||
"build_dataset_abstracts_annotations", | ||
"evaluate_encoder" | ||
], | ||
help="Type of execution to perform." | ||
) | ||
|
||
parser.add_argument('--force', action='store_true', | ||
help="Forcer l'exécution sans demander de confirmation") | ||
|
||
help="Force execution without asking for confirmation") | ||
return parser.parse_args() | ||
|
||
def main(): | ||
import os | ||
args = parse_arguments() | ||
config = load_config(args.config_file) | ||
|
||
config['retention_dir'] = get_retention_dir(args.config_file) | ||
config['force'] = args.force | ||
|
||
if args.force: | ||
config['force'] = True | ||
else: | ||
config['force'] = False | ||
execution_functions = { | ||
"populate_owl_tag_embeddings": main_populate_owl_tag_embeddings, | ||
"populate_gbif_taxon_tag_embeddings": main_populate_gbif_taxon_tag_embeddings, | ||
"populate_ncbi_taxon_tag_embeddings": main_populate_ncbi_taxon_tag_embeddings, | ||
"populate_abstract_embeddings": main_populate_abstract_embeddings, | ||
"compute_tag_chunk_similarities": main_compute_tag_chunk_similarities, | ||
"display_summary": main_display_summary, | ||
"build_rdf_graph": main_build_graph, | ||
"build_dataset_abstracts_annotations": main_build_dataset_abstracts_annotation, | ||
"evaluate_encoder": similarity_evaluator_main | ||
} | ||
|
||
if args.execution_type == "populate_owl_tag_embeddings": | ||
main_populate_owl_tag_embeddings(config) | ||
elif args.execution_type == "populate_gbif_taxon_tag_embeddings": | ||
main_populate_gbif_taxon_tag_embeddings(config) | ||
elif args.execution_type == "populate_ncbi_taxon_tag_embeddings": | ||
main_populate_ncbi_taxon_tag_embeddings(config) | ||
elif args.execution_type == "populate_abstract_embeddings": | ||
main_populate_abstract_embeddings(config) | ||
elif args.execution_type == "compute_tag_chunk_similarities": | ||
main_compute_tag_chunk_similarities(config) | ||
elif args.execution_type == "display_summary": | ||
main_display_summary(config) | ||
elif args.execution_type == "build_rdf_graph": | ||
main_build_graph(config) | ||
elif args.execution_type == "build_dataset_abstracts_annotations": | ||
main_build_dataset_abstracts_annotation(config) | ||
elif args.execution_type == "evaluate_encoder": | ||
similarity_evaluator_main(config) | ||
else: | ||
raise ValueError("Type d'exécution non reconnu.") | ||
try: | ||
execution_function = execution_functions[args.execution_type] | ||
print(f"[bold green]Executing:[/bold green] {args.execution_type}") | ||
execution_function(config) | ||
except KeyError: | ||
print(f"[bold red]Error:[/bold red] Unrecognized execution type: {args.execution_type}") | ||
sys.exit(1) | ||
except Exception as e: | ||
print(f"[bold red]Error during execution:[/bold red] {str(e)}") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ pandas | |
tabulate | ||
np | ||
pytest | ||
colorama |