fearlessbj4
commited on
Commit
•
d23f4c9
1
Parent(s):
6be8fdc
Upload /sim_case_sug_demo/g_h.py with huggingface_hub
Browse files- sim_case_sug_demo/g_h.py +117 -99
sim_case_sug_demo/g_h.py
CHANGED
@@ -5,13 +5,13 @@ _config={
|
|
5 |
"sug_based_list":["dispute","plaintiff"],
|
6 |
"sug_pool_list":["corpus3835","2022~2023"],
|
7 |
"embedder_list":["ftlf","ftrob"],
|
8 |
-
"based_index":
|
9 |
"pool_index":1,
|
10 |
"emb_index":1,
|
11 |
"sug_th":20,
|
12 |
"cluster_epsilon":0.67,
|
13 |
"similiar_trace_back_th":0.98,
|
14 |
-
"back_ground_RGB":[
|
15 |
}
|
16 |
emb_dim_lst=[768,1024]
|
17 |
bilstm_len_lst=[19,13]
|
@@ -191,7 +191,7 @@ def ansi_to_html_dis(_f,file_path,_tranpose=True):
|
|
191 |
d2=html_hl(_f["defendant_case2"])
|
192 |
dis1=html_hl(_f["dispute_case1"])
|
193 |
dis2=html_hl(_f["dispute_case2"])
|
194 |
-
score_="\n<mark style=\"background:#
|
195 |
#score_="<mark style=\"color:>"++"\">"+str(_f["ensemble_pred"])+"</mark>"
|
196 |
|
197 |
df=pd.DataFrame(_dict)
|
@@ -221,7 +221,7 @@ def ansi_to_html(_f,file_path,_tranpose=True):
|
|
221 |
|
222 |
p_point1=html_hl(_f["p_point_case1"])
|
223 |
p_point2=html_hl(_f["p_point_case2"])
|
224 |
-
score_="\n<mark style=\"background:#
|
225 |
#score_="<mark style=\"color:>"++"\">"+str(_f["ensemble_pred"])+"</mark>"
|
226 |
|
227 |
df=pd.DataFrame(_dict)
|
@@ -246,7 +246,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
246 |
ANSI_BG_COLORS = {
|
247 |
Fore.BLACK: (0, 0, 0),
|
248 |
Fore.RED: (255, 0, 0),
|
249 |
-
Fore.GREEN: (
|
250 |
Fore.YELLOW: (255, 255, 0),
|
251 |
Fore.BLUE: (0, 0, 255),
|
252 |
Fore.MAGENTA: (255, 0, 255),
|
@@ -331,6 +331,7 @@ def ansi_to_image(ansi_text, font_size=20, image_path="./test.png"):
|
|
331 |
def suggesting_dis(the_pool,target_name,case_dict):
|
332 |
global ANSI_COLORS,_th,c_th,sug_th,corpus_dict,corpus_pd_f,vec_lst,id_lst,sen_lst,corpus_clust_label,_cluster_core_dict,_embedder
|
333 |
global bilstm_len,cnn_len,emb_dim,inset_th,clust_th
|
|
|
334 |
lst_2=[_e for _e in case_dict["dispute"]][:bilstm_len]
|
335 |
|
336 |
#for _e in lst2:
|
@@ -348,6 +349,8 @@ def suggesting_dis(the_pool,target_name,case_dict):
|
|
348 |
|
349 |
rt_lst=[]
|
350 |
for i in tqdm(the_pool):
|
|
|
|
|
351 |
lst_1=[_e for _e in corpus_dict[i]]
|
352 |
id_lst_1=[id_lst[sen_lst.index(_e)] for _e in lst_1]
|
353 |
vec_lst_1=[vec_lst[sen_lst.index(_e)] for _e in lst_1]#[_embedder.encode(_e) for _e in lst_1]
|
@@ -386,98 +389,107 @@ def suggesting_dis(the_pool,target_name,case_dict):
|
|
386 |
#print(cnn_pred)
|
387 |
#print(bilstm_pred)
|
388 |
x_e=[[bilstm_pred[0][0],cnn_pred[0][0]]]
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
pre_lst_1=[[color_lst[inset.index(clst_1[_e]) % len(color_lst)],Fore.WHITE,lst_1[_e],Style.RESET_ALL] if clst_1[_e] in inset else [Style.RESET_ALL,lst_1[_e]] for _e in range(len(lst_1))]
|
394 |
-
pre_lst_2=[[color_lst[inset.index(clst_2[_e]) % len(color_lst)],Fore.WHITE,lst_2[_e],Style.RESET_ALL] if clst_2[_e] in inset else [Style.RESET_ALL,lst_2[_e]] for _e in range(len(lst_2))]
|
395 |
-
|
396 |
-
vlst_1=[[vec_lst_1[_e],pre_lst_1[_e][0]] for _e in range(len(pre_lst_1)) if len(pre_lst_1[_e])==4]
|
397 |
-
vlst_2=[[vec_lst_2[_e],pre_lst_2[_e][0]] for _e in range(len(pre_lst_2)) if len(pre_lst_2[_e])==4]
|
398 |
-
|
399 |
-
#print(lst_1)
|
400 |
-
|
401 |
-
plst_1=replace_all("".join(corpus_pd_f[i.replace("_",",")][0]),key_lst,sp_key,1).split(sp_key)
|
402 |
-
|
403 |
-
dlst_1=replace_all("".join(corpus_pd_f[i.replace("_",",")][1]),key_lst,sp_key,1).split(sp_key)
|
404 |
-
|
405 |
-
v_plst_1=[_embedder.encode(_e) for _e in plst_1]
|
406 |
-
|
407 |
-
v_dlst_1=[_embedder.encode(_e) for _e in dlst_1]
|
408 |
-
|
409 |
-
|
410 |
-
cs_p1=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_1]) for _e in v_plst_1]
|
411 |
-
cs_d1=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_1]) for _e in v_dlst_1]
|
412 |
-
|
413 |
-
cs_p2=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_2]) for _e in v_plst_2]
|
414 |
-
cs_d2=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_2]) for _e in v_dlst_2]
|
415 |
-
|
416 |
-
pre_lst_p1=[[cs_p1[_e][-1],Fore.WHITE,plst_1[_e],Style.RESET_ALL] if cs_p1[_e][0]>_th else [Style.RESET_ALL,plst_1[_e]] for _e in range(len(cs_p1))]
|
417 |
-
pre_lst_d1=[[cs_d1[_e][-1],Fore.WHITE,dlst_1[_e],Style.RESET_ALL] if cs_d1[_e][0]>_th else [Style.RESET_ALL,dlst_1[_e]] for _e in range(len(cs_d1))]
|
418 |
-
|
419 |
-
pre_lst_p2=[[cs_p2[_e][-1],Fore.WHITE,plst_2[_e],Style.RESET_ALL] if cs_p2[_e][0]>_th else [Style.RESET_ALL,plst_2[_e]] for _e in range(len(cs_p2))]
|
420 |
-
pre_lst_d2=[[cs_d2[_e][-1],Fore.WHITE,dlst_2[_e],Style.RESET_ALL] if cs_d2[_e][0]>_th else [Style.RESET_ALL,dlst_2[_e]] for _e in range(len(cs_d2))]
|
421 |
-
|
422 |
-
|
423 |
-
#if max_dp<max([len(plst_1),len(plst_2),len(dlst_1),len(dlst_2)]):
|
424 |
-
# max_dp=max([len(plst_1),len(plst_2),len(dlst_1),len(dlst_2)])
|
425 |
-
|
426 |
-
#print(plst_1)
|
427 |
-
#print(plst_2)
|
428 |
-
#print(dlst_1)
|
429 |
-
#print(dlst_2)
|
430 |
-
draw_lst_1=["".join(_e) for _e in pre_lst_1]
|
431 |
-
draw_lst_2=["".join(_e) for _e in pre_lst_2]
|
432 |
-
|
433 |
-
draw_lst_p1=["".join(_e) for _e in pre_lst_p1]
|
434 |
-
draw_lst_p2=["".join(_e) for _e in pre_lst_p2]
|
435 |
-
draw_lst_d1=["".join(_e) for _e in pre_lst_d1]
|
436 |
-
draw_lst_d2=["".join(_e) for _e in pre_lst_d2]
|
437 |
-
#replace_all(temp_c,key_lst,",",0)
|
438 |
-
|
439 |
-
#print(plst_1)
|
440 |
-
tp_str=""
|
441 |
-
|
442 |
-
#print("---------------------")
|
443 |
-
#print(Fore.BLUE+str(i)+Style.RESET_ALL)
|
444 |
-
temp_ot["case_id"]=i
|
445 |
-
temp_ot["plaintiff_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p1]
|
446 |
-
temp_ot["defendant_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_d1]
|
447 |
-
temp_ot["dispute_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_1]
|
448 |
-
temp_ot["plaintiff_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p2]
|
449 |
-
temp_ot["defendant_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_d2]
|
450 |
-
temp_ot["dispute_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_2]
|
451 |
-
|
452 |
-
tp_str+=Fore.BLUE+str(i)+Style.RESET_ALL+"\n"
|
453 |
-
tp_str+=(Fore.GREEN if temp_ot["ensemble_pred"]>=0.75 else Fore.YELLOW if temp_ot["ensemble_pred"]>=0.5 else Fore.RED)+str(temp_ot["ensemble_pred"])+Style.RESET_ALL+"\n"
|
454 |
-
tp_str+=Fore.MAGENTA+"---plaintiff_case1---"+Style.RESET_ALL+"\n"
|
455 |
-
tp_str+="".join(draw_lst_p1)+Style.RESET_ALL+"\n"
|
456 |
-
|
457 |
-
tp_str+=Fore.MAGENTA+"---defendant_case1---"+Style.RESET_ALL+"\n"
|
458 |
-
tp_str+="".join(draw_lst_d1)+Style.RESET_ALL+"\n"
|
459 |
|
460 |
-
|
461 |
-
tp_str+="".join(draw_lst_1)+Style.RESET_ALL+"\n"
|
462 |
-
###
|
463 |
-
tp_str+=Fore.BLUE+"target"+Style.RESET_ALL+"\n"
|
464 |
-
|
465 |
-
tp_str+=Fore.MAGENTA+"---plaintiff_case2---"+Style.RESET_ALL+"\n"
|
466 |
-
tp_str+="".join(draw_lst_p2)+Style.RESET_ALL+"\n"
|
467 |
-
|
468 |
-
tp_str+=Fore.MAGENTA+"---defendant_case2---"+Style.RESET_ALL+"\n"
|
469 |
-
tp_str+="".join(draw_lst_d2)+Style.RESET_ALL+"\n"
|
470 |
-
|
471 |
-
tp_str+=Fore.MAGENTA+"---dispute_case2---"+Style.RESET_ALL+"\n"
|
472 |
-
tp_str+="".join(draw_lst_2)+Style.RESET_ALL+"\n"
|
473 |
-
|
474 |
-
#tp_str+="---------------------"+"\n"
|
475 |
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
ot=sorted(rt_lst,key=lambda x:x["ensemble_pred"],reverse=True)
|
482 |
ot_lst=[i["output"] for i in ot[:sug_th]]
|
483 |
|
@@ -595,10 +607,16 @@ def suggesting(the_pool,target_name,case_dict):
|
|
595 |
#print("---------------------")
|
596 |
#print(Fore.BLUE+str(i)+Style.RESET_ALL)
|
597 |
temp_ot["case_id"]=i
|
598 |
-
|
599 |
-
temp_ot["
|
600 |
-
temp_ot["
|
601 |
-
temp_ot["
|
|
|
|
|
|
|
|
|
|
|
|
|
602 |
|
603 |
tp_str+=Fore.BLUE+str(i)+Style.RESET_ALL+"\n"
|
604 |
tp_str+=(Fore.GREEN if temp_ot["ensemble_pred"]>=0.75 else Fore.YELLOW if temp_ot["ensemble_pred"]>=0.5 else Fore.RED)+str(temp_ot["ensemble_pred"])+Style.RESET_ALL+"\n"
|
|
|
5 |
"sug_based_list":["dispute","plaintiff"],
|
6 |
"sug_pool_list":["corpus3835","2022~2023"],
|
7 |
"embedder_list":["ftlf","ftrob"],
|
8 |
+
"based_index":1,
|
9 |
"pool_index":1,
|
10 |
"emb_index":1,
|
11 |
"sug_th":20,
|
12 |
"cluster_epsilon":0.67,
|
13 |
"similiar_trace_back_th":0.98,
|
14 |
+
"back_ground_RGB":[217, 225, 242]
|
15 |
}
|
16 |
emb_dim_lst=[768,1024]
|
17 |
bilstm_len_lst=[19,13]
|
|
|
191 |
d2=html_hl(_f["defendant_case2"])
|
192 |
dis1=html_hl(_f["dispute_case1"])
|
193 |
dis2=html_hl(_f["dispute_case2"])
|
194 |
+
score_="\n<mark style=\"background:#d9e1f2;color:"+("green" if _f["ensemble_pred"]>=0.75 else "yellow" if _f["ensemble_pred"]>=0.5 else "red")+"\">"+str(_f["ensemble_pred"])+"</mark>"
|
195 |
#score_="<mark style=\"color:>"++"\">"+str(_f["ensemble_pred"])+"</mark>"
|
196 |
|
197 |
df=pd.DataFrame(_dict)
|
|
|
221 |
|
222 |
p_point1=html_hl(_f["p_point_case1"])
|
223 |
p_point2=html_hl(_f["p_point_case2"])
|
224 |
+
score_="\n<mark style=\"background:#d9e1f2;color:"+("green" if _f["ensemble_pred"]>=0.75 else "yellow" if _f["ensemble_pred"]>=0.5 else "red")+"\">"+str(_f["ensemble_pred"])+"</mark>"
|
225 |
#score_="<mark style=\"color:>"++"\">"+str(_f["ensemble_pred"])+"</mark>"
|
226 |
|
227 |
df=pd.DataFrame(_dict)
|
|
|
246 |
ANSI_BG_COLORS = {
|
247 |
Fore.BLACK: (0, 0, 0),
|
248 |
Fore.RED: (255, 0, 0),
|
249 |
+
Fore.GREEN: (30, 255, 30),
|
250 |
Fore.YELLOW: (255, 255, 0),
|
251 |
Fore.BLUE: (0, 0, 255),
|
252 |
Fore.MAGENTA: (255, 0, 255),
|
|
|
331 |
def suggesting_dis(the_pool,target_name,case_dict):
|
332 |
global ANSI_COLORS,_th,c_th,sug_th,corpus_dict,corpus_pd_f,vec_lst,id_lst,sen_lst,corpus_clust_label,_cluster_core_dict,_embedder
|
333 |
global bilstm_len,cnn_len,emb_dim,inset_th,clust_th
|
334 |
+
|
335 |
lst_2=[_e for _e in case_dict["dispute"]][:bilstm_len]
|
336 |
|
337 |
#for _e in lst2:
|
|
|
349 |
|
350 |
rt_lst=[]
|
351 |
for i in tqdm(the_pool):
|
352 |
+
if target_name==i:
|
353 |
+
continue
|
354 |
lst_1=[_e for _e in corpus_dict[i]]
|
355 |
id_lst_1=[id_lst[sen_lst.index(_e)] for _e in lst_1]
|
356 |
vec_lst_1=[vec_lst[sen_lst.index(_e)] for _e in lst_1]#[_embedder.encode(_e) for _e in lst_1]
|
|
|
389 |
#print(cnn_pred)
|
390 |
#print(bilstm_pred)
|
391 |
x_e=[[bilstm_pred[0][0],cnn_pred[0][0]]]
|
392 |
+
if bilstm_pred[0][0]>=0.75:
|
393 |
+
ensemble_pred=logistic(x_r,y_r,x_e)
|
394 |
+
temp_ot["ensemble_pred"]=float(ensemble_pred[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
+
#print(ensemble_pred)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
|
398 |
+
pre_lst_1=[[color_lst[inset.index(clst_1[_e]) % len(color_lst)],Fore.WHITE,lst_1[_e],Style.RESET_ALL] if clst_1[_e] in inset else [Style.RESET_ALL,lst_1[_e]] for _e in range(len(lst_1))]
|
399 |
+
pre_lst_2=[[color_lst[inset.index(clst_2[_e]) % len(color_lst)],Fore.WHITE,lst_2[_e],Style.RESET_ALL] if clst_2[_e] in inset else [Style.RESET_ALL,lst_2[_e]] for _e in range(len(lst_2))]
|
400 |
+
|
401 |
+
vlst_1=[[vec_lst_1[_e],pre_lst_1[_e][0]] for _e in range(len(pre_lst_1)) if len(pre_lst_1[_e])==4]
|
402 |
+
vlst_2=[[vec_lst_2[_e],pre_lst_2[_e][0]] for _e in range(len(pre_lst_2)) if len(pre_lst_2[_e])==4]
|
403 |
+
|
404 |
+
#print(lst_1)
|
405 |
+
|
406 |
+
plst_1=replace_all("".join(corpus_pd_f[i.replace("_",",")][0]),key_lst,sp_key,1).split(sp_key)
|
407 |
+
|
408 |
+
dlst_1=replace_all("".join(corpus_pd_f[i.replace("_",",")][1]),key_lst,sp_key,1).split(sp_key)
|
409 |
+
|
410 |
+
v_plst_1=[_embedder.encode(_e) for _e in plst_1]
|
411 |
+
|
412 |
+
v_dlst_1=[_embedder.encode(_e) for _e in dlst_1]
|
413 |
+
|
414 |
+
|
415 |
+
cs_p1=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_1]) for _e in v_plst_1]
|
416 |
+
cs_d1=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_1]) for _e in v_dlst_1]
|
417 |
+
|
418 |
+
cs_p2=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_2]) for _e in v_plst_2]
|
419 |
+
cs_d2=[max([[cos_sim(_e,_v[0]),_v[-1]] for _v in vlst_2]) for _e in v_dlst_2]
|
420 |
+
|
421 |
+
pre_lst_p1=[[cs_p1[_e][-1],Fore.WHITE,plst_1[_e],Style.RESET_ALL] if cs_p1[_e][0]>_th else [Style.RESET_ALL,plst_1[_e]] for _e in range(len(cs_p1))]
|
422 |
+
pre_lst_d1=[[cs_d1[_e][-1],Fore.WHITE,dlst_1[_e],Style.RESET_ALL] if cs_d1[_e][0]>_th else [Style.RESET_ALL,dlst_1[_e]] for _e in range(len(cs_d1))]
|
423 |
+
|
424 |
+
pre_lst_p2=[[cs_p2[_e][-1],Fore.WHITE,plst_2[_e],Style.RESET_ALL] if cs_p2[_e][0]>_th else [Style.RESET_ALL,plst_2[_e]] for _e in range(len(cs_p2))]
|
425 |
+
pre_lst_d2=[[cs_d2[_e][-1],Fore.WHITE,dlst_2[_e],Style.RESET_ALL] if cs_d2[_e][0]>_th else [Style.RESET_ALL,dlst_2[_e]] for _e in range(len(cs_d2))]
|
426 |
+
|
427 |
+
|
428 |
+
#if max_dp<max([len(plst_1),len(plst_2),len(dlst_1),len(dlst_2)]):
|
429 |
+
# max_dp=max([len(plst_1),len(plst_2),len(dlst_1),len(dlst_2)])
|
430 |
+
|
431 |
+
#print(plst_1)
|
432 |
+
#print(plst_2)
|
433 |
+
#print(dlst_1)
|
434 |
+
#print(dlst_2)
|
435 |
+
draw_lst_1=["".join(_e) for _e in pre_lst_1]
|
436 |
+
draw_lst_2=["".join(_e) for _e in pre_lst_2]
|
437 |
+
|
438 |
+
draw_lst_p1=["".join(_e) for _e in pre_lst_p1]
|
439 |
+
draw_lst_p2=["".join(_e) for _e in pre_lst_p2]
|
440 |
+
draw_lst_d1=["".join(_e) for _e in pre_lst_d1]
|
441 |
+
draw_lst_d2=["".join(_e) for _e in pre_lst_d2]
|
442 |
+
#replace_all(temp_c,key_lst,",",0)
|
443 |
+
|
444 |
+
#print(plst_1)
|
445 |
+
tp_str=""
|
446 |
+
|
447 |
+
#print("---------------------")
|
448 |
+
#print(Fore.BLUE+str(i)+Style.RESET_ALL)
|
449 |
+
temp_ot["case_id"]=i
|
450 |
+
temp_ot["plaintiff_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_p1]
|
451 |
+
temp_ot["defendant_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_d1]
|
452 |
+
temp_ot["dispute_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_1]
|
453 |
+
temp_ot["plaintiff_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_p2]
|
454 |
+
temp_ot["defendant_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_d2]
|
455 |
+
temp_ot["dispute_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_2]
|
456 |
+
|
457 |
+
#temp_ot["plaintiff_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p1]
|
458 |
+
#temp_ot["defendant_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_d1]
|
459 |
+
#temp_ot["dispute_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_1]
|
460 |
+
#temp_ot["plaintiff_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p2]
|
461 |
+
#temp_ot["defendant_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_d2]
|
462 |
+
#temp_ot["dispute_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_2]
|
463 |
+
|
464 |
+
tp_str+=Fore.BLUE+str(i)+Style.RESET_ALL+"\n"
|
465 |
+
tp_str+=(Fore.GREEN if temp_ot["ensemble_pred"]>=0.75 else Fore.YELLOW if temp_ot["ensemble_pred"]>=0.5 else Fore.RED)+str(temp_ot["ensemble_pred"])+Style.RESET_ALL+"\n"
|
466 |
+
tp_str+=Fore.MAGENTA+"---plaintiff_case1---"+Style.RESET_ALL+"\n"
|
467 |
+
tp_str+="".join(draw_lst_p1)+Style.RESET_ALL+"\n"
|
468 |
+
|
469 |
+
tp_str+=Fore.MAGENTA+"---defendant_case1---"+Style.RESET_ALL+"\n"
|
470 |
+
tp_str+="".join(draw_lst_d1)+Style.RESET_ALL+"\n"
|
471 |
+
|
472 |
+
tp_str+=Fore.MAGENTA+"---dispute_case1---"+Style.RESET_ALL+"\n"
|
473 |
+
tp_str+="".join(draw_lst_1)+Style.RESET_ALL+"\n"
|
474 |
+
###
|
475 |
+
tp_str+=Fore.BLUE+"target"+Style.RESET_ALL+"\n"
|
476 |
+
|
477 |
+
tp_str+=Fore.MAGENTA+"---plaintiff_case2---"+Style.RESET_ALL+"\n"
|
478 |
+
tp_str+="".join(draw_lst_p2)+Style.RESET_ALL+"\n"
|
479 |
+
|
480 |
+
tp_str+=Fore.MAGENTA+"---defendant_case2---"+Style.RESET_ALL+"\n"
|
481 |
+
tp_str+="".join(draw_lst_d2)+Style.RESET_ALL+"\n"
|
482 |
+
|
483 |
+
tp_str+=Fore.MAGENTA+"---dispute_case2---"+Style.RESET_ALL+"\n"
|
484 |
+
tp_str+="".join(draw_lst_2)+Style.RESET_ALL+"\n"
|
485 |
+
|
486 |
+
#tp_str+="---------------------"+"\n"
|
487 |
+
|
488 |
+
|
489 |
+
|
490 |
+
temp_ot["output"]=tp_str
|
491 |
+
rt_lst.append(temp_ot)
|
492 |
+
print(tp_str)
|
493 |
ot=sorted(rt_lst,key=lambda x:x["ensemble_pred"],reverse=True)
|
494 |
ot_lst=[i["output"] for i in ot[:sug_th]]
|
495 |
|
|
|
607 |
#print("---------------------")
|
608 |
#print(Fore.BLUE+str(i)+Style.RESET_ALL)
|
609 |
temp_ot["case_id"]=i
|
610 |
+
|
611 |
+
temp_ot["plaintiff_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_p1]
|
612 |
+
temp_ot["p_point_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_1]
|
613 |
+
temp_ot["plaintiff_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_p2]
|
614 |
+
temp_ot["p_point_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[Back.WHITE],"font_color":ANSI_COLORS[Fore.BLACK],"content":_e[-1]} for _e in pre_lst_2]
|
615 |
+
|
616 |
+
#temp_ot["plaintiff_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p1]
|
617 |
+
#temp_ot["p_point_case1"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_1]
|
618 |
+
#temp_ot["plaintiff_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_p2]
|
619 |
+
#temp_ot["p_point_case2"]=[{"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[_e[1]],"content":_e[-2]} if len(_e)==4 else {"background_color":ANSI_COLORS[_e[0]],"font_color":ANSI_COLORS[Fore.WHITE],"content":_e[-1]} for _e in pre_lst_2]
|
620 |
|
621 |
tp_str+=Fore.BLUE+str(i)+Style.RESET_ALL+"\n"
|
622 |
tp_str+=(Fore.GREEN if temp_ot["ensemble_pred"]>=0.75 else Fore.YELLOW if temp_ot["ensemble_pred"]>=0.5 else Fore.RED)+str(temp_ot["ensemble_pred"])+Style.RESET_ALL+"\n"
|