ai hostorycode

This commit is contained in:
hsafaei
2025-10-12 11:11:44 +03:30
parent 372251aff7
commit c80813aaa8
3 changed files with 74 additions and 26 deletions
@@ -16,7 +16,7 @@ from app.common.text_normalizer import TextNormalizer
from app.common.elastic_helper import ElasticHelper from app.common.elastic_helper import ElasticHelper
def repair_ai_codes( elastic, index_name_i, index_name_o, file_log) : def ai_fill_history_codes( elastic, index_name_i, index_name_o, file_log) :
body = {} body = {}
try: try:
@@ -172,16 +172,16 @@ def repair_ai_codes( elastic, index_name_i, index_name_o, file_log) :
load_dotenv(dotenv_path='config.env') load_dotenv(dotenv_path='config.env')
# host=os.getenv('HOST_160') host=os.getenv('HOST_160')
# password=os.getenv('HOST_160_PASS') password=os.getenv('HOST_160_PASS')
host=os.getenv('HOST_113') # host=os.getenv('HOST_113')
password=os.getenv('HOST_113_PASS') # password=os.getenv('HOST_113_PASS')
path_base_map = "G:/Project2/gateway2_main/repo/_other/" path_base_map = "G:/Project2/gateway2_main/repo/_other/"
elastic = ElasticHelper(host, password, "elastic", path_base_map) elastic = ElasticHelper(host, password, "elastic", path_base_map)
repair_ai_codes( elastic, "mj_qa_section", "mj_qa_section", "./output/log__ai_r1.txt") ai_fill_history_codes( elastic, "mj_qa_section", "mj_qa_section", "./output/log__ai_r1.txt")
+62 -15
View File
@@ -134,7 +134,7 @@ def moveSimplifies(elastic, index_name_o, data):
def moveClassifierAiCodes(elastic, index_name_o, data, version_key = "D51_v1"): def copyToAiCodesHistoryCodes(elastic, index_name_o, data, version_key = "D51_v1"):
text_normal = TextNormalizer() text_normal = TextNormalizer()
index = 0 index = 0
percent_prev = 0 percent_prev = 0
@@ -217,7 +217,7 @@ def moveClassifierAiCodes(elastic, index_name_o, data, version_key = "D51_v1"):
print(f"last ::: send_round -> {len(list_bulk)}") print(f"last ::: send_round -> {len(list_bulk)}")
def moveClassifierAiCodes2( elastic, data_codes, version_key, index_name_i, index_name_o) : def copyToAiCodesHistoryCodes2( elastic, data_codes, version_key, index_name_i, index_name_o) :
body = {} body = {}
try: try:
@@ -320,14 +320,14 @@ def moveClassifierAiCodes2( elastic, data_codes, version_key, index_name_i, inde
load_dotenv(dotenv_path='config.env') load_dotenv(dotenv_path='config.env')
host=os.getenv('HOST_160') # host=os.getenv('HOST_160')
password=os.getenv('HOST_160_PASS') # password=os.getenv('HOST_160_PASS')
# host=os.getenv('HOST_112') # host=os.getenv('HOST_112')
# password=os.getenv('HOST_112_PASS') # password=os.getenv('HOST_112_PASS')
# host=os.getenv('HOST_113') host=os.getenv('HOST_113')
# password=os.getenv('HOST_113_PASS') password=os.getenv('HOST_113_PASS')
# host=os.getenv('HOST_60') # host=os.getenv('HOST_60')
# password=os.getenv('HOST_60_PASS') # password=os.getenv('HOST_60_PASS')
@@ -365,22 +365,69 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# classes = json.load(f) # classes = json.load(f)
#---#-----داده های جدید نسخه # #---#-----داده های جدید نسخه
# with open("./data/all_sections_classes_new_140406.json", "r", encoding="utf-8") as f: # with open("./data/all_sections_classes_new_140406.json", "r", encoding="utf-8") as f:
# classes = json.load(f) # classes = json.load(f)
# moveClassifierAiCodes(elastic,"mj_qa_section", classes, "D51_v1") # copyToAiCodesHistoryCodes(elastic,"mj_qa_section", classes, "D51_v1")
#---------------------------
#--------------------------- #---------------------------
# کدهای 49 گانه آموزش دیده با دیتاست خوب حدود15 الی 20 هزارتایی که با کمک فایلهای تبیین مفهومی و مدلهای زبانی به دست آمد # کدهای 49 گانه آموزش دیده با دیتاست خوب حدود15 الی 20 هزارتایی که با کمک فایلهای تبیین مفهومی و مدلهای زبانی به دست آمد
with open("./data/all_sections_classes_full_140407.json", "r", encoding="utf-8") as f: # with open("./data/all_sections_classes_full_140407.json", "r", encoding="utf-8") as f:
classes = json.load(f) # classes = json.load(f)
# moveClassifierAiCodes(elastic,"mj_qa_section", classes, "D49_v1") # copyToAiCodesHistoryCodes(elastic,"mj_qa_section", classes, "D49_v1")
moveClassifierAiCodes2(elastic, classes, "D49_v1","mj_qa_section", "mj_qa_section")
print('finished!')
#--برای سرعت بیشتر ، که چندان اثری نداشت
# copyToAiCodesHistoryCodes2(elastic, classes, "D49_v1","mj_qa_section", "mj_qa_section")
# print('finished!')
#--------------------------------------
#-- دستی این مورد اجرا شد، تا اجزاءی که در مرحله جدید کدگذاری نشدند، و از قبل مواردی داشتند پاک شوند
# POST mj_qa_section/_update_by_query
# {
# "query": {
# "bool": {
# "should": [
# {
# "terms": {
# "ai_code.label": [
# "امور زیربنایی",
# "نظامی و انتظامی" ,
# "کشاورزی و دامپروری",
# "منابع طبیعی",
# "آیین دادرسی مدنی و اداری",
# "اطلاعات و امنیت"
# ]
# }
# },
# {
# "terms": {
# "ai_codes.label": [
# "امور زیربنایی",
# "نظامی و انتظامی" ,
# "کشاورزی و دامپروری",
# "منابع طبیعی",
# "آیین دادرسی مدنی و اداری",
# "اطلاعات و امنیت"
# ]
# }
# }
# ]
# }
# }
# ,"script": {
# "source": """
# ctx._source.remove("ai_code");
# ctx._source.remove("ai_codes");
# """,
# "lang": "painless"
# }
# }
#--------------------------------------
+3 -2
View File
@@ -42,6 +42,7 @@ print(host)
path_base_map = "G:/Project2/gateway2_main/repo/_other/" path_base_map = "G:/Project2/gateway2_main/repo/_other/"
elastic = ElasticHelper(host, password, "elastic", path_base_map) elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.backupIndexToZipfile("G:/Project2/111", "mj_mashruh")
#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section")
# elastic.restorFileToElastic2('G:/Project2/111/mj_qa_section.zip', 'mj_qa_section', 'majles', False, 'mj_qa_section') # elastic.restorFileToElastic2('G:/Project2/111/mj_qa_section.zip', 'mj_qa_section', 'majles', False, 'mj_qa_section')
# elastic.restorFileToElastic2('G:/Project2/111/gn_setting.zip', 'gn_setting', 'general', False, 'gn_setting') # elastic.restorFileToElastic2('G:/Project2/111/gn_setting.zip', 'gn_setting', 'general', False, 'gn_setting')
@@ -52,8 +53,8 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.restorFileToElastic2('G:/Project2/111/mn_spr_sanad.zip', 'mn_spr_sanad', 'monir', False, 'mn_spr_sanad') # elastic.restorFileToElastic2('G:/Project2/111/mn_spr_sanad.zip', 'mn_spr_sanad', 'monir', False, 'mn_spr_sanad')
# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_domain") # elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_domain")
# elastic.createIndex( 'mj_qa_domain', 'majles', 'mj_domain') # elastic.createIndex( 'mj_qa_domain', 'majles', 'mj_qa_domain')
# elastic.restorFileToElastic2('G:/Project2/111/mj_qa_domain_base1.zip', 'mj_qa_domain', 'majles', False, 'mj_qa_domain') # elastic.restorFileToElastic2('G:/Project2/111/mj_qa_domain.zip', 'mj_qa_domain', 'majles', False, 'mj_qa_domain')
# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section-m1") # elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section-m1")