22import glob
33import argparse
44import rdflib
5- from config import args
5+ from strings2things . config import args
66from strings2things .sparql import (
77 strings_to_things_query ,
88 things_to_strings_query
@@ -36,7 +36,7 @@ def initialize_graphs(ontology_path, kg_path, ontology_uri, kg_uri):
3636 return dataset
3737
3838
39- def strings_to_things (dataset , output_file = "subgraph.ttl" ):
39+ def strings_to_things (dataset , output_file = args . output ):
4040 """
4141 Replace human-readable strings in the KG with ontology IRIs based on matches.
4242 """
@@ -50,7 +50,7 @@ def strings_to_things(dataset, output_file="subgraph.ttl"):
5050 print (f"Strings replaced with IRIs and written to { output_file } ({ len (new_graph )} triples)." )
5151
5252
53- def things_to_strings (dataset , output_file = "output.ttl" ):
53+ def things_to_strings (dataset , output_file = args . output ):
5454 """
5555 Replace IRIs in the KG with human-readable labels using the ontology.
5656 """
@@ -65,14 +65,6 @@ def things_to_strings(dataset, output_file="output.ttl"):
6565
6666
6767def main ():
68- parser = argparse .ArgumentParser (description = "Convert between strings and ontology terms." )
69- parser .add_argument ("direction" , choices = ["string2thing" , "thing2string" ], help = "Conversion direction" )
70- parser .add_argument ("--ontology" , required = True , help = "Path to ontology files directory" )
71- parser .add_argument ("--kg" , required = True , help = "Path to knowledge graph files directory" )
72- parser .add_argument ("--ontology-uri" , default = "https://imaging-plaza.epfl.ch/ontology#" , help = "Named graph URI for ontology" )
73- parser .add_argument ("--kg-uri" , default = "https://imaging-plaza.epfl.ch/finalGraph" , help = "Named graph URI for knowledge graph" )
74- args = parser .parse_args ()
75-
7668 dataset = initialize_graphs (args .ontology , args .kg , args .ontology_uri , args .kg_uri )
7769
7870 if args .direction == "string2thing" :
0 commit comments