From e4a92befb75b2ac633c4ce7b48316f211972aa6d Mon Sep 17 00:00:00 2001 From: ajokar Date: Mon, 9 Jun 2025 21:16:15 +0330 Subject: [PATCH] classification to elastic 160 --- ai_json_move_to_index.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ai_json_move_to_index.py b/ai_json_move_to_index.py index 92cdf4e..d0dff88 100644 --- a/ai_json_move_to_index.py +++ b/ai_json_move_to_index.py @@ -136,6 +136,7 @@ def moveClassifierAiCodes(elastic, index_name_o, data): text_normal = TextNormalizer() index = 0 percent_prev = 0 + send_round = 1 list_bulk=[] for item in data: index += 1 @@ -144,13 +145,13 @@ def moveClassifierAiCodes(elastic, index_name_o, data): # print("progress -> %.2f %%" % percent) # percent_prev = percent - id = item['id'] - other_codes = item['other-codes'] - best_codes = item['best_codes'] + id = item + best_code = data[item]['best-class'] + other_codes = data[item]['other-classes'] - ai_codes = [] - ai_code = {} + ai_code = best_code + ai_codes = other_codes list_bulk.append({ '_id': id, @@ -163,9 +164,12 @@ def moveClassifierAiCodes(elastic, index_name_o, data): if len(list_bulk) > 200 : elastic.updateBulkList(list_bulk, index_name_o) list_bulk = [] + print(f"send_round -> {send_round}") + send_round += 1 if len(list_bulk) : elastic.updateBulkList(list_bulk, index_name_o) + print(f"last ::: send_round -> {send_round}") @@ -194,7 +198,8 @@ password=os.getenv('HOST_160_PASS') print(host) # print(password) -path_base_map = "G:/Project2/gateway2_main/repo/_other/" +# path_base_map = "G:/Project2/gateway2_main/repo/_other/" +path_base_map = "" elastic = ElasticHelper(host, password, "elastic", path_base_map) @@ -204,7 +209,9 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) # moveZipSimplifies(elastic,"mj_qa_section", "G:\Work\_majles\_data\simpilified_final.zip") +with open("./data/all_sections_classes.json", "r", encoding="utf-8") as f: + classes = json.load(f) - -moveClassifierAiCodes(elastic,"mj_qa_section", []) +moveClassifierAiCodes(elastic,"mj_qa_section", classes) +print('finished!')