refactor
This commit is contained in:
+224
-135
@@ -42,14 +42,51 @@ def get_evaluation_data(data):
|
|||||||
result.append("رد تشخیص نوع تعارض")
|
result.append("رد تشخیص نوع تعارض")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
def create_list_procssing(list_input:list,cpu:int,out_put_index_name:str):
|
|
||||||
|
|
||||||
|
def run_to_procssing(list_files, out_put_index_name):
|
||||||
|
results = []
|
||||||
|
for file in list_files:
|
||||||
|
result = asyncio.run(import_from_json(file, out_put_index_name))
|
||||||
|
results.append(result)
|
||||||
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
async def import_conflict_to_elastic(
|
||||||
|
input_path, out_put_index_name, file_jumps, host, password
|
||||||
|
):
|
||||||
|
|
||||||
|
list_files = []
|
||||||
|
if os.path.isdir(input_path):
|
||||||
|
list_files = [
|
||||||
|
os.path.join(input_path, f)
|
||||||
|
for f in os.listdir(input_path)
|
||||||
|
if os.path.isfile(os.path.join(input_path, f))
|
||||||
|
]
|
||||||
|
elif os.path.isfile(input_path):
|
||||||
|
list_files.append(input_path)
|
||||||
|
|
||||||
|
jump_files = []
|
||||||
|
if os.path.exists(file_jumps):
|
||||||
|
with open(file_jumps, "r", encoding="utf-8") as f:
|
||||||
|
jump_files = [line.strip() for line in f if line.strip()]
|
||||||
|
|
||||||
|
list_input = []
|
||||||
|
for file in list_files:
|
||||||
|
if not file in jump_files:
|
||||||
|
list_input.append(file)
|
||||||
|
|
||||||
|
# ----------------------------------------
|
||||||
|
# ---- packing by cpu_count --------------
|
||||||
|
cpu_count = 10
|
||||||
list_process = []
|
list_process = []
|
||||||
|
|
||||||
x = len(list_input)
|
x = len(list_input)
|
||||||
y = (x - (x % cpu)) / cpu
|
y = (x - (x % cpu_count)) / cpu_count
|
||||||
c = x % cpu
|
c = x % cpu_count
|
||||||
list_spilt = []
|
list_spilt = []
|
||||||
for f in range(0, x, int(y)):
|
for f in range(0, x, int(y)):
|
||||||
list_spilt.append(f)
|
list_spilt.append(f)
|
||||||
@@ -59,9 +96,16 @@ def create_list_procssing(list_input:list,cpu:int,out_put_index_name:str):
|
|||||||
for split in list_spilt:
|
for split in list_spilt:
|
||||||
if b + 1 < len_list_spilt:
|
if b + 1 < len_list_spilt:
|
||||||
|
|
||||||
|
|
||||||
print(split, list_spilt[b + 1])
|
print(split, list_spilt[b + 1])
|
||||||
proc = multiprocessing.Process(target=run_to_procssing,args=(list_input[split:list_spilt[b+1]],out_put_index_name))
|
proc = multiprocessing.Process(
|
||||||
|
target=run_to_procssing,
|
||||||
|
args=(
|
||||||
|
list_input[split : list_spilt[b + 1]],
|
||||||
|
out_put_index_name,
|
||||||
|
host,
|
||||||
|
password,
|
||||||
|
),
|
||||||
|
)
|
||||||
proc.start()
|
proc.start()
|
||||||
list_process.append(proc)
|
list_process.append(proc)
|
||||||
b = b + 1
|
b = b + 1
|
||||||
@@ -70,41 +114,15 @@ def create_list_procssing(list_input:list,cpu:int,out_put_index_name:str):
|
|||||||
print("finish ⏹️✅")
|
print("finish ⏹️✅")
|
||||||
|
|
||||||
|
|
||||||
def run_to_procssing(list_files,out_put_index_name):
|
async def import_from_json(file, out_put_index_name, host, password) -> list:
|
||||||
results = []
|
|
||||||
for file in list_files:
|
|
||||||
result = asyncio.run(test(file,out_put_index_name))
|
|
||||||
results.append(result)
|
|
||||||
return results
|
|
||||||
|
|
||||||
async def import_conflict_to_elastic(input_path, out_put_index_name):
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
list_files = []
|
|
||||||
if os.path.isdir(input_path):
|
|
||||||
list_files = [os.path.join(input_path, f) for f in os.listdir(input_path) if os.path.isfile(os.path.join(input_path, f))]
|
|
||||||
elif os.path.isfile(input_path):
|
|
||||||
list_files.append(input_path)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
create_list_procssing(list_input=list_files,cpu=10,out_put_index_name=out_put_index_name)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def test(file,out_put_index_name) -> list:
|
|
||||||
|
|
||||||
time = datetime.datetime.now().timestamp()
|
time = datetime.datetime.now().timestamp()
|
||||||
file_name = file.split("/")[-1:][0]
|
file_name = file.split("/")[-1:][0]
|
||||||
print('▶️',file_name)
|
print("▶️", file_name)
|
||||||
|
|
||||||
host = os.getenv("HOST_160")
|
elastic = ElasticHelper(
|
||||||
password = os.getenv("HOST_160_PASS")
|
es_url=f"http://{host}:6900", es_pass=password, es_user="elastic"
|
||||||
elastic = ElasticHelper(es_url=f"http://{host}:6900",es_pass= password,es_user= "elastic")
|
)
|
||||||
data_all = []
|
data_all = []
|
||||||
try:
|
try:
|
||||||
with open(file, "r") as rfile:
|
with open(file, "r") as rfile:
|
||||||
@@ -119,8 +137,6 @@ async def test(file,out_put_index_name) -> list:
|
|||||||
for item in data_all:
|
for item in data_all:
|
||||||
_id = item["id"]
|
_id = item["id"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
previous_info = item["previous_info"]
|
previous_info = item["previous_info"]
|
||||||
next_info = item["next_info"]
|
next_info = item["next_info"]
|
||||||
version_key = item["version_key"]
|
version_key = item["version_key"]
|
||||||
@@ -141,14 +157,12 @@ async def test(file,out_put_index_name) -> list:
|
|||||||
previous_info["title_type"] = title_type1
|
previous_info["title_type"] = title_type1
|
||||||
next_info["title_type"] = title_type2
|
next_info["title_type"] = title_type2
|
||||||
|
|
||||||
|
|
||||||
conflict_detection = item["conflict_detection"]
|
conflict_detection = item["conflict_detection"]
|
||||||
# conflict_type_detection = item["conflict_type_detection"]
|
# conflict_type_detection = item["conflict_type_detection"]
|
||||||
conflict_relation_identification = item["conflict_relation_type"]
|
conflict_relation_identification = item["conflict_relation_type"]
|
||||||
conflict_evaluation = item["conflict_evaluation"]
|
conflict_evaluation = item["conflict_evaluation"]
|
||||||
conflict_final = item["conflict_final"]
|
conflict_final = item["conflict_final"]
|
||||||
|
|
||||||
|
|
||||||
subject_unity["ref_key"] = "gemma4"
|
subject_unity["ref_key"] = "gemma4"
|
||||||
|
|
||||||
es_data = {
|
es_data = {
|
||||||
@@ -156,7 +170,7 @@ async def test(file,out_put_index_name) -> list:
|
|||||||
"version_key": version_key,
|
"version_key": version_key,
|
||||||
"previous_info": previous_info,
|
"previous_info": previous_info,
|
||||||
"next_info": next_info,
|
"next_info": next_info,
|
||||||
"subject_unitys": [subject_unity]
|
"subject_unitys": [subject_unity],
|
||||||
}
|
}
|
||||||
if conflict_detection:
|
if conflict_detection:
|
||||||
conflict_detection["ref_key"] = "openyourmind"
|
conflict_detection["ref_key"] = "openyourmind"
|
||||||
@@ -164,7 +178,9 @@ async def test(file,out_put_index_name) -> list:
|
|||||||
|
|
||||||
if conflict_relation_identification:
|
if conflict_relation_identification:
|
||||||
conflict_relation_identification["ref_key"] = "openyourmind"
|
conflict_relation_identification["ref_key"] = "openyourmind"
|
||||||
es_data["conflict_relation_identifications"] = [conflict_relation_identification]
|
es_data["conflict_relation_identifications"] = [
|
||||||
|
conflict_relation_identification
|
||||||
|
]
|
||||||
|
|
||||||
if conflict_evaluation:
|
if conflict_evaluation:
|
||||||
conflict_evaluation["ref_key"] = "qwen3-6"
|
conflict_evaluation["ref_key"] = "qwen3-6"
|
||||||
@@ -189,10 +205,7 @@ async def test(file,out_put_index_name) -> list:
|
|||||||
# total_import += total_count
|
# total_import += total_count
|
||||||
time1 = datetime.datetime.now().timestamp()
|
time1 = datetime.datetime.now().timestamp()
|
||||||
time = time1 - time
|
time = time1 - time
|
||||||
print('✅',file_name,":",time)
|
print("✅", file_name, ":", time)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def append_conflict_to_elastic(
|
def append_conflict_to_elastic(
|
||||||
@@ -209,11 +222,15 @@ def append_conflict_to_elastic(
|
|||||||
"llm_output",
|
"llm_output",
|
||||||
],
|
],
|
||||||
ref_key_advance={},
|
ref_key_advance={},
|
||||||
import_if_not_found = False
|
import_if_not_found=False,
|
||||||
):
|
):
|
||||||
list_files = []
|
list_files = []
|
||||||
if os.path.isdir(input_path):
|
if os.path.isdir(input_path):
|
||||||
list_files = [os.path.join(input_path, f) for f in os.listdir(input_path) if os.path.isfile(os.path.join(input_path, f))]
|
list_files = [
|
||||||
|
os.path.join(input_path, f)
|
||||||
|
for f in os.listdir(input_path)
|
||||||
|
if os.path.isfile(os.path.join(input_path, f))
|
||||||
|
]
|
||||||
elif os.path.isfile(input_path):
|
elif os.path.isfile(input_path):
|
||||||
list_files.append(input_path)
|
list_files.append(input_path)
|
||||||
|
|
||||||
@@ -282,19 +299,40 @@ def append_conflict_to_elastic(
|
|||||||
"conflict_evaluations": [],
|
"conflict_evaluations": [],
|
||||||
"conflict_finals": [],
|
"conflict_finals": [],
|
||||||
}
|
}
|
||||||
res = {
|
res = {"_id": id, "_source": _source}
|
||||||
"_id": id,
|
|
||||||
"_source": _source
|
|
||||||
}
|
|
||||||
|
|
||||||
# print("id start...", _id)
|
# print("id start...", _id)
|
||||||
|
|
||||||
subject_unitys = res["_source"]["subject_unitys"] if "subject_unitys" in res["_source"] else []
|
subject_unitys = (
|
||||||
conflict_detections = res["_source"]["conflict_detections"] if "conflict_detections" in res["_source"] else []
|
res["_source"]["subject_unitys"]
|
||||||
conflict_type_detections = res["_source"]["conflict_type_detections"] if "conflict_type_detections" in res["_source"] else []
|
if "subject_unitys" in res["_source"]
|
||||||
conflict_relation_identifications = res["_source"]["conflict_relation_identifications"] if "conflict_relation_identifications" in res["_source"] else []
|
else []
|
||||||
conflict_evaluations = res["_source"]["conflict_evaluations"] if "conflict_evaluations" in res["_source"] else []
|
)
|
||||||
conflict_finals = res["_source"]["conflict_finals"] if "conflict_finals" in res["_source"] else []
|
conflict_detections = (
|
||||||
|
res["_source"]["conflict_detections"]
|
||||||
|
if "conflict_detections" in res["_source"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
conflict_type_detections = (
|
||||||
|
res["_source"]["conflict_type_detections"]
|
||||||
|
if "conflict_type_detections" in res["_source"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
conflict_relation_identifications = (
|
||||||
|
res["_source"]["conflict_relation_identifications"]
|
||||||
|
if "conflict_relation_identifications" in res["_source"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
conflict_evaluations = (
|
||||||
|
res["_source"]["conflict_evaluations"]
|
||||||
|
if "conflict_evaluations" in res["_source"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
conflict_finals = (
|
||||||
|
res["_source"]["conflict_finals"]
|
||||||
|
if "conflict_finals" in res["_source"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
|
||||||
subject_unity = {}
|
subject_unity = {}
|
||||||
conflict_detection = {}
|
conflict_detection = {}
|
||||||
@@ -312,7 +350,11 @@ def append_conflict_to_elastic(
|
|||||||
main_type = ""
|
main_type = ""
|
||||||
description = ""
|
description = ""
|
||||||
reason = ""
|
reason = ""
|
||||||
ref_key_adv = ref_key_advance["subject_unity"] if "subject_unity" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["subject_unity"]
|
||||||
|
if "subject_unity" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["subject_unity"]
|
ss = item["subject_unity"]
|
||||||
if "main_type" in ss:
|
if "main_type" in ss:
|
||||||
@@ -351,8 +393,11 @@ def append_conflict_to_elastic(
|
|||||||
and "conflict_detection" in fields
|
and "conflict_detection" in fields
|
||||||
):
|
):
|
||||||
description = ""
|
description = ""
|
||||||
ref_key_adv = ref_key_advance["conflict_detection"] if "conflict_detection" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_detection"]
|
||||||
|
if "conflict_detection" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["conflict_detection"]
|
ss = item["conflict_detection"]
|
||||||
if "has_conflict" in ss:
|
if "has_conflict" in ss:
|
||||||
@@ -369,7 +414,9 @@ def append_conflict_to_elastic(
|
|||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_detections = clear_array_object_by(conflict_detections, ref_key_adv)
|
conflict_detections = clear_array_object_by(
|
||||||
|
conflict_detections, ref_key_adv
|
||||||
|
)
|
||||||
|
|
||||||
conflict_detections.append(cd)
|
conflict_detections.append(cd)
|
||||||
data["conflict_detections"] = conflict_detections
|
data["conflict_detections"] = conflict_detections
|
||||||
@@ -381,8 +428,11 @@ def append_conflict_to_elastic(
|
|||||||
):
|
):
|
||||||
main_type = ""
|
main_type = ""
|
||||||
description = ""
|
description = ""
|
||||||
ref_key_adv = ref_key_advance["conflict_type_detection"] if "conflict_type_detection" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_type_detection"]
|
||||||
|
if "conflict_type_detection" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["conflict_type_detection"]
|
ss = item["conflict_type_detection"]
|
||||||
if "main_type" in ss:
|
if "main_type" in ss:
|
||||||
@@ -400,7 +450,9 @@ def append_conflict_to_elastic(
|
|||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_type_detections = clear_array_object_by(conflict_type_detections, ref_key_adv)
|
conflict_type_detections = clear_array_object_by(
|
||||||
|
conflict_type_detections, ref_key_adv
|
||||||
|
)
|
||||||
|
|
||||||
conflict_type_detections.append(cd)
|
conflict_type_detections.append(cd)
|
||||||
data["conflict_type_detections"] = conflict_type_detections
|
data["conflict_type_detections"] = conflict_type_detections
|
||||||
@@ -412,8 +464,11 @@ def append_conflict_to_elastic(
|
|||||||
):
|
):
|
||||||
main_type = ""
|
main_type = ""
|
||||||
description = ""
|
description = ""
|
||||||
ref_key_adv = ref_key_advance["relation_identification"] if "relation_identification" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["relation_identification"]
|
||||||
|
if "relation_identification" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["relation_identification"]
|
ss = item["relation_identification"]
|
||||||
if "main_type" in ss:
|
if "main_type" in ss:
|
||||||
@@ -432,7 +487,9 @@ def append_conflict_to_elastic(
|
|||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_relation_identifications = clear_array_object_by(conflict_relation_identifications, ref_key_adv)
|
conflict_relation_identifications = clear_array_object_by(
|
||||||
|
conflict_relation_identifications, ref_key_adv
|
||||||
|
)
|
||||||
conflict_relation_identifications.append(cd)
|
conflict_relation_identifications.append(cd)
|
||||||
data["conflict_relation_identifications"] = (
|
data["conflict_relation_identifications"] = (
|
||||||
conflict_relation_identifications
|
conflict_relation_identifications
|
||||||
@@ -446,8 +503,11 @@ def append_conflict_to_elastic(
|
|||||||
):
|
):
|
||||||
main_type = ""
|
main_type = ""
|
||||||
description = ""
|
description = ""
|
||||||
ref_key_adv = ref_key_advance["conflict_relation_type"] if "conflict_relation_type" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_relation_type"]
|
||||||
|
if "conflict_relation_type" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["conflict_relation_type"]
|
ss = item["conflict_relation_type"]
|
||||||
if "main_type" in ss:
|
if "main_type" in ss:
|
||||||
@@ -466,7 +526,9 @@ def append_conflict_to_elastic(
|
|||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_relation_identifications = clear_array_object_by(conflict_relation_identifications, ref_key_adv)
|
conflict_relation_identifications = clear_array_object_by(
|
||||||
|
conflict_relation_identifications, ref_key_adv
|
||||||
|
)
|
||||||
conflict_relation_identifications.append(cd)
|
conflict_relation_identifications.append(cd)
|
||||||
data["conflict_relation_identifications"] = (
|
data["conflict_relation_identifications"] = (
|
||||||
conflict_relation_identifications
|
conflict_relation_identifications
|
||||||
@@ -477,19 +539,28 @@ def append_conflict_to_elastic(
|
|||||||
and item["conflict_evaluation"]
|
and item["conflict_evaluation"]
|
||||||
and "conflict_evaluation" in fields
|
and "conflict_evaluation" in fields
|
||||||
):
|
):
|
||||||
ref_key_adv = ref_key_advance["conflict_evaluation"] if "conflict_evaluation" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_evaluation"]
|
||||||
|
if "conflict_evaluation" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
item["conflict_evaluation"]["ref_key"] = ref_key_adv
|
item["conflict_evaluation"]["ref_key"] = ref_key_adv
|
||||||
|
|
||||||
conflict_evaluations = clear_array_object_by(conflict_evaluations, ref_key_adv)
|
conflict_evaluations = clear_array_object_by(
|
||||||
|
conflict_evaluations, ref_key_adv
|
||||||
|
)
|
||||||
conflict_evaluations.append(item["conflict_evaluation"])
|
conflict_evaluations.append(item["conflict_evaluation"])
|
||||||
data["conflict_evaluations"] = conflict_evaluations
|
data["conflict_evaluations"] = conflict_evaluations
|
||||||
elif "llm_output" in item and item["llm_output"] and "llm_output" in fields:
|
elif "llm_output" in item and item["llm_output"] and "llm_output" in fields:
|
||||||
main_type = ""
|
main_type = ""
|
||||||
description = ""
|
description = ""
|
||||||
validates = []
|
validates = []
|
||||||
ref_key_adv = ref_key_advance["conflict_evaluation"] if "conflict_evaluation" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_evaluation"]
|
||||||
|
if "conflict_evaluation" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
ss = item["llm_output"]
|
ss = item["llm_output"]
|
||||||
if "main_type" in ss:
|
if "main_type" in ss:
|
||||||
@@ -514,7 +585,9 @@ def append_conflict_to_elastic(
|
|||||||
"description": description,
|
"description": description,
|
||||||
}
|
}
|
||||||
|
|
||||||
conflict_evaluations = clear_array_object_by(conflict_evaluations, ref_key_adv)
|
conflict_evaluations = clear_array_object_by(
|
||||||
|
conflict_evaluations, ref_key_adv
|
||||||
|
)
|
||||||
conflict_evaluations.append(cd)
|
conflict_evaluations.append(cd)
|
||||||
data["conflict_evaluations"] = conflict_evaluations
|
data["conflict_evaluations"] = conflict_evaluations
|
||||||
|
|
||||||
@@ -523,7 +596,11 @@ def append_conflict_to_elastic(
|
|||||||
and item["conflict_final"]
|
and item["conflict_final"]
|
||||||
and "conflict_final" in fields
|
and "conflict_final" in fields
|
||||||
):
|
):
|
||||||
ref_key_adv = ref_key_advance["conflict_final"] if "conflict_final" in ref_key_advance else ref_key
|
ref_key_adv = (
|
||||||
|
ref_key_advance["conflict_final"]
|
||||||
|
if "conflict_final" in ref_key_advance
|
||||||
|
else ref_key
|
||||||
|
)
|
||||||
|
|
||||||
item["conflict_final"]["ref_key"] = ref_key_adv
|
item["conflict_final"]["ref_key"] = ref_key_adv
|
||||||
|
|
||||||
@@ -567,7 +644,6 @@ def append_conflict_to_elastic(
|
|||||||
bulk_data = []
|
bulk_data = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def clear_array_object_by(array, ref_key):
|
def clear_array_object_by(array, ref_key):
|
||||||
array = [c for c in array if c["ref_key"] != ref_key]
|
array = [c for c in array if c["ref_key"] != ref_key]
|
||||||
|
|
||||||
@@ -602,7 +678,14 @@ def get_evaluation_data(data):
|
|||||||
|
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="subject_unitys", key_value="qwen3-6", base_url="http://192.168.23.160"):
|
def genrate_excel_data(
|
||||||
|
elastic,
|
||||||
|
file_ouput,
|
||||||
|
index_name_o="mj_qa_conflict",
|
||||||
|
key="subject_unitys",
|
||||||
|
key_value="qwen3-6",
|
||||||
|
base_url="http://192.168.23.160",
|
||||||
|
):
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
"query": {
|
"query": {
|
||||||
@@ -611,17 +694,13 @@ def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="
|
|||||||
{
|
{
|
||||||
"nested": {
|
"nested": {
|
||||||
"path": key,
|
"path": key,
|
||||||
"query": {
|
"query": {"term": {key + ".ref_key": {"value": key_value}}},
|
||||||
"term": {key+".ref_key": {"value": key_value}}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sort":[
|
"sort": [{"previous_info.ts_date": "desc"}],
|
||||||
{"previous_info.ts_date": "desc"}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print(body)
|
print(body)
|
||||||
@@ -700,14 +779,14 @@ def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="
|
|||||||
subject_unitys = entry.get("subject_unitys", {})
|
subject_unitys = entry.get("subject_unitys", {})
|
||||||
conflict_detections = entry.get("conflict_detections", {})
|
conflict_detections = entry.get("conflict_detections", {})
|
||||||
conflict_type_detections = entry.get("conflict_type_detections", {})
|
conflict_type_detections = entry.get("conflict_type_detections", {})
|
||||||
conflict_relation_identifications = entry.get("conflict_relation_identifications", {})
|
conflict_relation_identifications = entry.get(
|
||||||
|
"conflict_relation_identifications", {}
|
||||||
|
)
|
||||||
conflict_evaluations = entry.get("conflict_evaluations", {})
|
conflict_evaluations = entry.get("conflict_evaluations", {})
|
||||||
conflict_finals = entry.get("conflict_finals", {})
|
conflict_finals = entry.get("conflict_finals", {})
|
||||||
|
|
||||||
|
|
||||||
link = f'=HYPERLINK("{base_url}/refine/conflict/{_id}", "لینک")'
|
link = f'=HYPERLINK("{base_url}/refine/conflict/{_id}", "لینک")'
|
||||||
|
|
||||||
|
|
||||||
subject_rate = 0
|
subject_rate = 0
|
||||||
subject_oss120 = ""
|
subject_oss120 = ""
|
||||||
subject_qwen3_6 = ""
|
subject_qwen3_6 = ""
|
||||||
@@ -764,7 +843,6 @@ def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="
|
|||||||
conflict_openyourmind = str(su["has_conflict"])
|
conflict_openyourmind = str(su["has_conflict"])
|
||||||
conflict_rate += getRate(su["has_conflict"])
|
conflict_rate += getRate(su["has_conflict"])
|
||||||
|
|
||||||
|
|
||||||
relation_rate = 0
|
relation_rate = 0
|
||||||
relation_oss120 = ""
|
relation_oss120 = ""
|
||||||
relation_qwen3_6 = ""
|
relation_qwen3_6 = ""
|
||||||
@@ -793,7 +871,6 @@ def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="
|
|||||||
relation_openyourmind = su["main_type"]
|
relation_openyourmind = su["main_type"]
|
||||||
relation_rate += getRate(su["main_type"])
|
relation_rate += getRate(su["main_type"])
|
||||||
|
|
||||||
|
|
||||||
evalution_rate = 0
|
evalution_rate = 0
|
||||||
evalution_oss120 = ""
|
evalution_oss120 = ""
|
||||||
evalution_qwen3_6 = ""
|
evalution_qwen3_6 = ""
|
||||||
@@ -822,23 +899,56 @@ def genrate_excel_data(elastic, file_ouput, index_name_o="mj_qa_conflict", key="
|
|||||||
evalution_openyourmind = su["main_type"]
|
evalution_openyourmind = su["main_type"]
|
||||||
evalution_rate += getRate(su["main_type"])
|
evalution_rate += getRate(su["main_type"])
|
||||||
|
|
||||||
|
|
||||||
item = [
|
item = [
|
||||||
str(count), _id, link ,
|
str(count),
|
||||||
"", "", subject_rate, subject_oss120, subject_qwen3_6, subject_gemma4_p2, subject_oss120_p2, subject_qwen3_6p2, subject_openyourmind,
|
_id,
|
||||||
"", "", conflict_rate, conflict_oss120, conflict_qwen3_6, conflict_gemma4_p2, conflict_oss120_p2, conflict_qwen3_6p2, conflict_openyourmind,
|
link,
|
||||||
"", "", relation_rate, relation_oss120, relation_qwen3_6, relation_gemma4_p2, relation_oss120_p2, relation_qwen3_6p2, relation_openyourmind,
|
"",
|
||||||
"", "", evalution_rate, evalution_oss120, evalution_qwen3_6, evalution_gemma4_p2, evalution_oss120_p2, evalution_qwen3_6p2, evalution_openyourmind,
|
"",
|
||||||
|
subject_rate,
|
||||||
|
subject_oss120,
|
||||||
|
subject_qwen3_6,
|
||||||
|
subject_gemma4_p2,
|
||||||
|
subject_oss120_p2,
|
||||||
|
subject_qwen3_6p2,
|
||||||
|
subject_openyourmind,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
conflict_rate,
|
||||||
|
conflict_oss120,
|
||||||
|
conflict_qwen3_6,
|
||||||
|
conflict_gemma4_p2,
|
||||||
|
conflict_oss120_p2,
|
||||||
|
conflict_qwen3_6p2,
|
||||||
|
conflict_openyourmind,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
relation_rate,
|
||||||
|
relation_oss120,
|
||||||
|
relation_qwen3_6,
|
||||||
|
relation_gemma4_p2,
|
||||||
|
relation_oss120_p2,
|
||||||
|
relation_qwen3_6p2,
|
||||||
|
relation_openyourmind,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
evalution_rate,
|
||||||
|
evalution_oss120,
|
||||||
|
evalution_qwen3_6,
|
||||||
|
evalution_gemma4_p2,
|
||||||
|
evalution_oss120_p2,
|
||||||
|
evalution_qwen3_6p2,
|
||||||
|
evalution_openyourmind,
|
||||||
]
|
]
|
||||||
print(item)
|
print(item)
|
||||||
|
|
||||||
|
|
||||||
data_out.append(item)
|
data_out.append(item)
|
||||||
|
|
||||||
df = pd.DataFrame(data_out, columns=columns)
|
df = pd.DataFrame(data_out, columns=columns)
|
||||||
# Save to Excel
|
# Save to Excel
|
||||||
df.to_excel(file_ouput, index=False)
|
df.to_excel(file_ouput, index=False)
|
||||||
|
|
||||||
|
|
||||||
def getRate(main_type):
|
def getRate(main_type):
|
||||||
if main_type == "yes":
|
if main_type == "yes":
|
||||||
return 1
|
return 1
|
||||||
@@ -851,55 +961,34 @@ def getRate(main_type):
|
|||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
## -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
# load_dotenv(dotenv_path="config.env")
|
|
||||||
|
|
||||||
# host = "192.168.23.43"
|
|
||||||
# password = "icI1nbkmMQy3WoeaHpBJ"
|
|
||||||
|
|
||||||
# # host = os.getenv("HOST_112")
|
|
||||||
# # password = os.getenv("HOST_112_PASS")
|
|
||||||
|
|
||||||
|
|
||||||
# print(".... host ......", host)
|
|
||||||
|
|
||||||
# path_base_map = r"/home/sisrsis/projects/tavasi/dataParsers/"
|
|
||||||
# elastic = ElasticHelper(es_url="http://192.168.23.43:6900",es_pass= password,es_user= "elastic", path_mappings=path_base_map)
|
|
||||||
|
|
||||||
|
|
||||||
# ## ----------------------------------------------------
|
|
||||||
# map_file = "/home/sisrsis/projects/tavasi/dataParsers/mj_qa_conflict.json"
|
|
||||||
# elastic.createIndex(index_name="mj_qa_conflict",map_name="mj_qa_conflict",mapping_file_path=map_file)
|
|
||||||
|
|
||||||
# input_path = r"/home/sisrsis/projects/tavasi/dataParsers/285k_group_v3"
|
|
||||||
# file_jump_ids = r"/home/sisrsis/projects/tavasi/dataParsers/285k_group_v3_jump_ids.json"
|
|
||||||
|
|
||||||
# asyncio.run(import_conflict_to_elastic(input_path, "mj_qa_conflict", file_jump_ids))
|
|
||||||
|
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
# .\.env\Scripts\activate
|
# .\.env\Scripts\activate
|
||||||
# python -m app.majles.majles_conflict_works_v3
|
# python -m app.majles.majles_conflict_works_async_v3
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
load_dotenv(dotenv_path="config.env")
|
load_dotenv(dotenv_path="config.env")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
host = os.getenv("HOST_160")
|
host = os.getenv("HOST_160")
|
||||||
password = os.getenv("HOST_160_PASS")
|
password = os.getenv("HOST_160_PASS")
|
||||||
|
|
||||||
|
# host = os.getenv("HOST_112")
|
||||||
|
# password = os.getenv("HOST_112_PASS")
|
||||||
|
|
||||||
print(".... host ......", host)
|
print(".... host ......", host)
|
||||||
|
|
||||||
path_base_map = r"/home/sisrsis/projects/tavasi/dataParsers/"
|
|
||||||
elastic = ElasticHelper(es_url=f"http://{host}:6900",es_pass= password,es_user= "elastic", path_mappings=path_base_map)
|
|
||||||
|
|
||||||
|
|
||||||
## ----------------------------------------------------
|
## ----------------------------------------------------
|
||||||
map_file = "/home/sisrsis/projects/tavasi/dataParsers/mj_qa_conflict.json"
|
# path_base_map = "G:/Project2/tavasi_160/src/repo/_other/"
|
||||||
elastic.createIndex(index_name="mj_qa_conflict",map_name="mj_qa_conflict",mapping_file_path=map_file)
|
# elastic = ElasticHelper(es_url=f"http://{host}:6900",es_pass= password,es_user= "elastic", path_mappings=path_base_map)
|
||||||
|
|
||||||
input_path = r"/home/sisrsis/projects/tavasi/dataParsers/285k_group_v3"
|
# map_file = "G:/Project2/tavasi_160/src/repo/_other/majles/mj_qa_conflict.json"
|
||||||
elastic.es.close()
|
# elastic.createIndex(index_name="mj_qa_conflict",map_name="mj_qa_conflict",mapping_file_path=map_file)
|
||||||
asyncio.run(import_conflict_to_elastic(input_path, "mj_qa_conflict"))
|
# elastic.es.close()
|
||||||
|
|
||||||
|
input_path = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3"
|
||||||
|
file_jumps = r"G:\Project2\102_gpu\v3_conflict\285k_group_v3_jump_ids.json"
|
||||||
|
asyncio.run(
|
||||||
|
import_conflict_to_elastic(
|
||||||
|
input_path, "mj_qa_conflict", file_jumps, host, password
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -969,11 +969,11 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
|
|||||||
|
|
||||||
## -----------------------------------------------------------------------
|
## -----------------------------------------------------------------------
|
||||||
|
|
||||||
append_conflict_to_elastic( elastic,
|
# append_conflict_to_elastic( elastic,
|
||||||
input_path=r"G:\Project2\102_gpu\v3_conflict\17K_ev_gemma4\finall_data_finall_gemma4.json",
|
# input_path=r"G:\Project2\102_gpu\v3_conflict\17K_ev_gemma4\finall_data_finall_gemma4.json",
|
||||||
out_put_index_name="mj_qa_conflict",
|
# out_put_index_name="mj_qa_conflict",
|
||||||
ref_key="gemma4",
|
# ref_key="gemma4",
|
||||||
fields=["conflict_evaluation"])
|
# fields=["conflict_evaluation"])
|
||||||
|
|
||||||
# append_conflict_to_elastic( elastic,
|
# append_conflict_to_elastic( elastic,
|
||||||
# input_path=r"G:\Project2\102_gpu\v3_conflict\17K_ev_gemma4\finall_data_finall_oss120.json",
|
# input_path=r"G:\Project2\102_gpu\v3_conflict\17K_ev_gemma4\finall_data_finall_oss120.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user