import requests import json import os from decimal import Decimal from config_base import * from general_functions import * from dotenv import load_dotenv from elastic_helper import ElasticHelper from create_ai_index import * from create_context_ai import * # from move_to_other import * load_dotenv(dotenv_path='config.env') 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') print(host) # print(password) path_base_map = "G:/Project2/gateway2_main/repo/_other/" elastic = ElasticHelper(host, password, "elastic", path_base_map) # elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section_ai") #elastic.restorFileToElastic("G:/Project2/111", "mj_qa_section_ai", 'majles', True, "mj_qa_section") #### فایده ای نداشت ....!!! ## مسیر درختی مفید تولید نشد و عنوان قانون هم که فیلد مجزا داریم ! # create_context_ai(elastic, "mj_qa_section" ) ## 1 ##----------------------------------------------------------------- ##----- انتقال اطلاعات قبلی به اینجا #elastic.moveCustomFileds("mj_qa_section", "mj_qa_section_temp", ["ners_v1", "nlp_parser", "code-ai"]) ## 2 ##----------------------------------------------------------------- ## ----- تغییر ایندکسهای موقت به ایندکسهای اصلی # elastic.deleteIndex("mj_qa_opinion") # elastic.renameElasticIndex("mj_qa_opinion_temp", "mj_qa_opinion", "majles", "mj_qa_opinion") # elastic.deleteIndex("mj_qa_qanon") # elastic.renameElasticIndex("mj_qa_qanon_temp", "mj_qa_qanon", "majles", "mj_qa_qanon") # elastic.deleteIndex("mj_qa_section") # elastic.renameElasticIndex("mj_qa_section_temp", "mj_qa_section", "majles", "mj_qa_section") # elastic.deleteIndex("mj_rg_section") # elastic.renameElasticIndex("mj_rg_section_temp", "mj_rg_section", "majles", "mj_qa_section") ## 3 ##----------------------------------------------------------------- ## محاسبات پردازش داده ای واجب و پیچیده که پایه تمیزی داده در فاز2 و 3 هست اینجا انجام می شود fill_nlp_tags(elastic, "mj_qa_section") ## 4 ## -------------------------------------------------------------- ## پرکردن فیلدهای هوش مصنوعی برای اجزاء یا قانونهای جدید ##/////////////////////////////////////////////////////////// ai_url_base=os.getenv("AI_URL_BASE") ai_url_vec=ai_url_base+'/vecsim/vector' # ai_url_class=ai_url_base+'/vec_sim/class' ai_url_class='http://192.168.23.51:6111/class' # ai_url_ner=ai_url_base+'/vec_sim/ner' ## 4.1 ## ----------------------------------------------------------------- # تولید بردار برای اجزائی که لازم هست # elastic.createIndex("mj_qa_section_ai", 'majles/', "mj_qa_section" ) # import_data_embeding(elastic, ai_url_vec ,"mj_qa_section", "mj_qa_section_ai", "content" ) #extract_nlp_childs(elastic,"mj_qa_section") ## 4.2 ## ----------------------------------------------------------------- # برچسبهای هوشمند # import_classification(elastic, ai_url_class, "mj_qa_section_temp") # payload={ # "text":"سلام علیکم" # } # response = requests.request("POST", ai_url_vec, headers=HEADERS, json=payload) # print(response.text) # print(response) # payload={ # "text":"طرفین به منظور اتمام مطالعات و احداث نیروگاه‌های جریانی ارس و تأسیسات مربوطه، منطقه مشترک ساختمانی و مطالعاتی را تعیین و امنیت این منطقه را در طول مدت اجراء و بهره‌برداری تأمین می‌نمایند. " # } # response = requests.request("POST", ai_url_class, headers=HEADERS, json=payload) # print(response.text) # print(response) # resp = json.loads(response.text) # print(resp['result']) ## 5 ## -------------------------------------------------------------- ## پشتیبان گیری از داده جدید تکمیلی ##/////////////////////////////////////////////////////////// ## پشتیبان گیری # path_back = os.getcwd() + '/data_back' # if not os.path.exists(path_back) : # os.makedirs(path_back) # print('---> path_back = ' + path_back) # elastic.backupIndexToZipfile(path_back, "mj_qa_qanon") # elastic.backupIndexToZipfile(path_back, "mj_qa_section") # elastic.backupIndexToZipfile(path_back, "mj_rg_section") # elastic.backupIndexToZipfile(path_back, "mj_qa_opinion") ## کد نمونه بازیابی از فایل # path_back = 'G:/Project2/_back/back_data/data_majles/elastic/v1.0/full' # elastic.restorFileToElastic(path_back, 'mj_qa_section', 'majles')