codes rapair
This commit is contained in:
@@ -591,7 +591,8 @@ def importCodesToElastic(elastic, file_excel, index_name_o, tcode_label, file_lo
|
||||
|
||||
file.close()
|
||||
|
||||
def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_top=False, with_history_code={}):
|
||||
|
||||
def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_top=False, with_history_code={}, jump_ids = []):
|
||||
|
||||
|
||||
if head_top :
|
||||
@@ -618,6 +619,7 @@ def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_t
|
||||
bulk_data = []
|
||||
total_update=0
|
||||
row_number = 0
|
||||
correct_rows = []
|
||||
|
||||
try:
|
||||
for row in rows_list:
|
||||
@@ -649,6 +651,9 @@ def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_t
|
||||
data={}
|
||||
# ذخیره کد برای شناسه های یافت شده
|
||||
if section_id and section_id != 0:
|
||||
|
||||
if jump_ids and section_id in jump_ids :
|
||||
continue
|
||||
|
||||
_source = {}
|
||||
history_codes= []
|
||||
@@ -674,6 +679,8 @@ def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_t
|
||||
'_source' : _source
|
||||
}
|
||||
|
||||
correct_rows.append(row_number)
|
||||
|
||||
|
||||
bulk_data.append(data)
|
||||
|
||||
@@ -683,6 +690,7 @@ def extract_codes_to_json( file_excel, tcode_label, file_json, col_index, head_t
|
||||
except Exception as e:
|
||||
print('######################## Exception error --- row_number : ' , str(row_number), '/', str(count) , ' ***' , str(e) )
|
||||
print(str(traceback.print_exc()) )
|
||||
return correct_rows
|
||||
|
||||
#/////---- ردیف های اکسل را در سامانه قانون یار شناسایی می کند و شناسه ها را در همان اکسل تولید میکند
|
||||
#//// البته با تنظیم فلگ مرتبط، امکان درج در الاستیک هم دارد
|
||||
@@ -757,7 +765,7 @@ def run_Etebar_directory(elastic, directory, output, all_codes, update_elastic =
|
||||
print('00000 error 000000 ', code_name)
|
||||
|
||||
|
||||
def run_codes_extract_directory(directory, output, all_codes, col_index={}, head_top=False, version_key=''):
|
||||
def run_codes_extract_directory(directory, output, all_codes, col_index={}, head_top=False, version_key='', by_repair_error = False, elastic= None):
|
||||
|
||||
# List all files in the specified directory
|
||||
files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f))]
|
||||
@@ -791,7 +799,17 @@ def run_codes_extract_directory(directory, output, all_codes, col_index={}, head
|
||||
|
||||
item_found = [item for item in all_codes if item.get("title") == code_name]
|
||||
if item_found :
|
||||
extract_codes_to_json(file_path, code_name, output + f"/{code_name}.json", col_index, head_top, with_history_code)
|
||||
file_json = output + f"/{code_name}.json"
|
||||
correct_rows = []
|
||||
if by_repair_error :
|
||||
#-- در مواقعی که قبلا خطا خورد و فایل ارسال شده ، ولی نباید خطا می خورد
|
||||
#-- و با کد جدید مشکل خطا حل شده
|
||||
#-- موارد فوق استخراج و دوباره ارسال شود
|
||||
file_json = output + f"/{code_name}_err.json"
|
||||
correct_rows = extract_codes_to_json(file_path, code_name, file_json, col_index, head_top, with_history_code)
|
||||
parseCodesToExcel(elastic, file_path, "mj_qa_section", code_name, log_file, "", col_index, head_top)
|
||||
|
||||
extract_codes_to_json(file_path, code_name, output + f"/{code_name}.json", col_index, head_top, with_history_code, correct_rows)
|
||||
else :
|
||||
print('00000 error 000000 ', code_name)
|
||||
|
||||
|
||||
@@ -18,12 +18,12 @@ from app.for_ai.codes_import_from_excel import (
|
||||
run_codes_extract_directory,
|
||||
run_codes_to_elastic_directory,
|
||||
)
|
||||
from app.parvande_qanon.import_qavanin_excels_to_elastic import (
|
||||
from app.parvande_qanon.s2_import_qavanin_excels_to_elastic import (
|
||||
import_excel_before_to_elastic,
|
||||
import_excel_after_to_elastic,
|
||||
import_excel_tasmimat_to_elastic,
|
||||
)
|
||||
from app.parvande_qanon.repair_qa_qanon_for_map_new import *
|
||||
from app.majles.repair_qa_qanon_for_map_new import *
|
||||
|
||||
text_normal = TextNormalizer()
|
||||
|
||||
@@ -134,3 +134,8 @@ col_index = {
|
||||
### --- درج در الاستیک نمی کند update_elastic = False
|
||||
# run_codes_to_elastic_directory( elastic, "./data/tcodes/corrected_majles/not_edit4", "./data/tcodes/corrected_majles/not_edit4/result", all_codes, False, True, col_index, False)
|
||||
# run_codes_extract_directory("./data/tcodes/corrected_majles/not_edit4/result","./data/tcodes/corrected_majles/not_edit4/result_json",all_codes,col_index,True)
|
||||
|
||||
##--- استخراج موارد خطای کد
|
||||
run_codes_extract_directory("./data/tcodes/corrected_majles/not_edit4/result","./data/tcodes/corrected_majles/not_edit4/result_json",all_codes,col_index, head_top=False, by_repair_error = True, elastic=elastic)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user