codes_tokens

This commit is contained in:
hsafaei
2025-09-22 15:34:52 +03:30
parent b0d6212172
commit 7140efa3f0
3 changed files with 213 additions and 573 deletions
+78 -95
View File
@@ -1,17 +1,18 @@
import os
from dotenv import load_dotenv
from app.common.text_normalizer import TextNormalizer
# from general import *
from app.common.general_functions import *
from app.common.elastic_helper import ElasticHelper
from app.for_ai.create_relation_tags import *
from app.temp_refactor_gn_dataset import *
load_dotenv(dotenv_path='config.env')
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')
@@ -54,8 +55,8 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.restorFileToElastic2('G:/Project2/111/server112/mj_qa_section-m1.zip', 'mj_qa_section-m1', 'majles', False, 'mj_qa_section')
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_calendar")
#elastic.createIndex( 'gn_calendar', 'general', 'gn_calendar')
#elastic.restorFileToElastic2('G:/Project2/111/gn_calendar.zip', 'gn_calendar', 'general', False, 'gn_calendar')
# elastic.createIndex( 'gn_calendar', 'general', 'gn_calendar')
# elastic.restorFileToElastic2('G:/Project2/111/gn_calendar.zip', 'gn_calendar', 'general', False, 'gn_calendar')
# elastic.createIndex( 'gn_synonym', 'general', 'gn_synonym')
# elastic.restorFileToElastic2('G:/Project2/111/server112/gn_synonym.zip', 'gn_synonym', 'general', False, 'gn_synonym')
@@ -65,22 +66,22 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.restorFileToElastic2('G:/Project2/111/mn_sanad.zip', 'mn_sanad', 'monir', False, 'mn_sanad')
#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/gn_setting.zip', 'gn_setting', 'general', False, 'gn_setting')
#-------------------------------------------------------
# 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/gn_setting.zip', 'gn_setting', 'general', False, 'gn_setting')
# -------------------------------------------------------
##
# elastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha")
# elastic.backupIndexToZipfile("G:/Project2/111", "dh_parag_bge")
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_dataset")
#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", "mj_qa_section_ai")
# elastic.backupIndexToZipfile("G:/Project2/111", "mn_crition")
#moveDataset1(elastic, "G:/Project2/111/gn_dataset_14031125.zip", "gn_dataset2")
# moveDataset1(elastic, "G:/Project2/111/gn_dataset_14031125.zip", "gn_dataset2")
#-------------------------------------------------------
# -------------------------------------------------------
## backup from hamfahmi.ir
#-------------------------------------------------------
# -------------------------------------------------------
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_bayanat")
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_synonym")
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "gn_log_search")
@@ -98,14 +99,13 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_steps") # ???
# elastic.backupIndexToZipfile("G:/Project2/111/server3", "mn_nesha")
#-------------------------------------------------------
# -------------------------------------------------------
#-------------------------------------------------------
# -------------------------------------------------------
## backup from 160
#-------------------------------------------------------
path_back = 'G:/Project2/111/server112/'
# -------------------------------------------------------
path_back = "G:/Project2/111/server112/"
# elastic.backupIndexToZipfile(path_back, "gn_log_change")
# elastic.backupIndexToZipfile(path_back, "gn_log_action")
# elastic.backupIndexToZipfile(path_back, "gn_log_search")
@@ -124,7 +124,7 @@ path_back = 'G:/Project2/111/server112/'
# elastic.backupIndexToZipfile(path_back, "mj_rg_section")
# elastic.backupIndexToZipfile(path_back, "mj_qa_qanon")
############elastic.backupIndexToZipfile(path_back, "rrk_index")
#elastic.backupIndexToZipfile(path_back, "mj_df_qanon")
# elastic.backupIndexToZipfile(path_back, "mj_df_qanon")
######elastic.backupIndexToZipfile(path_back, "mj_qa_qanon_ai")
# elastic.backupIndexToZipfile(path_back, "mj_qa_section_ai")
@@ -136,9 +136,9 @@ path_back = 'G:/Project2/111/server112/'
# gn_dataset2
# gn_setting2
#-------------------------------------------------------
# -------------------------------------------------------
#-------------------------------------------------------
# -------------------------------------------------------
##
# ## کد نمونه بازیابی از فایل
@@ -146,15 +146,15 @@ path_back = 'G:/Project2/111/server112/'
# elastic.createIndex('mj_qa_section', 'majles', 'mj_qa_section')
# elastic.zipFileToElastic(path_back, 'mj_qa_section')
#selastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha")
# 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")
# 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.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', 'mj_model', 'majles', True, 'mj_model' )
# elastic.restorFileToElastic('G:/Project2/111', 'mj_model', 'majles', True, 'mj_model' )
# elastic.restorFileToElastic2('G:/Project2/111/mj_model_20250512-003003.zip', 'mj_model', 'majles', True, 'mj_model')
# elastic.restorFileToElastic2('G:/Project2/111/mj_qa_section_2_majles_repair.zip', 'mj_qa_section', 'majles', False, 'mj_qa_section')
@@ -189,21 +189,21 @@ path_back = 'G:/Project2/111/server112/'
# ]
# }
#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"])
# 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"])
#-------------------------------------------------------
# -------------------------------------------------------
#### فایده ای نداشت ....!!!
## مسیر درختی مفید تولید نشد و عنوان قانون هم که فیلد مجزا داریم !
# create_context_ai(elastic, "mj_qa_section" )
#-------------------------------------------------------
# -------------------------------------------------------
##
#ai_url_chunk = os.getenv("ai_url_chunk")
#fill_chunk_tags(elastic, ai_url_chunk, "mj_qa_section")
# ai_url_chunk = os.getenv("ai_url_chunk")
# fill_chunk_tags(elastic, ai_url_chunk, "mj_qa_section")
#-------------------------------------------------------
# -------------------------------------------------------
##
# برچسبهای هوشمند
@@ -225,23 +225,23 @@ path_back = 'G:/Project2/111/server112/'
# resp = json.loads(response.text)
# print(resp['result'])
#-------------------------------------------------------
# -------------------------------------------------------
##
## پشتیبان گیری
# path_back = os.getcwd() + '/data_back'
path_back = 'G:/Project2/111'
# if not os.path.exists(path_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_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")
# 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'
@@ -250,68 +250,51 @@ path_back = 'G:/Project2/111'
# elastic.restorFileToElastic(path_back, 'gn_log_action')
#-------------------------------------------------------
# -------------------------------------------------------
##
#-------------------------------------------------------
# -------------------------------------------------------
##
#-------------------------------------------------------
# -------------------------------------------------------
# -- جهت استخراج دیتاست بخشی از الاستیک برای استفاده در هوش مصنوعی
body= {
body = {
"query": {
"bool": {
"must": [
{
"bool": {
"must_not": [
{
"terms": {
"nlp_tags": [
"concept_no"
]
}
},
{
"exists": {
"field": "ai_keywords"
}
}
"must": [
{
"bool": {
"must_not": [
{"terms": {"nlp_tags": ["concept_no"]}},
{"exists": {"field": "ai_keywords"}},
]
}
},
{
"bool": {
"filter": {
"bool": {
"must": [
{"terms": {"qanon_etebar": ["", "معتبر"]}},
{
"terms": {
"title_type": [
"عادی",
"اصلی",
"موافقتنامه",
"بودجه",
]
}
},
]
}
}
}
},
]
}
},
{
"bool": {
"filter": {
"bool": {
"must": [
{
"terms": {
"qanon_etebar": [
"",
"معتبر"
]
}
},
{
"terms": {
"title_type": [
"عادی",
"اصلی",
"موافقتنامه",
"بودجه"
]
}
}
]
}
}
}
}
]
}
}
}
# elastic.exportToJsonForAI("./data/", "mj_qa_section", "keywords_extract_40K", body, ["content"])
@@ -324,7 +307,7 @@ body= {
# }
# }
# }
#elastic.exportToJsonForAI("./data/", "mj_qa_qanon", "qanon_title", body, ["title", "ts_date", "ts_year"])
# elastic.exportToJsonForAI("./data/", "mj_qa_qanon", "qanon_title", body, ["title", "ts_date", "ts_year"])
# body={
# "query": {
@@ -335,9 +318,9 @@ body= {
# }
# }
# }
#elastic.exportToJsonForAI("./data/", "mj_qa_qanon", "regular_title", body, ["title", "ts_date", "ts_year"])
# elastic.exportToJsonForAI("./data/", "mj_qa_qanon", "regular_title", body, ["title", "ts_date", "ts_year"])
#-------------------------------------------------------
# -------------------------------------------------------
print("finished")
print("finished")