98 lines
3.6 KiB
Python
98 lines
3.6 KiB
Python
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 *
|
|
|
|
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)
|
|
|
|
|
|
## 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")
|
|
#extract_nlp_childs(elastic,"mj_qa_section")
|
|
|
|
## 4 ## --------------------------------------------------------------
|
|
## پرکردن فیلدهای هوش مصنوعی برای اجزاء یا قانونهای جدید
|
|
|
|
##///////////////////////////////////////////////////////////
|
|
## 4.1 ## -----------------------------------------------------------------
|
|
# تولید بردار برای اجزائی که لازم هست
|
|
|
|
|
|
# elastic.createIndex("mj_qa_section_ai", 'majles/', "mj_qa_section" )
|
|
|
|
# ai_url_vec=os.getenv("ai_url_vec")
|
|
# import_data_embeding(elastic, ai_url_vec ,"mj_qa_section", "mj_qa_section_ai", "content" )
|
|
|
|
|
|
## 4.2 ## -----------------------------------------------------------------
|
|
# برچسبهای هوشمند
|
|
|
|
# import_classification(elastic, ai_url_class, "mj_qa_section_temp")
|
|
|
|
## 5 ## --------------------------------------------------------------
|
|
## پشتیبان گیری از داده جدید تکمیلی
|
|
|
|
##///////////////////////////////////////////////////////////
|
|
## پشتیبان گیری
|
|
|
|
# path_back = os.getcwd() + '/data_back'
|
|
path_back = 'G:/Project2/111'
|
|
# 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_qa_section", '', {}, True, [], ["pos_tags", "chunk_tags", "version_info"])
|
|
#elastic.backupIndexToZipfile(path_back, "mj_qa_section_ai")
|
|
#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'
|
|
# path_back = 'G:/Project2/111'
|
|
# elastic.restorFileToElastic(path_back, 'mj_qa_section_ai', 'majles', True, 'mj_qa_section')
|
|
|