plan majles

This commit is contained in:
hsafaei
2026-05-09 16:04:08 +03:30
parent cb90e83ba6
commit 488eb98fec
9 changed files with 1570 additions and 824 deletions
+143
View File
@@ -0,0 +1,143 @@
import numbers
import os
from dotenv import load_dotenv
from elasticsearch import Elasticsearch, helpers
import json
import re
import zipfile
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")))
from app.common.elastic_helper import ElasticHelper
from app.common.general_functions import *
from app.common.text_normalizer import TextNormalizer
from app.common.data_helper import DataHelper
text_normal = TextNormalizer()
def get_evaluation_data(data):
result = []
if data.is_subject_unity_assessment_correct:
result.append("تایید وجود وحدت موضوعی")
else:
result.append("رد وجود وحدت موضوعی")
if data.is_conflict_detection_correct:
result.append("تایید تشخیص مخالفت")
else:
result.append("رد تشخیص مخالفت")
if data.is_conflict_type_detection_correct:
result.append("تایید تشخیص نوع مخالفت")
else:
result.append("رد تشخیص نوع مخالفت")
if data.is_relation_type_detection_correct:
result.append("تایید تشخیص نوع تعارض")
else:
result.append("رد تشخیص نوع تعارض")
return result
def get_vlid_text(text):
if text == "valid":
return "معتبر"
elif text == "invalid":
return "نامعتبر"
elif text == "undetermined":
return "نامشخص"
def import_conflict_to_elastic( file_path, out_put_index_name):
data_all = DataHelper.load_orjson(file_path)
bulk_data = []
failed_data = []
total_count = 0
for item in data_all :
_id = item["id"]
previous_info = item["previous_info"]
next_info = item["next_info"]
version_key = item["version_key"]
subject_unity = item["subject_unity"]
conflict_detection = item["conflict_detection"]
conflict_type_detection = item["conflict_type_detection"]
conflict_relation_identification = item["conflict_relation_identification"]
conflict_evaluation = item["conflict_evaluation"]
conflict_final = item["conflict_final"]
es_data = {
"id": _id,
"version_key": version_key,
"previous_info": previous_info,
"next_info": next_info,
"subject_unity": subject_unity,
"conflict_detection": conflict_detection,
"conflict_type_detection":conflict_type_detection,
"conflict_relation_identification":conflict_relation_identification,
"conflict_evaluation": conflict_evaluation,
"conflict_final": conflict_final,
}
bulk_data.append({"_id": _id, "_source": es_data})
if len(bulk_data) > 200:
total_count += len(bulk_data)
print("=" * 10, "to_elastic , total=" + str(total_count))
elastic.importBulkList(bulk_data, out_put_index_name)
bulk_data = []
# break
if len(bulk_data) > 0:
total_count += len(bulk_data)
print("=" * 10, "to_elastic , total=" + str(total_count))
elastic.importBulkList(bulk_data, out_put_index_name)
bulk_data = []
## -----------------------------------------------------------------------
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_H102")
# password = os.getenv("HOST_H102_PASS")
# print( "---------------->>>>>>>>>>>>>>>", host )
# host=os.getenv('HOST_113')
# password=os.getenv('HOST_113_PASS')
print(".... majles_codes_update_steps ......", host)
path_base_map = "G:/Project2/tavasi_160/src/repo/_other/"
elastic = ElasticHelper(host, password, "elastic", path_base_map)
# import_conflict_to_elastic(
# file_path=r"G:\Project2\102_gpu\v3\output_130k_all_qavanin_persian_translate_full.json",
# out_put_index_name="mj_qa_conflict")
# elastic.backupIndexToZipfile("G:/Project2/111/server160", "mj_qa_conflict", "mj_qa_conflict")
# elastic.createIndex( 'mj_qa_conflict', 'majles', 'mj_qa_conflict', path_base_map+ 'majles/'+'mj_qa_conflict.json' )
# elastic.restorFileToElastic2('G:/Project2/111/server160/mj_qa_conflict.zip', 'mj_qa_conflict', 'majles', False)
## -----------------------------------------------------------------------
# .\.env\Scripts\activate
# python -m app.majles.majles_conflict_works.py