This commit is contained in:
hsafaei
2025-02-09 16:45:52 +03:30
parent d2b56991a0
commit b54683638a
11 changed files with 765 additions and 216 deletions
+154
View File
@@ -0,0 +1,154 @@
import os
from dotenv import load_dotenv
from text_normalizer import TextNormalizer
# from general import *
from general_functions import *
from elastic_helper import ElasticHelper
from create_relation_tags 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" )
#-------------------------------------------------------
##
ai_url_chunk = os.getenv("ai_url_chunk")
fill_chunk_tags(elastic, ai_url_chunk, "mj_qa_section")
#-------------------------------------------------------
##
# برچسبهای هوشمند
# 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'])
#-------------------------------------------------------
##
## کد نمونه بازیابی از فایل
# path_back = 'G:/Project2/_back/back_data/data_majles/elastic/v1.0/full'
# elastic.restorFileToElastic(path_back, 'mj_qa_section', 'majles')
#-------------------------------------------------------
##
#-------------------------------------------------------
##
#-------------------------------------------------------
# -- جهت استخراج دیتاست بخشی از الاستیک برای استفاده در هوش مصنوعی
body= {
"query": {
"bool": {
"must": [
{
"bool": {
"must_not": [
{
"terms": {
"nlp_tags": [
"concept_no"
]
}
},
{
"exists": {
"field": "ai_keywords"
}
}
]
}
},
{
"bool": {
"filter": {
"bool": {
"must": [
{
"terms": {
"qanon_etebar": [
"",
"معتبر"
]
}
},
{
"terms": {
"title_type": [
"عادی",
"اصلی",
"موافقتنامه",
"بودجه"
]
}
}
]
}
}
}
}
]
}
}
}
# elastic.exportToJsonForAI("./data/", "mj_qa_section", "keywords_extract_40K", body, ["content"])
#-------------------------------------------------------
print("finished")