anlyzes update to elastic search

This commit is contained in:
init_mahdi
2025-09-22 16:34:49 +03:30
parent 7140efa3f0
commit 984ccdf9da
2 changed files with 21 additions and 10 deletions
+20 -10
View File
@@ -206,19 +206,21 @@ def extract_domain_words(
final_structure = {}
all_code_labels = list(json_input_data.keys())
# برای هر عنوان اصلی
for code_label in all_code_labels:
if code_label == 'سایر':
continue
current_words_dict = json_input_data[code_label]
code_label = text_normalizer.normalize_qanon(code_label)
if not code_label in dict_domain_id :
if not code_label in dict_domain_id:
print( "------------ error ", item )
continue
domain_id = dict_domain_id[code_label]
code_label_id = domain_type + "_" + domain_id
current_words_dict = json_input_data[code_label]
# 1. words_general — تمام کلمات این عنوان — مرتب بر اساس تکرار
@@ -266,15 +268,17 @@ def extract_domain_words(
list_code_words = []
for other_title in all_code_labels:
if other_title == code_label:
other_words = set(json_input_data[other_title].keys())
current_words = set(current_words_dict.keys())
other_title = text_normalizer.normalize_qanon(other_title)
if (other_title == code_label) or (other_title =='سایر'):
continue
other_words = set(json_input_data[other_title].keys())
current_words = set(current_words_dict.keys())
other_title = text_normalizer.normalize_qanon(other_title)
if not other_title in dict_domain_id :
if not (other_title in dict_domain_id):
print( "========================= error ", other_title )
continue
@@ -323,11 +327,15 @@ def extract_domain_words(
final_structure[code_label] = data
eid = code_label_id
print(f'data Created! {eid}')
try:
resp = elastic.update_index_doc(True, index_name_o, eid, data)
except Exception as e:
pass
import traceback
print(traceback.print_exc())
print(f'data NOT saved in es')
print(f'data saved in es')
# ذخیره خروجی نهایی
with open("./analyzed_domains.json", "w", encoding="utf-8") as f:
@@ -353,4 +361,6 @@ path_base_map = "G:/Project2/gateway2_main/repo/_other/"
elastic = ElasticHelper(host, password, "elastic", path_base_map)
final_domain_words = extract_domain_words("data/ai/corrected_sorted1.json", elastic, "mj_qa_doamin")
final_domain_words = extract_domain_words(r"C:\Users\TAVASI-3\Desktop\init_mahdi\project\bank_words_per\data\corrected_sorted1.json", elastic, "mj_qa_domain")
# final_domain_words = extract_domain_words("data/ai/corrected_sorted1.json", elastic, "mj_qa_doamin")
# python -m app.for_ai.codes_tokens