This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch text2gql in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
commit 643a3bb804ead24ffee91aab69424629a512713e Author: Lriver <[email protected]> AuthorDate: Tue Sep 30 20:52:06 2025 +0800 feat: add configuration management module with dictionary paths and generation parameters --- text2gremlin/AST_Text2Gremlin/base/Config.py | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/text2gremlin/AST_Text2Gremlin/base/Config.py b/text2gremlin/AST_Text2Gremlin/base/Config.py new file mode 100644 index 00000000..e64ebb18 --- /dev/null +++ b/text2gremlin/AST_Text2Gremlin/base/Config.py @@ -0,0 +1,66 @@ + +""" +项目配置管理模块。 + +负责加载和管理项目配置文件,提供各模块所需的配置参数。 +""" + +import json +import os +import sys + + +class Config: + def __init__(self, file_path): + self.file_path = file_path + self.config_data = self.load_config() + self.gen_query = self.config_data.get( + "genQuery" + ) # default genQuery,can be set as translate + self.db_id = self.config_data.get("db_id") + + def load_config(self): + with open(self.file_path, "r") as file: + return json.load(file) + + def get_input_query_path(self): + return self.config_data.get("input_query_path") + + def get_input_query_template_path(self): + return self.config_data.get("input_query_template_path") + + def get_input_corpus_dir_or_file(self): + return self.config_data.get("input_corpus_dir_or_path") + + def set_input_corpus_dir_or_file(self, dir_or_file): + self.config_data["input_corpus_dir_or_path"] = dir_or_file + + def get_output_path(self): + if self.gen_query: + dir_or_file = self.config_data.get("output_query_dir_or_file") + if os.path.isdir(dir_or_file): + output_path = os.path.join(dir_or_file, self.db_id + ".txt") + return output_path + else: + return dir_or_file + else: + return self.config_data.get("output_prompt_path") + + def get_output_corpus(self): + return self.config_data.get("output_corpus_path") + + def get_schema_dict_path(self): + return self.config_data.get("schema_dict_path") + + def get_syn_dict_path(self): + return self.config_data.get("syn_dict_path") + + def get_db_id(self): + return self.db_id + + def get_schema_path(self, db_id): + schema_dict = self.config_data.get("db_schema_path") + return schema_dict[db_id] # todo error check + + def get_config(self, module_name): + return self.config_data.get(module_name)
