From 302f6b5cd880e7ca99ce8b738760caad63682d97 Mon Sep 17 00:00:00 2001 From: hsafaei Date: Tue, 15 Apr 2025 15:17:00 +0330 Subject: [PATCH] fix bug tokens --- all_sql_steps.py | 38 ++++++++-------- config_base.py | 1 + temp_codes.py | 100 ++++++++++++++++++++---------------------- tokens_parse_spell.py | 6 +-- 4 files changed, 70 insertions(+), 75 deletions(-) diff --git a/all_sql_steps.py b/all_sql_steps.py index 256d111..bc96728 100644 --- a/all_sql_steps.py +++ b/all_sql_steps.py @@ -29,43 +29,43 @@ from s11_Tanghih_plan_move import * # DELETE mj_qa_opinion_temp # ----------------------------------------------------------------- -# cursor, cnxn = create_cursor() +cursor, cnxn = create_cursor() -# ## ایجاد فهرست موضوعات قانون -# projectid = insertProejct() -# insertProjectItems(cursor, projectid) +## ایجاد فهرست موضوعات قانون +projectid = insertProejct() +insertProjectItems(cursor, projectid) -# # 2 -# import_law_section_to_elastic(cursor) +# 2 +import_law_section_to_elastic(cursor) -# import_opinion_to_elastic(cursor) +import_opinion_to_elastic(cursor) -# import_regulation_section_to_elastic(cursor) +import_regulation_section_to_elastic(cursor) -# ### از ابتدا تا اینجا حدودا 24 ساعت کشید +### از ابتدا تا اینجا حدودا 24 ساعت کشید -# import_law_section_update_ref_state(cursor) +import_law_section_update_ref_state(cursor) -# import_regulation_section_update_ref_state(cursor) +import_regulation_section_update_ref_state(cursor) -# import_law_reg_qanon_to_elastic(cursor) +import_law_reg_qanon_to_elastic(cursor) -# ## تا اینجا رسید و خطا داد -# import_relations_qanon_lwreg(cursor) +## تا اینجا رسید و خطا داد +import_relations_qanon_lwreg(cursor) -# ## اینجا خطا داد -# import_relations_qanon_opinion(cursor) +## اینجا خطا داد +import_relations_qanon_opinion(cursor) -# import_lawreg_lwphase_info(cursor) +import_lawreg_lwphase_info(cursor) -# cursor.close() -# cnxn.close() +cursor.close() +cnxn.close() cursor, cnxn = create_cursor('db4minaei') diff --git a/config_base.py b/config_base.py index 118b24e..203a9c6 100644 --- a/config_base.py +++ b/config_base.py @@ -5,6 +5,7 @@ import pyodbc # و باید توکن معتبر جدید از سایت قوانین درحالت لاگین شده، # دریافت شود و به جای توکن زیر جایگزین شود +# TOKEN = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3Mzk3ODc1NTQsImp0aSI6IlpKRnhHUjFPR2p6b2RqWGxoVzJpSzFSeks5VVNwdXE0IiwiaXNzIjpudWxsLCJleHAiOjE3NDEwODc1NTMsImF1ZCI6bnVsbCwiZGF0YSI6eyJpZCI6MSwiZmlyc3RfbmFtZSI6Ilx1MDY0NVx1MDYyZlx1MDZjY1x1MDYzMSBcdTA2NDFcdTA2NDZcdTA2Y2MiLCJsYXN0X25hbWUiOiJcdTA2MzNcdTA2MjdcdTA2NDVcdTA2MjdcdTA2NDZcdTA2NDciLCJlbWFpbCI6ImRldkBnbWFpbC5jb20iLCJ1c2VybmFtZSI6ImRldiIsInVzZXJfbGV2ZWwiOjJ9fQ.orS-RbJkYY2nT6r7WKDfL2Wy2M0rJ9Gh_RpZv5kvVvU' TOKEN = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE3NDM4NTQ0MTEsImp0aSI6IjhDOWErR3BPMGk5U3Blc0ZFT251RDNoM2t3XC82R1BWTiIsImlzcyI6bnVsbCwiZXhwIjoxNzQ1MTU0NDEwLCJhdWQiOm51bGwsImRhdGEiOnsiaWQiOjEsImZpcnN0X25hbWUiOiJcdTA2NDVcdTA2MmZcdTA2Y2NcdTA2MzEgXHUwNjQxXHUwNjQ2XHUwNmNjIiwibGFzdF9uYW1lIjoiXHUwNjMzXHUwNjI3XHUwNjQ1XHUwNjI3XHUwNjQ2XHUwNjQ3IiwiZW1haWwiOiJkZXZAZ21haWwuY29tIiwidXNlcm5hbWUiOiJkZXYiLCJ1c2VyX2xldmVsIjoyfX0.jke3m7QD2pj7E18fBJYjiz9FrYbl6ZxVaYbLt9jfZu0' ACCEPT = "application/json" HEADERS = {"Authorization": TOKEN, "Accept": ACCEPT} diff --git a/temp_codes.py b/temp_codes.py index 6033a3c..ea9bee0 100644 --- a/temp_codes.py +++ b/temp_codes.py @@ -16,14 +16,19 @@ from temp_LawSection_content import * load_dotenv(dotenv_path='config.env') -host=os.getenv('HOST_160') -password=os.getenv('HOST_160_PASS') +# host=os.getenv('HOST_160') +# password=os.getenv('HOST_160_PASS') + + # host=os.getenv('HOST_112') # password=os.getenv('HOST_112_PASS') -# host=os.getenv('HOST_60') -# password=os.getenv('HOST_60_PASS') +host=os.getenv('HOST_60') +password=os.getenv('HOST_60_PASS') + +# host=os.getenv('HOST_161') +# password=os.getenv('HOST_161_PASS') # host=os.getenv('HOST_80') # password=os.getenv('HOST_80_PASS') @@ -74,60 +79,49 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) # elastic.createIndex('mj_qa_section', 'majles', 'mj_qa_section') # elastic.zipFileToElastic(path_back, 'mj_qa_section') -# elastic.backupIndexToZipfile("G:/Project2/111", "gn_log_action") +#selastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha") +# elastic.backupIndexToZipfile("G:/Project2/111", "gn_calendar") -# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") -#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section_ai") +#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") +# elastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha") +#elastic.backupIndexToZipfile("G:/Project2/111", "dh_volume_temp") #elastic.restorFileToElastic("G:/Project2/111", "mj_qa_section_ai", 'majles', True, "mj_qa_section") +# elastic.restorFileToElastic('G:/Project2/111', 'dh_haditha', 'dhadith', 'dh_haditha' ) +elastic.restorFileToElastic('G:/Project2/111', 'gn_calendar') -body= { - "query": { - "bool": { - "must": [ - { - "bool": { - "should": [ - { - "match_phrase": { - "title.ph": { - "query": "نسخ ضمنی", - "boost": 10 - } - } - }, - { - "match_phrase": { - "content.ph": { - "query": "نسخ ضمنی", - "boost": 10 - } - } - } - ] - } - }, - { - "bool": { - "filter": { - "bool": { - "must": [ - { - "term": { - "ts_ref.keyword": "اداره کل حقوقی قوه قضاییه" - } - } - ] - } - } - } - } - ] - } - } + +body= { + "query": { + "terms": { + "qanon_id": [ + "qq83354", + "qq83382", + "qq112748", + "qq112296", + "qq83435", + "qq114127", + "qq175888", + "qq85335", + "qq84208", + "qq114652", + "qq114640" + ] + } + }, + "sort": [ + { + "qanon_id": { + "order": "asc" + }, + "child_order": { + "order": "asc" + } + } + ] } -# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_opinion", "mj_qa_opinion_naskh", body, False, ["content"]) +#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section", "mj_qa_section_Aab", body, False, ["content", "simplifies", "tcode_sub_old", "tcode_main_old", "code-ai", "ai_keywords"]) #------------------------------------------------------- #### فایده ای نداشت ....!!! @@ -185,7 +179,7 @@ path_back = 'G:/Project2/111' # path_back = 'G:/Project2/_back/back_data/data_majles/elastic/v1.0/full' # elastic.restorFileToElastic(path_back, 'mj_qa_section', 'majles') -elastic.restorFileToElastic(path_back, 'gn_log_action') +# elastic.restorFileToElastic(path_back, 'gn_log_action') #------------------------------------------------------- diff --git a/tokens_parse_spell.py b/tokens_parse_spell.py index 110a41a..9583bca 100644 --- a/tokens_parse_spell.py +++ b/tokens_parse_spell.py @@ -128,8 +128,8 @@ def exportTokensToFile(elastic, index_name_i, filename, fields=['content'], body def diff_files_to_file(file_dict1, file_dict2, filename, path_out="./data/"): - dict1 = json.loads(open(file_dict1, "r", encoding="utf-8").read()) - dict2 = json.loads(open(file_dict2, "r", encoding="utf-8").read()) + dict1 = json.loads(open(path_out+file_dict1, "r", encoding="utf-8").read()) + dict2 = json.loads(open(path_out+file_dict2, "r", encoding="utf-8").read()) return diff_to_file(dict1, dict2, filename, False, path_out) def diff_to_file(dict1, dict2, filename, by_diff_count=False, path_out="./data/"): @@ -184,7 +184,7 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map) # exportTokensToFile(elastic,"mj_qa_section", "content_mj_qa_section_1.txt") -exportTokensMulti(elastic,"mj_qa_section", "mj_qa_section") +#exportTokensMulti(elastic,"mj_qa_section", "mj_qa_section") diff_files_to_file("mj_qa_section1.txt", "mj_qa_section2.txt", "diff_1_2.txt") diff_files_to_file("mj_qa_section2.txt", "mj_qa_section1.txt", "diff_2_1.txt")