This commit is contained in:
hsafaei
2026-06-15 13:12:04 +03:30
parent 488eb98fec
commit 0bc3f9a633
5 changed files with 1653 additions and 34 deletions
File diff suppressed because it is too large Load Diff
+64 -7
View File
@@ -31,6 +31,9 @@ def recersive_sections(
"""
title = section.get("title", "").strip()
section_list = section.get("section_list", [])
if not section_list :
section_list = section.get("sections", [])
description = section.get("definition", "").strip()
tags = section.get("keywords", [])
@@ -66,6 +69,12 @@ def recersive_sections(
# Process subsections (children)
subsections = section.get("subsections", [])
if not subsections :
subsections = section.get("subnodes", [])
if not subsections :
subsections = section.get("sub_title", [])
if subsections :
for idx, subsec in enumerate(subsections, start=1):
recersive_sections(
@@ -280,17 +289,25 @@ def import_v2_section_list(elastic, all_codes, folder_path, index_name="mj_plan"
data_tree = DataHelper.load_orjson(file_path)
if data_tree["title"] :
code_name = data_tree["title"]
code_name = code_name.replace("قانون جامع", "").strip()
if data_tree["subsections"] :
if "subsections" in data_tree :
root_node = data_tree["subsections"]
if "sub_title" in data_tree :
root_node = data_tree["sub_title"]
if "subnodes" in data_tree :
root_node = data_tree["subnodes"]
except Exception as e:
print(output)
continue
item_found = [item for item in all_codes if item.get("title") == code_name]
if not item_found :
print("* " * 10, " error in code_name ", key, code_name)
print("* " * 10, " error in code_name ", code_name)
continue
@@ -326,6 +343,7 @@ def import_v2_section_list(elastic, all_codes, folder_path, index_name="mj_plan"
return list_codes_imported
load_dotenv(dotenv_path='config.env')
host=os.getenv('HOST_160')
@@ -350,20 +368,59 @@ with open("./data/codes49.json", "r", encoding="utf8") as f:
## ---------------------------------------------------------
# .\.env\Scripts\activate
# python -m app.majles.majles_plans_import
# #--- برای گلان خبره استفاده شد
# D49_TgV1
# #--- D49_oss120 پلان ai - نسخه 1
# import_v1(elastic, all_codes, "D49_oss120")
# list_codes_imported=[]
# file_path = r"G:\Project2\102_gpu\v3\plan_dict_def_keyword.json"
# file_path = r"G:\Project2\102_gpu\match_plan\v2_0\plan_dict_def_keyword.json"
# import_v2_full_tree(elastic, all_codes, file_path, "mj_plan", list_codes_imported, "D49_oss120_gemma")
folder_path = r"G:\Project2\102_gpu\match_plan\v2"
list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_gemma_matched")
# folder_path = r"G:\Project2\102_gpu\match_plan\v3.0"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_gemma_matched")
# folder_path = r"G:\Project2\102_gpu\match_plan\v3.01"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_gemma_matched_2")
# folder_path = r"G:\Project2\102_gpu\match_plan\v3.02"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_gemma_matched_3")
# folder_path = r"G:\Project2\102_gpu\match_plan\v4"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_matched_4")
# folder_path = r"G:\Project2\102_gpu\match_plan\v4.1"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_matched_4-1")
# folder_path = r"G:\Project2\102_gpu\match_plan\v4.2"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_matched_4-2")
# folder_path = r"G:\Project2\102_gpu\match_plan\v4.3"
# list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss120_matched_4-3")
folder_path = r"G:\Project2\102_gpu\match_plan\v5"
list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_gemma4_5")
folder_path = r"G:\Project2\102_gpu\match_plan\v5.1_gemma"
list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_gemma4_5_1")
folder_path = r"G:\Project2\102_gpu\match_plan\v5.1_oss"
list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_oss_5_1")
folder_path = r"G:\Project2\102_gpu\match_plan\v5.1_yourmind"
list_codes_imported = import_v2_section_list(elastic, all_codes, folder_path, "mj_plan", "D49_yourmind_5_1")
## ---------------------------------------------------------
## ---------------------------------------------------------
# .\.env\Scripts\activate
# python -m app.majles.majles_plans_import