classification to elastic 160

This commit is contained in:
ajokar
2025-06-09 21:16:15 +03:30
parent 34dae25ba6
commit e4a92befb7
+15 -8
View File
@@ -136,6 +136,7 @@ def moveClassifierAiCodes(elastic, index_name_o, data):
text_normal = TextNormalizer() text_normal = TextNormalizer()
index = 0 index = 0
percent_prev = 0 percent_prev = 0
send_round = 1
list_bulk=[] list_bulk=[]
for item in data: for item in data:
index += 1 index += 1
@@ -144,13 +145,13 @@ def moveClassifierAiCodes(elastic, index_name_o, data):
# print("progress -> %.2f %%" % percent) # print("progress -> %.2f %%" % percent)
# percent_prev = percent # percent_prev = percent
id = item['id'] id = item
other_codes = item['other-codes'] best_code = data[item]['best-class']
best_codes = item['best_codes'] other_codes = data[item]['other-classes']
ai_codes = [] ai_code = best_code
ai_code = {} ai_codes = other_codes
list_bulk.append({ list_bulk.append({
'_id': id, '_id': id,
@@ -163,9 +164,12 @@ def moveClassifierAiCodes(elastic, index_name_o, data):
if len(list_bulk) > 200 : if len(list_bulk) > 200 :
elastic.updateBulkList(list_bulk, index_name_o) elastic.updateBulkList(list_bulk, index_name_o)
list_bulk = [] list_bulk = []
print(f"send_round -> {send_round}")
send_round += 1
if len(list_bulk) : if len(list_bulk) :
elastic.updateBulkList(list_bulk, index_name_o) 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(host)
# print(password) # 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) 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") # 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", classes)
moveClassifierAiCodes(elastic,"mj_qa_section", []) print('finished!')