Commit 004ecc58 authored by Anthony Larcher's avatar Anthony Larcher
Browse files

integration HAL

parent 5d1b0f89
......@@ -94,12 +94,11 @@ def create_bottomline_clustering(model, model_cfg, show, current_diar, file_path
if len(diar_per_cluster.unique('cluster')) > 1:
# calculate vector per cluster
current_vec_within_cluster = extract_vectors(diar_per_cluster,
file_path,
f"{show}_{cluster}",
_, current_vec_within_cluster = extract_vectors(diar_per_cluster,
file_path, # f"{show}_{cluster}",
model_cfg,
model,
show)
show,
model)
vec_within_clusters_dic[cluster] = current_vec_within_cluster
# calculate score and link for each cluster
......@@ -760,6 +759,8 @@ def sort_node_sides(first_seg_list,
:param candidate_pair_number:
:return:
"""
if selection_criteria == "longest":
first_seg_list_sorted, second_seg_list_sorted = sort_node_sides_longest(first_seg_list,
second_seg_list,
......@@ -847,7 +848,6 @@ def get_segment_sorted_list(node_to_check,
second_seg_list,
first_spk,
second_spk,
bottomline_cluster_list,
scores_per_segment,
current_diar,
current_vec,
......@@ -1082,15 +1082,15 @@ def run_active_learning_tree(link,
# otherwise as question to the human about this node
else:
# Ask the human
is_same_speaker, investigated_spk, _ = ask_question_al(node,
link,
bottomline_cluster_list, # scores_per_cluster,
None, # scores_per_segment,
init_diar,
hac_iv_vec,
user,
file_info,
uem,
is_same_speaker, investigated_spk, _ = ask_question_al(node_to_check=node,
linkage_matrix=link,
bottomline_cluster_list=bottomline_cluster_list,
scores_per_segment=None,
init_diar=init_diar,
current_vec=hac_iv_vec,
user=user,
file_info=file_info,
uem=uem,
selection_criteria=selection_method)
# if the question was related to times that corespond to speakers
......@@ -1206,6 +1206,7 @@ def run_active_learning_tree(link,
def allies_within_show_hal(model_cfg,
model,
data_folder,
show,
init_diar,
vec_per_cluster,
......@@ -1252,7 +1253,7 @@ def allies_within_show_hal(model_cfg,
model_cfg,
show,
init_diar,
hal_dir)
data_folder)
bottomline_cluster_list = bottomline_diar.unique('cluster')
......@@ -1319,21 +1320,21 @@ def allies_within_show_hal(model_cfg,
der_track_show[c2s] = der_track_cs
prefix = f"{dir_output_system}/HAL_c2s_{c2s}_th_h_{model_cfg['within_show']['hal_seg']}"
if model_cfg['within_show']['conditional_questioning']:
hal_path = f"{prefix}_{model_cfg['within_show']['conditional_questioning']}/"
else:
hal_path = f"{prefix}/"
#prefix = f"{dir_output_system}/HAL_c2s_{c2s}_th_h_{model_cfg['within_show']['hal_seg']}"
#if model_cfg['within_show']['conditional_questioning']:
# hal_path = f"{prefix}_{model_cfg['within_show']['conditional_questioning']}/"
#else:
# hal_path = f"{prefix}/"
else:
# ideal correction
new_diar, der_track_show = apply_ideal_correction(bottomline_diar, ref, uem, der_track_show)
hal_path = f"{dir_output_system}/simulate_bestHAL/"
#hal_path = f"{dir_output_system}/simulate_bestHAL/"
if not os.path.isdir(hal_path):
os.makedirs(hal_path)
if not os.path.isdir(hal_dir):
os.makedirs(hal_dir)
allies_write_diar(new_diar, f"{hal_path}/{show}.mdtm")
allies_write_diar(new_diar, f"{hal_dir}/{show}.mdtm")
return new_diar
......@@ -151,7 +151,7 @@ def vec2link_xv(model_cfg, xv_vec, current_diar):
distances, th = s4d.clustering.hac_utils.scores2distance(scores, th_w)
distance_sym = scipy.spatial.distance.squareform(distances)
link = scipy.cluster.hierarchy.hac.linkage(distance_sym, method=model_cfg['within_show']['hac_method'])
link = scipy.cluster.hierarchy.linkage(distance_sym, method=model_cfg['within_show']['hac_method'])
return scores, link, th
......
......@@ -35,7 +35,7 @@ import sklearn.mixture
import s4d
from ..user_simulation import Reference
from ..der_single import compute_der
def allies_write_diar(current_diar, filename):
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment